Configure the .NET reference configuration dependence

My application has several configurations for debug/release builds, as well as 32-bit and 64-bit builds. Now using 32-bit and 64-bit builds, I need to reference different dlls (I.e. those built with x86 and those built with x64), but the references seem to be global to my project and do not depend on configuration. Now, when I switch from 32-bit to 64-bit build, I always have to Exchange references (and vice versa). What is the appropriate way to implement different references for different configurations?
This can be done through some manual operations on the project file.

First , You need to right-click the project and click “Unload Project”. Then right-click it again and select Edit [Project Name].

When it loads in the editor, you will see Various entries to your refences:




3.0


3.0


3.0


False
..\Common\Lib\3rdParty\Prism \4.0\Desktop\Microsoft.Practices.ServiceLocation.dll

Please note that these are all inside the ItemGroup node.
You can now perform some magic…Add an expression To your ItemGroup to use it only when the build configuration has a certain number of bits:




Please note that this operation cannot be performed through the UI, so you must manually manage these reference lists (for example, if you need to add other references).

Also Note that this is not a hack…it just uses one of the features of MSBuild (VS used to build your project). You can use any expression you like to have as many of these ItemGroup lists as possible-if it doesn’t have an expression, Then it will always be included in the build.

My app has several configurations for debug/release builds, as well as 32-bit and 64-bit builds. Now using For 32-bit and 64-bit builds, I need to reference different dlls (i.e. those built with x86 and those built with x64), but the references seem to be global to my project and do not depend on the configuration. Now, when I download from When switching from 32-bit to 64-bit builds, I always have to exchange references (and vice versa). What is the appropriate way to implement different references for different configurations?

This can be done through some manual operations on the project file.

First, you need to right-click the project, and then click “Unload project”. Then right-click it again and select edit [project name].

When it loads in the editor, you will see various entries for your refences:




3.0< /RequiredTargetFramework>


3.0


3.0


False
..\Common\Lib\3rdParty\Prism\4.0\Desktop\Microsoft.Practices.ServiceLocation.dll

Note that these are all inside the ItemGroup node.
You can now perform some magic…Add an expression to your ItemGroup to use it only when the build configuration has a certain number of bits:

< p>




Please note that this operation cannot be performed through the UI, so you must Manually manage these reference lists (for example, if you need to add other references).

Also note that this is not a hack…it just uses one of the features of MSBuild (VS uses to build your project). You can use any expression you like to have as many of these ItemGroup lists-if it doesn’t have an expression, then it will always be included in the build.

Leave a Comment

Your email address will not be published.