1

I have a solution that needs to build with TFS. C# projects and some of C++ projects are upgraded to .Net Framework 4.6 and Platform Toolset v140. but some of the third party C++ projects can't upgrade (They are in V110). MSBuild is not able to use the appropriate toolset version for projects. It returns this error:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets (44): The builds tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.

Is there any way to get this to work? It is possible for MSBuild to build a solution which has projects with different Platform Toolsets?

Thank you, Arash

Arash
  • 271
  • 1
  • 4
  • 5
  • Did you need to manage your source code of the third party C++ projects? – PatrickLu-MSFT Nov 10 '15 at 02:16
  • I don't exactly know what you mean by manage. But what I can tell you is that in order to keep using them, I need to keep them in their current platform toolset (V110). However the rest of the projects (C++ and C#) are all upgraded. – Arash Nov 10 '15 at 15:28
  • I have a similar problem here: a solution with only C++ projects, one of them set to `ToolsVersion="14.0"` and using `PlatformToolset>v140`, everything else using v120. When loading this into VS2013 (i.e. 12.0) it just ignores the v140 and builds like usual using v120. Same on the commandline using msbuild. Building everything in Visual Studio Online (which afaik is the new TFS?) though I get the exact same error as posted.. Why? – stijn Nov 10 '15 at 20:41
  • Solution: if I change the `Visual Studio Version` in the build definition in VS Online to Visual Studio 2015 everything builds, using msbuild 14, but it seems it figures out that the solution is made using VS2013 and as such it uses the v120 toolset for all projects, even the one which is set to v140. Not sure if this is of any help for you, but for me it basically means 'use the latest Visual Studio version in TFS and the rest worka automatically' – stijn Nov 10 '15 at 20:59
  • Unfortunately there is no much option in TFS! – Arash Nov 12 '15 at 20:27
  • @Arash, is VS2015 installed on the TFS build agent machine? You need to install it to have your project built successfully. Additionally, what stijn mentioned above is available in vNext build system, would you mind to use vNext build system instead of XAML build? – Vicky - MSFT Nov 16 '15 at 02:23
  • Refer my answer for https://stackoverflow.com/questions/33154696/msbuild-error-the-builds-tools-for-v140-platform-toolset-v140-cannot-be-f – Jacob Nelson Mar 01 '19 at 06:56

2 Answers2

0

The problem solved by my Colleague Phil. Basically All you have to do is to change the MSBuild ToolPath property to point to right MSBuild version. As each version of MSBuild supports earlier versions, the highest used version of MSBuild should you point to.

So open the Build Process Template in Visual Studio and navigate to Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild. To get to there you should go to the following path:

Try Compile, Test and Associate ... -> Sequence -> Compile, Test, and Associate ... -> Try Compile and Test -> Compile and Test -> For Each Configuration in ... -> Compile and Test For ... -> If BuildSettings.HasProjectsToBuild -> For Each Project in BuildSettings... -> Compile Project and Copy -> Try to Compile the Project -> Compile the Project

Now right-click on "Run MSBuils for Projects" and select properties. Here you have a property "ToolPath" that you can specify the MSBuild address (in my case it is "C:\Program Files (x86)\MSBuild\14.0\Bin").

This should resolve the Problem.

Cheers,

Arash

Arash
  • 271
  • 1
  • 4
  • 5
-1

You don’t need to specify your Platform Toolset in MSBuild Arguments for your projects.

I have try on my local enviroment.A solution including three projects C#(Platform Toolset v140), C++(Platform Toolset v140), C++(Platform Toolset v120).Without specify Platform Toolset in MSBuild Arguments. Build sucessful.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • It build all right in Visual Studio but not with TFS. I didn't specify the toolset version in _Build Arguments_, it is only specified in each project's properties! – Arash Nov 10 '15 at 15:30