Question

I have an MVC3 project in VS2010 (Project A) and I want to reference an assembly in one of my other projects (Project B). Project B outputs to \bin\Debug and \bin\Release. I want to add a reference to the proper Project B assembly, based on the configuration of Project A. Is there a way to do this without having to include Project B in Project A's solution? I've always included the project in my solution if I've needed to do this in the past, is this the only and best option?

Was it helpful?

Solution

IMO adding the project to solution is much better if you have access to the project, if you want to make the reference point to different file locations based on the current configuration you can open up the csproj file in a text editor and modify the Reference hint by introducing a macro and the reference path will vary accordinlgy. For example you can do something like this in A.csproj

<Reference Include="B,...">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\ProjectB\bin\$(Configuration)\B.dll</HintPath>
</Reference>

and when you reload the project and view the reference properties you will see that the path changes with the selected configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top