In a large solution, I’m integrating Gendarme into Visual Studio 2008 compilation process. I am using GendarmeMsBuild task along with a .targets file to add a AfterBuild target to every project in the solution. I am looking for a way to import this file into .csproj files in a way that wouldn’t require me to change the include path (the projects have different nesting levels). Apart from using NuGet SolutionDir variable, best way to solve this seemed to be to use $(MSBuildStartupDirectory). However, as it turns out, on some machines, using the same version of VS 2008 (as same updates installed, as far as I was able to check) this resolves to the solution directory, and on others to c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE.
How can I either
- get this to always resolve to the solution folder
- or obtain the base folder in another consistent way?
SolutionDiris not exclusive to NuGet, NuGet simply adds the definition in case the project file is being built directly. If the build was started from a solution file thenSolutionDirwill be defined by MSBuild.