Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy different file to output directory for release and debug?

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?

like image 362
PseudoPsyche Avatar asked Dec 05 '14 14:12

PseudoPsyche


People also ask

What does Copy to Output Directory do?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.

What is output DIR?

output directory. [ESRI software] In ArcIMS, the folder designated during installation to hold files being served to users for display in a browser.


1 Answers

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>
like image 197
PseudoPsyche Avatar answered Oct 23 '22 13:10

PseudoPsyche