Referencing Public/Private/Reference Assemblies folder from your project

2011-12-08

When you're working on Code Analysis Rules, Custom build activities, MSBuild tasks or anything that integrates directly in Team Build or Visual Studio for that matter, you often need to reference assemblies that ship with Visual Studio.

These assemblies are usually stored somewhere in the Visual Studio installation path. Now if you're the only person working on your project, you'll probably not run into any issues here, but if you're using multiple machines, or more than one person is working on the project or you want to leverage the power of Team Build, you'll soon find out that your references become unreliable.



To solve the issues, you'll need to edit the project file by hand and fix the hintpath in your Assembly References. There's a few variables that point to a place inside the Visual Studio installation directory and $(DevEnvPath) would seem the most logical choice.

Turns our that while $(DevEnvPath) works fine inside Visual Studio, it doesn't carry over into Team Build, unless you set a system wide environment variable. Not ideal. But it works.

There are however two less obvious and less descriptive variables you can use: $(VSINSTALLDIR) or $(VS100COMNTOOLS). These two work irrespectively of where you're doing the build, as long as Visual Studio is installed on the system/buildserver in question.

See also:



 

Search This Blog

Loading...

Most Reading