[ACCEPTED]-MSBuild - how to copy files that may or may not exist?-copy
Accepted answer
Use the Exists condition on Copy task.
<CreateItem Include="*.xml">
<Output ItemName="ItemsThatNeedToBeCopied" TaskParameter="Include"/>
</CreateItem>
<Copy SourceFiles="@(ItemsThatNeedToBeCopied)"
DestinationFolder="$(OutputDir)"
Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')"/>
0
The easiest would be to use the ContinueOnError 3 flag http://msdn.microsoft.com/en-us/library/7z253716.aspx
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<MySourceFiles Include="a.cs;b.cs;c.cs"/>
</ItemGroup>
<Target Name="CopyFiles">
<Copy
SourceFiles="@(MySourceFiles)"
DestinationFolder="c:\MyProject\Destination"
ContinueOnError="true"
/>
</Target>
</Project>
But if something else is wrong you 2 will not notice it. So the condition exist 1 from madgnome's answer would be better.
It looks like you can mark MySourceFiles 2 as SkipUnchangedFiles="true" and it won't 1 copy the files if they already exist.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.