Change build tools from VS2010 to VS2015 in command line - visual-studio-2010

I want to upgrade a solution in command line, so that I can build that solution / the projects within that solution with VS 2015. But somehow that does not work like expected.
What I am doing
1) Download the source code from https://ssl.icu-project.org/repos/icu/icu/tags/release-56-1/
2) Calling vcvarsall.bat for VS 2015.
3) Changing the ToolsVersion for every project
for /r "%cd%" %%a in ( *.vcxproj ) do (
sed.exe -i "s/ToolsVersion=\"4\.0\"/ToolsVersion=\"14\.0\"/g" "%%a"
)
4) Upgrade solution
rem upgrade solution
devenv "allinone\allinone.sln" /Upgrade
But nonetheless, I get warnings like this:
warning : The build tools for Visual Studio 2010 (v100) cannot be
found. To build using the Visual Studio 2015 (v140) build tools,
either click the Project menu or right-click the solution, and then
select "Upgrade Solution...". Install Visual Studio 2010 (v100) to
build using the Visual Studio 2010 (v100) build tools.
What I am missing? Is there a way how this can be done withing command line / batch ?

You must add this:
<PropertyGroup><PlatformToolset>v140</PlatformToolset><PropertyGroup>
Source: used vs2015 to upgrade the projects and checked the diffs
The ToolsVersion you changed refers to msbuild I think. The PlatformToolset is what changes the compiling toolchain.

In the Visual Studio 2015 environment, right click the solution in the Solution Explorer View, and choose "Retarget solution".

Related

Can find the registry of MSBuild 15.0

