How to reference a different assembly when building from Visual Studio?
Hi,
After I updated one of my machines to Visual Studio 2010 SP1 I started getting build error when executing builds from the VS UI. When I was doing the build using msbuild from the command line everything worked fine.
We struggle a bit to understand what was going on and realized that the issue was that Visual Studio 2010 SP1 comes with a different assembly (new dll for Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll). But the dll that we were using for command line builds was the one from the VS 2010 vanilla. And this is what was causing the build to fail.
We could have solved this by just pointing the reference to the assembly from VS but that would cause the command line build to fail on different environments.
But I found out that there's a way to have conditional references. So in the end the solution looked like this:
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" Condition=" '$(BuildingInsideVisualStudio)' == 'true'">
<HintPath>$(VS100COMNTOOLS)\..\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" Condition=" '$(BuildingInsideVisualStudio)' != 'true'">
<HintPath><command line reference location>\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
</Reference>
This way we have the best of both worlds. Our code builds from VS using the VS 2010 SP1 binary and from command line using the assembly that we have access to at build time.
Please let me know if you have any questions about this,
Ionutz