将其他文件复制到输出目录以进行发布和调试

将其他文件复制到输出目录以进行发布和调试

本文介绍了将其他文件复制到输出目录以进行发布和调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何通过Properties => Copy Always来选择要复制到构建的输出目录中的文件,但是根据构建类型,我一直无法找到一种复制其他文件的方法. /p>

我有两个单独的配置文件,一个设置用于本地开发(即应仅在调试版本中复制),另一个设置用于服务器环境(即应仅在发行版本中复制). /p>

有人知道如何实现这种条件功能吗?

解决方案

当前,我通过使用@Bayeni分享的这篇帖子中的答案的略微修改版本,实现了所需的功能:https://stackoverflow.com/a/8083060/1428743

这目前对我有用,但是如果有更好的方法可以解决此问题,请告诉我.

  <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>

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?

解决方案

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>

这篇关于将其他文件复制到输出目录以进行发布和调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:48