Use MSBuild 3.5 with Visual Studio 2010

后端 未结 3 417
误落风尘
误落风尘 2021-01-12 00:32

How can I force Visual Studio 2010 to use MSBuild 3.5 instead of the new 4.0 ?

3条回答
  •  孤街浪徒
    2021-01-12 00:50

    I think you can't change the version of MSBuild used within Visual Studio without a dirty hack.

    ToolsVersion

    The version of MSBuild tasks, targets, and tools used by MSBuild is determined by the ToolsVersion attribute in the project file.

    • Visual Studio 2008 uses ToolsVersion="3.5"
    • Visual Studio 2010 uses ToolsVersion="4.0"

    Problem : If you change the ToolsVersion manually to 3.5 on the project file, Visual Studio 2010 will automatically upgrade the project file's ToolsVersion to 4.0

    The hack

    The solution is to set your project ToolsVersion to 3.6 (or whatever or 4.0 if you really want to override MSBuild 4.0) and then in the registry to create the following key :

    • Registry Hive: \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.6
    • String Key Name: MSBuildToolsPath
    • String Key Value: .NET Framework 3.5 Install Path (C:\Windows\Microsoft.NET\Framework\v3.5)

    On machine where ToolsVersion is unknown, the default ToolsVersion will be used.

    More information on custom toolset definition.

提交回复
热议问题