Does Visual Studio 2008 support configuration (debug/release build) specific references?

十年热恋 提交于 2019-12-01 20:34:14

What I usually do is set the output path for all projects to the same location depending on the configuration. Eg for release builds everything goes into /path/to/Release and for Debug to /path/to Debug. Then I manually edit the project file to include a seperate targets file containing something like this:

edit shows how to use conditions to select debug/release dll with a prefix

<-- file myDll.targets -->
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
  <ItemGroup  Condition=" '$(Configuration)' == 'Debug' ">
    <Reference Include="myDll_d">
      <Private>False</Private>
    </Reference>
  </ItemGroup>
  <ItemGroup  Condition=" '$(Configuration)' == 'Release' ">
    <Reference Include="myDll">
      <Private>False</Private>
    </Reference>
  </ItemGroup>
</Project>

Then in the project that needs to reference this dll the targets file is included:

<Import Project="myDll.targets"/>

Because of Private=false msbuild won't try to copy anything, it just looks for myDll.dll and will find it in the output path.

This is not particularly clean but does work. The targets file can also be modified to reference different platforms (x86/x64).

Your first idea is probably what is mostly used as it requires the less hassle - except indeed that the projects should be in the same solution (as far as I know);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!