I have a aspnetcore project need copy some files to other folder after build, post-build script is best idea.
Example:
xcopy $(OutDir)Mocks\* $(ProjectDir)\Mocks\ /Y /D /R /S
But it just work on windows.
Does it support cross-platform?
My build environment is in docker, docker image microsoft/dotnet:2.1.500-sdk.
I think msbuild has copy-file options. Can you use that?
Otherwise you will have to have specific Linux vs. Windows copy code.
@nguerrera @dsplaisted any insights?
@tiayi You can do this with the MSBuild Copy task in a target. Something like this:
<Target Name="CopyMocks" AfterTargets="Build">
<ItemGroup>
<MockFile Include="$(OutDir)Mocks\**\*.*" />
</ItemGroup>
<Copy
SourceFiles="@(MockFile)"
DestinationFolder="$(ProjectDir)\Mocks\%(RecursiveDir)"
SkipUnchangedFiles="true" />
</Target>
Oh, that's helpful. Thank you.
Seems to be answered, closing.
Most helpful comment
@tiayi You can do this with the MSBuild
Copytask in a target. Something like this: