简体   繁体   中英

Using Microsoft C++ compiler without installing Visual Studio

In our team, the devs all have Visual Studio 2012, and we also use TFS2012 build. For space & manageability reasons, we don't install Visual Studio on our (many) build agents. This has worked so far with C# projects (csproj).

Now we want to add support for C++ project (vcxproj). These build on devs' machines, but not on the build agents - we get: X.vcxproj(31,3): error MSB4019: The imported project "C:\\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. X.vcxproj(31,3): error MSB4019: The imported project "C:\\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I suppose this is because the C++ compiler & targets are only installed with VS.

  1. Is there a way to checkin just the compiler & targets, and set some property in our common.targets to point there?
  2. Failing that, what is the minimum I need to install on each build agent to support C++ compilation? The least I could find was VS Express, which is still too much to my liking.

It is simple for C#, the ability to compile C# programs is innate in the framework, System.CodeDom, so just installing .NET is enough. Not so for C++. You'll at a minimum need to install the Windows SDK, half a gig. This includes the C++ compiler in SDK versions earlier than 8.0

However, you'll next get to fret about finding a way to get the class libraries on that machine. ATL and MFC for example. You can't just copy them, that violates the license. Much worse, Microsoft is not doing business the way they used to. They switched to a rapid-release cycle since VS2012 with updates shipping in a manner of months. These are not updates you can ignore, they add pretty major chunks to get C++11 implemented. Definitely the kind that your C++ programmers will want to use.

In general, the SDK version of the C++ compiler is just not in sync with VS version, the Windows team has no obligation to keep it updated. The one thing that a build machine should never do is run a different set of build tools than the ones used by the programmers. That makes a build break that can't be reproduced by a dev a big nasty point of contention. Unless you like making your life complicated, the message is clear. Don't do it, install VS.

This problem was also present for earlier TFS versions. As far as I know the only solution is copying the targets to the agents. It should be enough creating a copy of this folder:

MSBuild\\Microsoft\\VisualStudio\\v11.0\\*.*

At least you do not have to install Visual Studio on the agents (except you want to automate setup project creation).

The error got also described here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM