Compiling with Visual Studio 2012 tools through Visual Studio 2015 - visual-studio-2012

I have a lot of developers currently using Visual Studio 2012 and I would like to upgrade them to 2015 in two stages. First upgrade to Visual Studio 2015, then upgrade to the new MSBuild (compiler) toolset. This is important because I would like builds in Visual Studio to use the same toolset as builds in our build scripts, which are available on developer machines and used by the build servers. I would like to avoid picking a day and telling every developer to install Visual Studio 2015, and simultaneously pushing changesets to our repositories/branches to update the build scripts all at once.
From my understanding, the ToolsVersion attribute of the Project element in the project file drives the distinction between MSBuild versions. However, when building a project with ToolsVersion=4.0 in Visual Studio 2015, I receive the following messages:
Building with tools version "14.0".
Project file contains
ToolsVersion="4.0". This toolset may be unknown or missing, in which
case you may be able to resolve this by installing the appropriate
version of MSBuild, or the build may have been forced to a particular
ToolsVersion for policy reasons. Treating the project as if it had
ToolsVersion="14.0". For more information, please see
http://go.microsoft.com/fwlink/?LinkId=293424.
In addition to that, I can follow the build output and see that it is in fact using the Visual Studio 2015 toolset to compile the code. I know the "4.0" toolset is not missing (I have Visual Studio 2012 installed, along with the .NET Framework versions that include that version of MSBuild), so I'm assuming either Visual Studio 2015 can't find it, or there is a "policy reason" I don't understand.
According to the MSDN page for Standard and Custom Toolset Configurations, MSBuild 12.0 (Visual Studio 2013) includes the 4.0 toolset. However I can't find any information on MSBuild 14.0 (Visual Studio 2015).
Is it possible to build in Visual Studio 2015, but use the Visual Studio 2012 toolset? If so, how? And what are the "policy reasons" mentioned in the build warning?

Solution
Have your developers set the environment variable MSBUILDDEFAULTTOOLSVERSION to 4.0. One simple way to do this is to have them run open an elevated PowerShell prompt and run:
[Environment]::SetEnvironmentVariable("MSBUILDDEFAULTTOOLSVERSION", "4.0", "Machine")
Visual Studio will need to be reopened before it will pick up this change. Once you are ready to upgrade to the new MSBuild toolset, have your developers remove that environment variable:
[Environment]::SetEnvironmentVariable("MSBUILDDEFAULTTOOLSVERSION", "4.0", "Machine")
Background
From MSDN (emphasis mine):
Starting in Visual Studio 2013, the MSBuild Toolset version is the
same as the Visual Studio version number. MSBuild defaults to this
Toolset within Visual Studio and on the command line, regardless of
the toolset version specified in project file. This behavior can be
overridden by using the /ToolsVersion flag. For more information, see
Overriding ToolsVersion Settings.
Incidentally, to verify which MSBuild toolsets are available on a machine and where they are located, you can just open up PowerShell and run:
dir HKLM:\Software\Microsoft\MSBuild\ToolsVersions

Related

Pip error even Microsoft Visual C++ 14.0 is installed

I read all of the questions and answers which are related or asked before and I still didn't find an appropriate answer to my problem.
I am using python 3.6.5 and pip(and setuptools) is up to date.
I am installed Microsoft Visual C++ Redistributable for Visual Studio 2017 from here:
https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
when using pip install, I still get the error:
Microsoft Visual C++ is required
PS: I want to install airflow
This problem was solved on a computer having Visual Studio Community 2017 v15.5.2 and the Visual Studio Installer v1.16.1247.518 installed.
The steps used are as follows:
Start the Visual Studio Installer
Visual Studio Installer showed a Installed section that stated that Visual
Studio Community 2017. In that section was a drop-down titled More. The drop-
down option Modify was selected.
Visual Studio Installer then showed "tabs" titled Workloads, Individual
components, Language packs and Installed locations. The tab "Individual components" was selected.
Scrolling down the list of Individual components, there was a section titled
Compilers, build tools, and runtimes. Under that section there was a VC++
2015.3 v140 toolset for desktop (x86,x64) option that was unchecked. The
option was then checked.
The Modify button located at the lower right part of the Visual Studio
Installer was pushed.
After waiting an unreasonably long amount of time, the installer finished
modifying the installation of Visual Studio Community 2017.
As always, your mileage may differ.
As per instructions here: https://www.scivision.co/python-windows-visual-c++-14-required/
Use vs_buildtools.exe and install only the windows 10 SDK.
Visual C++ Redistributable installs run-time libraries and can be used to run applications written with VC. But you need Visual C++ compiler! So install Build Tools.
I suggest using MinGW as the C compiler.

Is it possible to add the Visual C++ v120 Compiler Tool Set to Visual Studio 2015?

I have a programm using an GSL library which worked quite well with Visual Studio 2013. Now I set up a new Windows version and installed Visual Studio 2015 RC Community.
After that I can not compile the code anymore. After converting the code to the new tool set I got the error that some external symbols of the libraries could not be found. I think this has something to do with the fact, that the library was build with Visual C++ v120.
So is there a possiblilty to add this Compiler Version to the Studio? And does it work without trouble next to a new version installed. I do not want to install the older version of VS, because of the possibility of some troubles haveing to version parallel installed.
You can install VS2013 toolset version from your VS2015 installer without installing visual studio 2013. From the 2015 installer, select Windows 8.1 and Windows Phone 8.0/8.1 Tools. Thats it.
Found it in a msdn forum (have to be the first time something is actually solved in a microsoft forum)
Install Visual Studio 2013
Open your Project in Visual Studio 2015
In the General page of the Project Properties, change the Platform Toolset to "Visual Studio 2013 (v120)"
You never have to open Visual Studio 2013; you just have to install it so that Visual Studio 2015 can find the toolset. (Unfortunately there is no way to install just the toolset.)

