Copy different file to output directory for releas

2020-08-26 03:30发布

I know how to select files that I want copied to the output directory of my build via Properties=>Copy Always, but I haven't been able to find a way to copy a different file depending on the build type.

I have two separate config files, one set up for local development (ie. should be copied on debug build only) and one that is set up for the server environment (ie. should be copied on release build only).

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

2条回答
闹够了就滚
2楼-- · 2020-08-26 03:54

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

查看更多
地球回转人心会变
3楼-- · 2020-08-26 03:57

Currently I have achieved the desired functionality by using a slight modified version of the answer in this post that @Bayeni shared: https://stackoverflow.com/a/8083060/1428743

This is currently working for me, but if there is a better way to go about 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>
查看更多
登录 后发表回答