I want to copy all files recursively with the given file extensions after the build process has successfully completed.
Robocopy
ROBOCOPY %source% %destination% /S *.as?x *.xls? *.mrt
hsor
xcopy .\*.as?x %destination% /SY
xcopy .\*.xls? %destination% /SY
xcopy .\*.mrt %destination% /SY
I tried to insert both features into the post build section in visual studio. RoboCopy exits with an error: Error 1 The command "Source source ROBOCOPY / S * .as? X * .xls? * .Mrt" came out with code 1. Some files were copied, but to the wrong folder (_PublishedWebsites).
xcopy also copies to the wrong directory (_PublishedWebsites), and also does not copy all files.
On the command line, both commands work as expected.
Update
I updated the robocopy command:
ROBOCOPY $(MSBuildProjectDirectory) $(MSBuildProjectDirectory)\..\..\..\EDP\Web\Modules\Invoice\Web /S *.as?x *.xls? *.mrt
Now the files are copied to the right place, but the robocopy return code causes a visual studio error.
Here is a solution using this :
call ROBOCOPY $(MSBuildProjectDirectory) $(MSBuildProjectDirectory)\..\..\..\EDP\Web\Modules\Invoice\Web /S *.as?x *.xls? *.mrt
if %errorlevel% leq 1 exit 0 else exit %errorlevel%
<ItemGroup>
<SourceFiles Include="$(MSBuildProjectDirectory)\**\*.js"/>
<SourceFiles Include="$(MSBuildProjectDirectory)\**\*.html"/>
<SourceFiles Include="$(MSBuildProjectDirectory)\**\*.css*"/>
<SourceFiles Include="$(MSBuildProjectDirectory)\**\*.png"/>
<SourceFiles Include="$(MSBuildProjectDirectory)\**\*.as?x"/>
</ItemGroup>
<Target Name="AfterBuild">
<Copy
SourceFiles="@(SourceFiles)"
DestinationFiles="@(SourceFiles->'%(MSBuildProjectDirectory)..\..\..\EDP\Web\Modules\DMS\Web\%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>