Why am I not able to open a VS project

I have a Visual Studio project that I created in my previous PC (32-bit if that makes any difference). I recently got a new PC (64-bit) and I am trying to open the project and I am seeing the following error:
Unsupported
This version of Visual Studio does not have the following project types installed or does not support them. You can still open these projects in the version of Visual Studio in which they were originally created.
- ONew, "C:\temp\onb\ONewSln\ONew\ONew.csproj"
No changes required
These projects can be opened in this version of Visual Studio without changing them. They will continue to open in Visual Studio 2010 SP1 and in this version of Visual Studio.
- ONewWeb, "C:\temp\onb\ONewSln\ONewWeb\ONewWeb.csproj"
- ONewSln, "C:\temp\onb\ONewSln\ONewSln.sln"
Screenshot:
Is there a add-on or visual studio component that I have to download to make it work?
Please help me resolve the issue.
After doing some research and spending hours banging my head against the wall, I figured out how to resolve the issue.
You have to install Microsoft Office Developer Tools for Visual Studio 2012.
Open up the Web Platform Installer and if you don’t have it installed, download and install it. Search for Office Developer Tools and install it.
This will enable you to open the project without any issue.
Usually you can open VS2010 SP1 files in VS2012. But after opening and on compiling you may get some errors of missing packages. Then you have to install the missing packages. Check this out: Visual Studio 2012 compatibilty.
Some solutions, projects, files, and other assets that you created in Visual Studio 2010 Service Pack 1 (SP1) will run without modification in Visual Studio 2012, but others have to be upgraded. The above document describes how various kinds of assets behave in these two versions of Visual Studio.
If you use both Visual Studio 2012 and Visual Studio 2010 SP1, you can create and modify projects and files in either version as long as you don't add features that require Visual Studio 2012.
VS2012 may convert projects when you first open them, but the changes are (except noted in the document linked) backward compatible with VS2010.

Visual Studio 2012 fails to open Visual Studio 2010 projects

I tried to open in Visual Studio 2012 a VS 2010 solution and I get these error:
Unable to read the project file "Language.vcxproj".
D:...\Language\Language.vcxproj(2,33): The tools version "4.0" is unrecognized. Available tools versions are "2.0".
It has something to do with the ToolsVersion attribute:
I believe this may be something with target platform settings, or with the version of the .NET framework, or with the version of the C++ compiler.
BTW, this also happens with .csproj files contained on other solutions I have.
What annoys me more is that I have a colleague that can open those solutions in his computer without any problem and I can not.
In the Control Panel, I have this items for the .NET framework:
Microsoft .NET Framework 4.5 Multi-Targeting Pack
Microsoft .NET Framework 4.5 SDK
Help, please!

How to use MSBuild to target v110 platform toolset?

I am developing a command line application that creates a full Visual Studio 11 solution made of a single VC++ project and that tries to compile it in the end using MSBuild.
The problem I am facing is strange.
If I execute my command line program inside Visual Studio 11 it works; if I instead launch it outside the development environment it throws me the error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(511,5): error MSB8008: Specified platform toolset (v110) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected. [f:\ABC.vcxproj]
The command I am using is the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe f:\snake\W9A30040.vcxproj /property:PlatformToolset=v110;Configuration=Debug /v:quiet
But I have the feeling that PlatformToolset=v110 is ignored and MSBuild use v100 (Visual Studio 2010).
Do you have any suggestions how to tell MSBuild to compile for v110 Platform Toolset?
I ran into the same problem as well with the full release of VS 2012. You can also set the VisualStudioVersion as a property with MSBuild as opposed to dealing with environment variables as mentioned in the accepted answer. For instance:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\myproject.vcxproj /p:VisualStudioVersion=11.0
The environment variables approach I'm sure work just as well, I honestly didn't try that as I was trying to stay away from having to modify the environment variables.
Make sure that the top of your .SLN file looks like this:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
When you double-click on the solution file, it's the # Visual Studio 2012 that controls which version of Visual Studio is loaded (and controls the icon displayed in Windows Explorer).
However, when you run MSBuild, it looks at the Format Version 12.00 part.
Confused?
This is confusing, since Visual Studio 2010 is version 10.0 and Visual Studio 2012 is version 11.0 (not 12.0), and using the version 12.0 solution file format causes MSBuild to (implicitly) set VisualStudioVersion to 11.0.
I found a workaround for this issue; could be a problem of Visual Studio 11 Beta that will be resolved before official release.
Anyway, if you are interestedm just set the environment variable "VisualStudioVersion" equal to "11.0" before calling MSBuild.exe.
In batch files
set VisualStudioVersion=11.0
or in VB.NET
Environment.SetEnvironmentVariable("VisualStudioVersion", "11.0")
Starting with Visual Studio 2013, MSBuild is now part of Visual Studio, and the correct path should be $(MSBuildToolsPath) (“C:\Program Files (x86)\MSBuild\12.0\Bin”). If you use msbuild.exe from the .Net framework folder (“C:\Windows\Microsoft.NET\Framework64\v4.0.30319”) it will not able to distinguish the vs2012 and vs2013 versions.
Use the menu based options to do this. From VC++2010 Express:
- Right click on the main file of the project (not the solution itself at the very top of the tree).
- Click General.
- Find Platform Toolset on the right side of the dialog, top half.
- Change from v110 to v100.
- Click OK.
----- Done ------
Microsoft provides a batch file to set all the EnvVars
You find it in the Start Menu under "Microsoft Visual Studio 2012/Visual Studio Tools" or in the Visual Studio folder ("C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat")

Resources