Editing project references in visual studio 2005 project files

Currently, if you add a reference to a project that is outside the folder structure of the current solution, but on the same drive, you will get a relative path in the HintPath of the .csproj file. The only problem we have with this, is that the reference will be to a DLLat an exact location, so switching between debug and release build will still reference the same DLL.

I've found that you can edit the HintPath in the .csproj file to use the expansion $(Configuration) and the referencing project will use the appropriate version of the DLL.  So for example I change:

 <HintPath>..\..\..\Solution1\ClassLibrary1\ClassLibrary1\bin\Debug\Project1.dll</HintPath>
 to
 
<HintPath>..\..\..\Solution1\ClassLibrary1\ClassLibrary1\bin\$(Configuration)\Project1.dll</HintPath>


My question is, is it safe to do this. Since references cannot be edited in the gui, (only added or removed) it would seem to me that this is safe, especially now that this .csproj files are effectively the make files for msbuild.

Any official opinion on whether this is appropriate or not


Answer this question

Editing project references in visual studio 2005 project files

  • Darren Neimke

    As I said, the project I'm referencing is outside the folder structure of this solution. That is, it is in a different solution to the solution I'm making the reference from. Unless I'm missing something, project references only work for projects within the same solution.

  • Tr&amp;#7847;n Ng&amp;#7885;c V&amp;#259;n

    You can add the same project in multiple solutions.  And projects in a solution can come from different directories.  So, add that other project to your current solution and make it a project reference.

    Project references were created for the same problem you are trying to solve.

  • GeuS

    Not going to happen. As it is, it takes 6 minutes to open one of our solutions. The reason we split our work into multiple solutions is that the solution is to big to handle in one bite. Builds would take forever, and especially under Team Foundation the solution would take forever to open. Each of our solutions already has multiple projects, and we use project references, we just need this functionality.

    There are other ways we can make this work, including copying DLL's from other solutions to a local lib directory using pre-build macros, but this is cumbersome slow since XCopy does not seem to work under VS2005.

    What I'm looking for, is whether their is a risk in doing what I propose, not if there is a different way of doing it.

  • minhhoang

    Well, in this case, you should use Project references.  You can add "ClassLibrary1" as a project in your current solution and add it as a reference to your current project.
  • Bassim Matuk

    Hi Milow,what you are doing is certainly supported in Whidbey. Let us know if you hit into any problems in this scenario.

    -Thanks,
    Prasadi

  • Editing project references in visual studio 2005 project files