views:

1453

answers:

3

i have a debug and a release version of an assembly dll.

They are sitting is directories on my computer. For other developers they are sitting in directories on their computer.

For the debug version of the application i want to use the debug assembly. For the release version of the application i want to use the release assembly.

That's the question.


For those not paying attention, there are quite a few issues here. How to reference an assembly on my computer, which after the project is checked into source control becomes a valid path on someone elses computer.

How to have the "References" node be per solution type (Debug, Release).

i tried copying the debug assembly to

\bin\Debug

and the release assembly to

\bin\Release

and added the assembly dll's to source control in the

\bin\Debug \bin\Release

folders. Then i hope that the assembly would be found in the executable's folder.

Problem with that is that other developer's machines get an error that the assembly dlls could not be overwritten - when CopyLocal is false.

A: 

Include the project and link to the project? dont know if that does work in your situration...

Petoj
It's not a project, it's an assembly.
Ian Boyd
+4  A: 

Use a common structure for these DLLs (a common directory-name) and link to this relative.

Example from a .csproj-file:

<Reference Include="utils_xxx, Version=1.2.10.0, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\common_utils_dllproject_dir\utils\bin\$(Configuration)\utils_xxx.dll</HintPath>
</Reference>

You maybe have to enter this by hand, but once in the repo, it is the same for all. Now you just have to convince your developers to adjust to this directory-layout and -naming.

PS: If you overlooked it: $(Configuration) is the trick to use Release/Debug-DLLs.

Leonidas
i can't force a directory structure on every developer.
Ian Boyd
+1  A: 
  • Developers must have a folder somewhere on their machine structured like this...
[Parent Folder]
  Debug
    [Debug Assembly].dll
  Release
    [Release Assembly].dll
  • Open the project and add a reference to the Debug assembly from the first step. Check it in.
  • Have every developer open the project and add a reference path in the project properties. The path should be an absolute path to the Debug folder from the first step.
  • Have every developer close Visual Studio and edit the [project].user file that is now in the same folder as the project file. Change "Debug" to "$(Configuration)". Save and close.
  • This should now work. If you select the reference in the Solution Explorer and look at the Path property in the Property Grid, it may not be correct. It's just a VS issue. If you test building in Release and Debug, it should work.

This works because the reference paths that developers set are stored in a user file that never gets checked into source control. Therefore, the paths can be different for every dev. This solution is basically stolen from Leonidas' answer but uses reference paths.

Disclaimer
I don't know all the details of your situation, but I personally wouldn't do this. I would probably GAC the release version of the assembly on the developers' machines. Then I would have a build script that ran on a server that would take care of your complicated scenarios.

whatknott