Visual Studio 2010 条件引用

发布于 2024-11-17 12:21:32 字数 175 浏览 2 评论 0原文

我们这里有多个产品共享一些公共库。这些库是单独解决方案的一部分(因此它们可以由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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江湖正好 2024-11-24 12:21:32

您应该能够通过直接编辑项目文件来使用条件构造来执行此操作(VS IDE 不会为您执行此操作)。

例如,您可以使用“Choose”元素执行类似的操作:

<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 有 更多有关使用条件构造的信息

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 has more information about using conditional constructs.

嘴硬脾气大 2024-11-24 12:21:32

您可能想看看 NuGet:

NuGet

NuGet 是一款免费、开源、面向 .NET 平台的、以开发人员为中心的包管理系统,旨在简化开发过程中将第三方库合并到 .NET 应用程序中的过程

(在这种情况下,您自己就是第三方)

注意:这不会为您提供条件引用,但可以轻松更新公共组件。

You might want to have a look at NuGet:

NuGet

NuGet is a free, open source developer focused package management system for the .NET platform intent on simplifying the process of incorporating third party libraries into a .NET application during development.

(where you would be the third party yourself in this case)

Note: This would not give you conditional references, but it would ease updating the common components.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文