Visual Studio 2010 条件引用 [英] visual studio 2010 conditional references

查看:27
本文介绍了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="..stuffMyStuff.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 有有关使用条件结构的更多信息.

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

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