以不同的配置引用不同的程序集 [英] Referencing different assemblies in different configurations

查看:88
本文介绍了以不同的配置引用不同的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在问之前,我阅读了线程。那里没有帮助。

Before asking, I read this and this threads. No help there.

我正在使用Visual Studio 2003(这是我的雇主要求的),但我想对VS更高版本的回答也可能有用。

I am using Visual Studio 2003 (this is mandated by my employer) but I guess answers to later versions of VS might also be useful.

所以,想象一下我有两个.Net项目:A-一个类库,B-一个应用程序。在BI中,单击添加引用,转到项目选项卡,然后选择A。在这种情况下,B的调试版本将引用A的调试版本,而B的发行版本。 B将使用A的发行版。现在想象一下,代替项目AI,它只有两个程序集-aD.dll和a.dll。我没有任何创建这些项目的项目。我要执行的是强制B的Debug版本引用aD.dll,B的发行版本引用a.dll

问题1:我该怎么做? / em>

So, imagine I have two .Net projects: A - which is a class library and B - which is an application. In B I click Add Reference, go to the Projects tab and choose A. In this scenario the debug version of B will reference the debug version of A, and the release version of B will use the release version of A. Now imagine that instead of project A I just have two assemblies - aD.dll and a.dll. I don't have any project that creates these. What I want to do is enforce that Debug version of B reference aD.dll, and the release version of B reference a.dll
Question 1: How do I do this?

当我想引用某些dll时,我转到添加引用-> 浏览并浏览我的dll。但是我需要指定的不是完整路径,而是相对路径。

问题2:我该怎么做?

When I want to reference some dll, I go to add reference -> Browse and browse my dll. But I need to specify not the full path, but the relative path.
Question 2: How do I do this?

这是紧急情况,在此先感谢:)

This is an emergency, thanks in advance :)

推荐答案

你不能做可以通过IDE来实现,但是您可以通过手动入侵.csproj文件来实现。

You can't do this through the IDE, but you can do it by hacking the .csproj file by hand:

如果您已经引用了 a.dll

<Reference Include="a">...</Reference>

...然后尝试以下条件:

...then try a pair of conditions as follows:

<Reference Condition="'$(Configuration)' == 'Release'" Include="a">...</Reference>
<Reference Condition="'$(Configuration)' == 'Debug'" Include="aD">...</Reference>

编辑:以下是您可以在<参考> 元素: http: //msdn.microsoft.com/zh-CN/library/bb629388.aspx

Here's an explanation of what you can put inside a <Reference> element: http://msdn.microsoft.com/en-us/library/bb629388.aspx

这篇关于以不同的配置引用不同的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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