Copy another file to the output directory for release and debugging?

I know how to select the files that I want to copy to the output directory of my assembly through Properties => Copy Always, but I could not find a way to copy another file depending on the type of assembly.

I have two separate configuration files, one of which is configured for local development (i.e. it should be copied only for debug builds), and one that is configured for the server environment (i.e. it should be copied only in the release version) .

Does anyone know how to achieve this type of conditional function?

+5
source share
2 answers

I have currently achieved the desired functionality using a small modified version of the answer in this post, which @Bayeni shared: fooobar.com/questions/59753 / ...

This currently works for me, but if there is a better way to do this, please let me know.

<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <Content Include="local.cfg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <ItemGroup Condition=" '$(Configuration)' == 'Release' "> <Content Include="release.cfg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> 
+5
source

Why don't you use the PostBuild event and call xCopy to copy the files you need?

0
source

Source: https://habr.com/ru/post/1208433/


All Articles