开发者

Referencing different assemblies in different configurations

开发者 https://www.devze.com 2023-01-23 10:09 出处:网络
Before asking, I read this and this threads. No help there. I am using Visual Studio 2003 (this is mandated by my employer) but I guess answers to later versions of VS might also b开发者_如何学Ce use

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

I am using Visual Studio 2003 (this is mandated by my employer) but I guess answers to later versions of VS might also b开发者_如何学Ce useful.

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?

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 :)


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

If you've already got a reference to, say, 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>

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

0

精彩评论

暂无评论...
验证码 换一张
取 消