I have a old project, which is created by Visual Studio 2015, and I use a bat file to get the registry of MSBuild 14.0 in this project build event. Now I have to update my project to Visual Studio 2017, so I need to update the bat file to get the MSbuild 15.0, but I could not fins it.
In Visual Studio 2015:
The registry path is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0
The value is:
C:\Program Files (x86)\MSBuild\14.0\Bin
But for Visual Studio 2017, I could not find the registry path.
How I get the registry value again for Visual Studio 2017?
How I get the registry value again for Visual Studio 2017?
You should to read following thread:
vswhere:
Over the years Visual Studio could be discovered using registry keys,
but with recent changes to the deployment and extensibility models a
new method is needed to discover possibly more than once installed
instance. These changes facilitate a smaller, faster default install
complimented by on-demand install of other workloads and components.
vswhere is designed to be a redistributable, single-file executable
that can be used in build or deployment scripts to find where Visual
Studio - or other products in the Visual Studio family - is located.
For example, if you know the relative path to MSBuild, you can find
the root of the Visual Studio install and combine the paths to find
what you need.
vswhere is included with the installer as of Visual Studio 2017
version 15.2 and later, and can be found at the following location:
%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe.
And you use command like the following to find the latest version installed:
#echo off
for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild`) do (
if /i "%%i"=="installationPath" set InstallDir=%%j
)
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
"%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" %*
)
Hope this helps.

Upgrading a solution from Visual Studio 2010 to 2013 with command-line

I'm building many Visual Studio projects (.sln solutions files) from command-line with:
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
for /r %%X in (/*.sln) do (
msbuild %%X /p:configuration=release /p:platform=win32 /nologo /noconsolelogger /fileLogger /v:quiet /flp:logfile=build_errors.log;errorsonly;append
)
Unfortunately, they all have been created with MSVS2010. Thus I get errors:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".
As I have 20 or 30 .sln files, I don't want to open each one and Upgrade solution, etc. (which I even didn't find exactly as mentioned here!).
Is there a command-line solution to upgrade all of them to MSVS2013 ?
You can upgrade solution and all of its project files through devenv /upgrade command. (devenv.exe is in the VS installation path (..\Common7\IDE).
devenv SolutionFile | ProjectFile /upgrade
To build solution/project without upgrade, you can specify Toolset argument (/tv).
msbuild %%X /p:configuration=release /p:platform=win32 /tv:12.0
If this is the only problem you can retarget the projects to use the VS2013 toolset instead of the one in VS2010. You can write a simple script in a language of your choice (or even do it manually) that iterates over all of your project files and replaces the value of PlatformToolset property to the <PlatformToolset>Visual Studio 2013 (v120)</PlatformToolset>. Alternatively, you can download and install the VS2010 build tools from the SDK - https://www.microsoft.com/en-us/download/details.aspx?id=8279

Visual Studio 2015 - Clang version not found when building from command line

I have a Xamarin-based solution in Visual Studio 2015. One of the projects is an Android native shared library containing C++ code.
When I build the solution from within VS 2015 IDE, everything works as expected. However, when I try to build the solution from the command line I get an error.
The build command is:
msbuild mytest.sln /p:Configuration=Release /p:Platform=ARM /t:Rebuild
The error I get is:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for Clang_3_8 (Platform Toolset = 'Clang_3_8') cannot be found. To build using the Clang_3_8 build tools, please install Clang_3_8 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".
My Visual Studio 2015 has all the updates applied. Wondering if anyone knows what the problem could be. Is it a path problem? Regards.
Turned out it is a path problem. Make sure to use the developer command prompt link under Program Files-->Visual Studio 2015->Visual Studio Tools. This batch file sets up proper paths, including the one for clang.

Build with sdk 7.1 on VS2015

I have Visual Studio 2015 installed, and I need to compile a specific project with Visual C++ 2010 compiler, which is included in SDK 7.1.
I want to use 2010 compiler within VS2015, without install VS2010.
So, I installed it (the SDK), and "Visual Studio 2010 (v100)", "Windows7.1SDK" options appear under "Platform Toolset" property in the project properties.
But, when I try to build the project, I get those errors:
With "Windows7.1SDK" -
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5): error : Required file "" is missing.
and with "Visual Studio 2010 (v100)" -
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5): error : Required file "" is missing.
Can't figure out what the problem is..
I had the same issue for 2 weeks and just found a workaround that might help :
Without modifying anything to my VS2010 projects (not changing the toolset in the vcxproj), I use the command line build tools MSBuild tools with the toolset specified as a switch as found here Building C++ project on a PC with Windows SDK 7.1 but without VS2010
msbuild /p:PateformToolset=Windows7.1SDK project.vcxproj
(In my case, the corresponding msbuild is in the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319)
If Msbuild throws an error telling its missing mspdb100.dll, you may need to add %PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\Common7\IDE\ to your %PATH% env var.
Finally, you may have some files missing like ammintrin.h (especially if like me you try to compile old InDesign plugins) even after installing the visual c++ updates.
The only (and ugly) workaround I found in my case that does not involve installing VS2010 (the common answer of MS) is to copy the missing includes from the %PROGRAMFILES(X86)%\Microsoft Visual Studio 14.0\VC\include folder to the %PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\VC\include one.
Voila ! Hope this helps

Upgrade Visual Studio 2013 solutions to Visual Studio 2015

I have installed both Visual Studio 2013 and Visual Studio 2015. Projects and solutions that were created in VS2013 are opened by VS2013 as I would expect, but I would like to be able to upgrade those files so that they would be opened by VS2015 when double clicked.
How can I upgrade solution files that are in VS2013 format so that the Microsoft Visual Studio Version Selector will open them in VS2015?
The simplest solution IMO (also worked for 2012 and 2013) is:
Open the solution file using Visual Studio 2015
Select the solution file in Solution Explorer
Select File / Save MySolution.sln As...
Overwrite the existing solution file.
Change the version in the .sln file
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
To match whatever version you have
As of this morning my VS Enterprise is 14.0.23107.0
Example:
# Visual Studio 2015
VisualStudioVersion = 14.0.23107.0
Visual Studio 2015 Update 3 is 14.0.25420.1
Note: This works for VS 2015 and 2017
An alternative to hand-editing the .sln file or re-saving on top of the original .sln file:
Open the solution in Visual Studio
Right click solution > Add > New Solution Folder (name does not matter)
Save solution
Delete the newly added solution folder
Save solution
The solution will now be upgraded.
I ran across this looking for the same thing. The accepted answer works, but I noticed some comments about not being batchable. I found an option for batching and I thought I'd share.
You can use the /upgrade option in devenv.com. This means it's batchable. For example, to recurse the current directory upgrading all .sln files (after backing them up), you could do this:
dir -Recurse -path ".\" *.sln | ForEach-object {
Copy-Item $_.FullName "$($_.DirectoryName)\$($_.Name.Remove($_.Name.Length - $_.Extension.Length)).vs2013$($_.Extension)";
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" /upgrade $_.FullName
}
I solved the problem by this: Right click on solution, "Retarget solution".(vs2013)
The other solutions here didn't work for me. My project was created in Visual Studio 2012, and I am now using Visual Studio 2015, but this should work if you're going from 2013 to 2015. This is how you manually upgrade a project from a earlier version to a newer one:
Open the Developer Command Prompt for VS2015 (to find it: https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx)
Type in devenv SolutionFile | ProjectFile /upgrade and press enter
Where SolutionFile | ProjectFile is the full path with filename of your .sln file.
https://msdn.microsoft.com/en-us/library/w15a82ay.aspx

Resources