Overriding ToolsVersion Settings
By using the /ToolsVersion switch (or /tv, for short) or the $(ProjectToolsVersion) property, you can override the ToolsVersion setting in the project file, which lets you, for example, build a project in a solution with a Toolset version different from that of the other projects. You can also override the ToolsVersion of the MSBuild task using the ToolsVersion task parameter.
For more information about ToolsVersion, see Using MSBuild to Target Specific .NET Framework Versions.
Override the ToolsVersion Settings of Projects on Command Line Builds
Although Visual Studio 2008 projects typically build with the ToolsVersion specified in the project file, you can use the /ToolsVersion (or, /tv) switch on the command line to override that value and build all of the projects and their project-to-project dependencies with a different Toolset. For example:
C:\windows\microsoft.net\framework\v3.5>msbuild.exe someproj.proj /tv:3.5 /p:Configuration=Debug
In this example, all projects are built using ToolsVersion 3.5. (However, see the section "Order of Precedence" later in this topic.)
When using the /tv switch on the command line, you can optionally use the $(ProjectToolsVersion) property in individual projects to build them with a different ToolsVersion value than the other projects in the solution.
Override the ToolsVersion Settings Using the ToolsVersion Parameter of the MSBuild Task
The MSBuild task is the primary means for one project to build another. To enable the MSBuild task to build a project with a different ToolsVersion than the one specified in the project, it provides an optional task parameter named ToolsVersion. Below is an example of its use:
<MSBuild Projects="MyProject1" Targets="Build" Properties="Configuration=Debug" ToolsVersion="2.0"> <Output TaskParameter="TargetOutputs" ItemName="Outputs" /> </MSBuild>
Order of Precedence
The order of precedence, from highest to lowest, used to determine the ToolsVersion used by a project to build is:
The ToolsVersion attribute on the MSBuild task used to build the project, if any.
The /tv switch used on msbuild.exe if any. (Similar to the outer msbuild task.)
The project file ToolsVersion attribute.
The default tools version in the config file.
The default tools version in the registry.
Numbers 1, 2, and 3 are the same as properties:
Properties attribute on the MSBuild task
/p: switch on msbuild.exe
Property tag in the project file
If you do not specify a value for /ToolsVersion when you build on the command line, Visual Studio 2005 solutions will build using a ToolsVersion value of "2.0" and Visual Studio 2008 solutions will build using a ToolsVersion value of "3.5."