• Create Account

## Visual Studio C#

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1maya18222  Members

194
Like
0Likes
Like

Posted 18 August 2012 - 04:28 AM

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?

### #2TheTroll  Members

883
Like
0Likes
Like

Posted 18 August 2012 - 04:53 PM

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.

### #3maya18222  Members

194
Like
0Likes
Like

Posted 19 August 2012 - 03:46 AM

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.

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.

### #4SiCrane  Moderators

11522
Like
2Likes
Like

Posted 19 August 2012 - 04:38 AM

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
<Reference Include="MyAssembly, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>path\to\MyAssembly.dll</HintPath>
</Reference>

in your project and change it to something like
<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>

For the MSBuild condition syntax see this.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.