Visual Studio 2010的参考条件 [英] visual studio 2010 conditional references

查看:167
本文介绍了Visual Studio 2010的参考条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们这里有多种的产品,共享一些公共库。这些库是一个独立的解决方案的一部分(这样他们就可以通过TFS独立待建),但问题是发展过程中,人们必须修改公共库,把它编译成二进制文件,将其复制到公共位置,编译产品解决方案

We have multiple products here that shared some common libraries. These libraries are part of a separate solution (so they can be built by TFS independently), but the problem is during development, one has to modify the common library, compile it to binary, copy it to the common location, compile the product solution.

为了避免这种情况其实我​​想知道如果它可能有参考条件,因此调试配置,我将引用他们作为项目引用,而在发布配置,他们将是二进制的引用。

In order to avoid this actually I am wondering if its possible to have conditional references, so for a debug configuration, I would reference them as project references, while in release configuration they would be binary references.

推荐答案

您应该能够通过直接编辑的项目文件与条件结构做到这一点(VS IDE不会为你做这个)。

You should be able to do this with conditional constructs by editing the project file directly (VS IDE won't do this for you).

例如,你可能会做这样的事情用选择元素:

For example, you might do something like this using the "Choose" element:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
    <PropertyGroup>
        <!-- ... --> 
    </PropertyGroup>
    <Choose>

        <When Condition=" '$(Configuration)'=='Debug' ">
            <ItemGroup>
                <ProjectReference Include="..\stuff\MyStuff.csproj">
                    <Project>{4c7bbe47-8d84-45d4-95f0-f640ba59563c}</Project>
                    <Name>MyStuff</Name>
                </ProjectReference>
            </ItemGroup>
        </When>

        <When Condition=" '$(Configuration)'=='Retail' ">
            <ItemGroup>
                <Reference Include="MyStuff.dll" />
            </ItemGroup>
        </When>

    </Choose>
    <!-- Rest of Project -->
</Project>

MSDN有关于使用条件结构 更多信息。

MSDN has more information about using conditional constructs.

这篇关于Visual Studio 2010的参考条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