# Visual Studio C#

This topic is 1977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

1. How do you set your project to refer to different references based on the build mode? For example, how do I reference

"Libs\someDebugLib.dll" in my debug build

and

"Libs\someReleaseLib.dll" in my release build

2. How come when using .net libraries you dont have to select debug or release versions? ... is the correct one being chosen under the hood? .. if so, how?

##### Share on other sites
1. In C# you don't. In general when you add a reference you add the debug version. When you are ready to release just include the release version.
2. The only real difference between the two is when in debug the optimizations are disabled. This makes it harder to debug. But you can include either one and they will both work.

##### Share on other sites
[quote name='TheTroll' timestamp='1345330418' post='4970941']
1. In C# you don't. In general when you add a reference you add the debug version. When you are ready to release just include the release version.
2. The only real difference between the two is when in debug the optimizations are disabled. This makes it harder to debug. But you can include either one and they will both work.
[/quote]

But lets say you're working on a project with lots of references, and if as you say, you just set the debug references, but having to change these to the release versions each time you want to build a release version (which could be quite often, especially if you're keeping track on performance), is a real pain.

##### Share on other sites
I don't know of any way to do it from the IDE, but you can manually modify the .csproj to change references to conditional references. Basically you find a line that looks like
[code]
<Reference Include="MyAssembly, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>path\to\MyAssembly.dll</HintPath>
</Reference>
[/code]
in your project and change it to something like
[code]
<Reference Include="MyAssembly, processorArchitecture=MSIL"
Condition=" '$(Configuration)'=='Debug' "> <SpecificVersion>False</SpecificVersion> <HintPath>path\to\MyDebugAssembly.dll</HintPath> </Reference> <Reference Include="MyAssembly, processorArchitecture=MSIL" Condition=" '$(Configuration)'=='Release' ">
<SpecificVersion>False</SpecificVersion>
<HintPath>path\to\MyReleaseAssembly.dll</HintPath>
</Reference>
[/code]
For the MSBuild condition syntax see [url=http://msdn.microsoft.com/en-us/library/7szfhaft]this[/url].