FindUnderPath not working

I have a strange thing going on.

I am using FindUnderPath to make sure my files exist before I do anything with them in deployment. The problem is, FindUnderPath says the files exist and gives locations in "InPath" but the files are missing. How is it finding a file that isn't there

<PropertyGroup>

<ReleaseRoot>\\build\BuildSuppository\Duck\$(BuildNum)\Release</ReleaseRoot>

</PropertyGroup>

<ItemGroup>

<AppFilesSrc Include="$(ReleaseRoot)\thing1.dll;

$(ReleaseRoot)\thing1.pdb

"/>

</ItemGroup>

<Target Name="ValidateFilesExist">

<Message Text="Validate that files exist before doing anything." />

<FindUnderPath

Files="@(AppFilesSrc)"

Path="$(ReleaseRoot)">

<Output

TaskParameter="InPath"

ItemName="FilesFound" />

<Output

TaskParameter="OutOfPath"

ItemName="FilesNotFound" />

</FindUnderPath>

<Message Text="Missing: @(FilesNotFound)" />

<Message Text="Found: @(FilesFound)" />

<Touch Files="@(DeployFail)" AlwaysCreate="true" Condition=" '@(FilesNotFound)' != ''" />

<Error Text="Missing Files: @(FilesNotFound)" Condition=" '@(FilesNotFound)' != ''" />

</Target>

When I run this, the log says: Build started 6/13/2006 6:16:35 PM.
__________________________________________________
Project "C:\Inetpub\wwwroot\AbazabDeploy.proj" (default targets):

Target ValidateFilesExist:
Validate that files exist before doing anything.
Missing:
Found: \\build\BuildSuppository\Duck\[buildNum]\Release\thing1.dll;\\build\BuildSuppository\Duck\[buildNum]\Release\thing1.pdb

The problem is there is no thing1.pdb. It was deleted. So why does it say it's there



Answer this question

FindUnderPath not working

  • Luke D

    Hi,

    I don't think the FindUnderPath task goes to the disk to check to see if the file is present, but compares the path of the file to the path provided. If the file has that path then it is returned in the InPath item. So if you manually create these items with the path then they will be present in the InPath item. Something that may help you is using the Condition with an Exist clause. If you need a list of files that are missing as in your example have a look at this modified project file.

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="ValidateFilesExist">

    <PropertyGroup>

    <ReleaseRoot>FileRoot\</ReleaseRoot>

    </PropertyGroup>

    <ItemGroup>

    <AppFilesSrc Include="$(ReleaseRoot)\thing1.dll;$(ReleaseRoot)\thing1.pdb;$(ReleaseRoot)\**\*"/>

    </ItemGroup>

    <Target Name="ValidateFilesExist">

    <Message Text="Validate that files exist before doing anything." />

    <FindUnderPath Files="@(AppFilesSrc)" Path="$(ReleaseRoot)">

    <Output TaskParameter="InPath" ItemName="FilesFound" />

    <Output TaskParameter="OutOfPath" ItemName="FilesNotFound" />

    </FindUnderPath>

    <CreateItem Include="%(AppFilesSrc.Identity)" Condition="Exists('%(AppFilesSrc.FullPath)')">

    <Output ItemName="RealFoundFiles" TaskParameter="Include"/>

    </CreateItem>

    <CreateItem Include="%(AppFilesSrc.Identity)" Condition="!Exists('%(AppFilesSrc.FullPath)')">

    <Output ItemName="RealNotFoundFiles" TaskParameter="Include"/>

    </CreateItem>

    <Message Text="Missing: @(FilesNotFound)" />

    <Message Text="Found: @(FilesFound)" />

    <Message Text=" "/>

    <Message Text="Real Found: @(RealFoundFiles)" />

    <Message Text="Real Not Found: @(RealNotFoundFiles)" />

    </Target>

    </Project>

    Sayed Ibrahim Hashimi
    www.sedodream.com


  • baron5038

    Hi,
    Glad I could help! You can place conditions on all MSBuild elements. My book does cover topics such as this. Another place to look is my article Inside MSBuild along with the Web Resources listed there.

    Sayed Ibrahim Hashimi
    www.sedodream.com

  • Homiczek

    Sir,
    You've helped me yet again. Thank you so much.
    I had no idea that I could make conditions using the metadata like that.
    Does your book cover things like this
    My main source of documentation is:
    http://msdn2.microsoft.com/en-us/library/0k6kkbsd(VS.80).aspx

    I am looking for better information and tricks like like the help you have provided.

    Thanks again for you help.
    -Marc

  • FindUnderPath not working