Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first problem with your particular markup appears to confuse <a href="http://msdn.microsoft.com/en-us/library/ms171458.aspx" rel="nofollow">MsBuild $(properties)</a> with <a href="http://msdn.microsoft.com/en-us/library/ms171453.aspx" rel="nofollow">MsBuild %(items)</a> and <a href="http://msdn.microsoft.com/en-us/library/vstudio/646dk05y.aspx" rel="nofollow">MsBuild @(itemgroups)</a>.</p> <p>ProtectedFiles is a property:</p> <pre><code> &lt;!-- A property that is passed a semicolon delimited list of file names --&gt; &lt;PropertyGroup&gt; &lt;ProtectedFiles/&gt; &lt;/PropertyGroup&gt; </code></pre> <p>But it's being treated as an Item and wouldn't have any %item.metadata:</p> <pre><code>&lt;--! An ItemGroup to pick up the files&gt; &lt;ItemGroup&gt; &lt;FilesToDelete Include=$(DeploymentTargetFolder)\*.* Exclude="@(ProtectedFiles-&gt;'$(DeployTargetFolder)\%(identity)')" &lt;ItemGroup/&gt; </code></pre> <p>Save the following markup locally as "foo.xml", then call "<strong>msbuild.exe foo.xml</strong>" and observe the output:</p> <pre><code>&lt;Project ToolsVersion="4.0" DefaultTargets="foo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; &lt;PropertyGroup&gt; &lt;FilesProp&gt;FileA.txt;FileB.txt&lt;/FilesProp&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;ProtectedFiles Include="FileA.txt" /&gt; &lt;ProtectedFiles Include="FileA.txt" /&gt; &lt;/ItemGroup&gt; &lt;Target Name="foo"&gt; &lt;Message Importance="high" Text="ProtectedFiles ItemGroup: @(ProtectedFiles)" /&gt; &lt;Message Importance="high" Text="ProtectedFiles ItemGroup transform: @(ProtectedFiles-&gt;'%(Identity)')" /&gt; &lt;Message Importance="high" Text="FilesProp Property: $(FilesProp)" /&gt; &lt;Message Importance="high" Text="FilesProp Property: @(FilesProp-&gt;'%(FilesProp.Identity)')" /&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre> <p>Will yield the following output:</p> <pre><code>foo: ProtectedFiles ItemGroup: FileA.txt;FileA.txt ProtectedFiles ItemGroup transform: FileA.txt;FileA.txt FilesProp Property: FileA.txt;FileB.txt FilesProp Property: </code></pre> <p>If you're unable to change the design and need to convert a Property comprising a semi-colon delimited list of file paths, use the <a href="http://msdn.microsoft.com/en-us/library/s2y3e43x.aspx" rel="nofollow">MsBuild &lt;CreateItem /&gt; task</a>.</p> <p>Add this markup to foo.xml occurring after the Foo target, then invoke msbuild again, but using the "bar" target (e.g. <strong>msbuild.exe foo.xml /t:bar</strong>)</p> <pre><code>&lt;Target Name="bar"&gt; &lt;CreateItem Include="$(FilesProp)"&gt; &lt;Output TaskParameter="Include" ItemName="TheFiles"/&gt; &lt;/CreateItem&gt; &lt;Message Text="TheFiles ItemGroup: @(TheFiles)" Importance="high" /&gt; &lt;Message Text="Output each item: %(TheFiles.Identity)" Importance="high" /&gt; &lt;/Target&gt; </code></pre> <p>Will yield the following output:</p> <pre><code>bar: TheFiles ItemGroup: FileA.txt;FileB.txt Output each item: FileA.txt Output each item: FileB.txt </code></pre> <p>Next you should rethink some of your assumptions. I don't believe the file extension should be the determining factor when deciding which files to update, rather you should rely on MsBuild's ability to build tasks incrementally allowing it to perform a task only if the inputs are newer than the outputs. You can do this by using an <a href="http://msdn.microsoft.com/en-us/library/3e54c37h.aspx" rel="nofollow">MsBuild &lt;Copy /&gt; task</a> configured to skip unchanged files.</p> <p>Add this markup to the above Xml file, then modify the $(SourceFolder) and $(TargetFolder) to point to a source folder you'd like to copy recursively, and a destination folder to place the files. Build using "<strong>msbuild.exe foo.xml /t:Deployment</strong>" and observe the output.</p> <pre><code>&lt;Target Name="Deployment"&gt; &lt;PropertyGroup&gt; &lt;SourceFolder&gt;c:\sourcefolder\&lt;/SourceFolder&gt; &lt;TargetFolder&gt;c:\destinationfolder\&lt;/TargetFolder&gt; &lt;/PropertyGroup&gt; &lt;CreateItem Include="$(SourceFolder)\**\*.*"&gt; &lt;Output TaskParameter="Include" ItemName="FilesToCopy" /&gt; &lt;/CreateItem&gt; &lt;Copy SourceFiles="@(FilesToCopy)" DestinationFolder="$(TargetFolder)%(RecursiveDir)" SkipUnchangedFiles="true" /&gt; &lt;/Target&gt; </code></pre> <p>Without modifying any of the source files, run the command again and note that no files were copied.</p> <p>Modify a file in the source folder, then run the command again. Notice that only the updated files were copied?</p> <p>I hope this gets you on the right track. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload