Platform toolset (v110) is not installed or invalid - visual-studio

I have a weird problem when I want to compile a Visual Studio 2012 solution via msbuild on the command line. Whatever I do, it exits with Specified platform toolset (v110) is not installed or invalid. I have tried launching it via the regular command prompt, the Windows 7 SDK prompt, and all three command prompts included in VS2012. However, compiling in Visual Studio itself works.
where msbuild outputs:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
c:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe

You have probably solved the problem yourself but perhaps it may help others with a similar problem. Try to set the VisualStudioVersion environment variable before running MSBuild, e.g
SET VisualStudioVersion=11.0
There is a possibility that it helps.

You could also try passing the command line parameter /p:VisualStudioVersion=11.0 to MSBuild, when trying to build your project. It seems to have the same effect as setting the environment variable, in the above answer.

Related

How to execute VS2013 MSBuild from an EXISTING command prompt

I would like to "MSBuild" (VS2013) my application as part of a bigger ".cmd" script. I cannot let visual studio build a shell and issue commands into that shell (please don't ask why; if that were negotiable I wouldn't have to ask this question in the first place)
I have the shell, its path, and its environment variables prepared for everything else (except Visual Studio 2013 and MSBuild). What can I do or invoke, so that the next command then can be "MSBuild..."
I have spent hours searching in vain but all I have found looks to me like it requires building a new shell, applying a mouse click, or loosing the standard input.
Thanks
Run vsvars32.bat. It is in the Common7\Tools folder of your Visual Studio installation. In the case of VS 2013, this folder is available in the environment variable, VS120COMNTOOLS. It is similar for other versions of VS. Your script will be something like:
call "%VS120COMNTOOLS%vsvars32.bat"
msbuild mysolution.sln /t:Build

Visual Studio 2012 Command Prompt expected environment pathway not included

Recently installed (and re-installed) VS 2012 Ultimate with Blend
The VS Command Prompt doesn't seem to have a reference (are they called environment pathways) to the folder "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\". This means the following lines won't run from the command prompt (either as normal or as administrator)
msbuild buildapp.csproj /t:HelloWorld
Installutil WindowsService1.exe
To use msbuild or Installutil I need to specify the full pathways for the above to run.
Is the above a by design change that MS have made to VS?
In my VS 2012 environment I can find the path you say is missing. I opened the "Developer Command Prompt for VS2012" and did PATH to verify and also ran InstallUtil.exe successfully.
Make sure you open the correct prompt, mine was started using %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"
Here's Microsoft's explanation (err..justification :)) of the convoluted path structure :
For 32 bit builds :
Setting the Path and Environment Variables for Command-Line Builds
.. and 64 bit builds :
How to: Enable a 64-Bit Visual C++ Toolset on the Command Line

Issue generating resources in VS.Net 2010, windows 7 64 bit

I am having an issue generating resources in VS.Net 2010, windows 7 64bit. It am able to compile the solution in Visual studio. But when I try to compile the solution in command prompt using msbuild, it fails generating the resources.
I went through the below link and find a solution to get it compiled in command prompt using msbuild.
http://blogs.msdn.com/b/visualstudio/archive/2010/06/19/resgen-exe-error-an-attempt-was-made-to-load-a-program-with-an-incorrect-format.aspx
I used option 2 from the above article.
Before compiling in command prompt I have to execute the below two commands.
CorFlags /32BIT+ /Force Resgen.exe
set RESGENTOOLARCHITECTURE=Managed32Bit
And after finishing the compilation I have to execute the below remove 32 bit command. Other wise it fails in visual studio.
CorFlags /32BIT- /Force Resgen.exe
One weird thing is non of my team members are having any issue with this. I only have the problem.
Could you please let me know why it's only me?
Also any other permanent solution if you have, with out running the above commands again and again.
Thanks in Advance
Sometimes it has issues with the privileges.
Just make sure that you have tried running your command prompt with full privileges.
i.e. Run as administrator

Env vars for Visual Studio command prompt

I'm doing an RDP into a machine that has just the CLR installed, and doesn't have Visual Studio on it. Can I somehow load all the Visual Studio-specific environment variables on to the regular command prompt and convert it into the VS command prompt so that I'm able to build my projects via command line?
I looked at the vcvarsall.bat file. That calls the appropriate processor-specific batch file. Couldn't get any inputs from there.
Short of installing all VS, or tracing thru all the various batch files to find out what's getting set, you may be able to simply capture the env vars that are set.
Open up a VS command prompt, and run set > vars.bat
Then open up vars.bat, and put a set command in front of each line.
Not sure how much this will help, since you're going to be missing all the utilities that come with Visual Studio, but it does answer your question.
I don't recommend trying to copy only what you need. You'll need other header files, libraries, dlls, etc... You can instead install VS express edition.
If you are trying to debug a problem you can use remote debugging in Visual Studio or use WinDbg on the computer.

How to launch correct version of Msbuild

When I type...
Msbuild<Enter>
...at the command prompt, I get...
Microsoft (R) Build Engine Version 2.0.50727.4927
[Microsoft .NET Framework, Version 2.0.50727.4927]
Copyright (C) Microsoft Corporation 2005. All rights reserved.
This is all very well and good except that when I run this against a Visual Studio 2010 .sln file, the error message indicates:
MyProject.sln(2): Solution file error MSB5014: File format version is not recognized. MSBuild can only read solution files between versions 7.0 and 9.0, inclusive.
0 Warning(s)
1 Error(s)
It would appear that the version of MSBuild that is being called, is not capable of understanding my solution file.
I figured that I would check out my path and see where MSBuild is being picked up from. However, it seems that no part of my path points at a location where MSBuild is to be found.
How is the command line finding the copy of MSBuild that it is using and how can I change this version so that the latest version is used?
I found this question as my PATH variable did not contain a reference to MSBuild.exe. In case anyone else is having this issue, my resolution was to explictly register the environment variables for Visual Studio tools from the command prompt:
"%VS100COMNTOOLS%"\\vsvars32.bat // VS2010 environment variables
"%VS110COMNTOOLS%"\\vsvars32.bat // VS2012 environment variables
"%VS120COMNTOOLS%"\\vsvars32.bat // VS2013 environment variables
MSBuild.exe is now registered in PATH
where msbuild
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
It must be somewhere in the PATH environment. Use 'where msbuild' to determine where it is loading msbuild from.
Use the Visual Studio Command Prompt (2010) shortcut to initialize the path and other environment variables for VS 2010 and MSBuild 4.0.
Change your environment variables.
Find/set your MSBuild path variable to be C:\Windows\Microsoft.NET\Framework\v4.0.30319
Obiviously the above path will depend on your installation location, but it will be close if not exact.
For building a C# 6 project, this worked for me in a batch file
if exist "%ProgramFiles(x86)%\MSBuild\14.0\bin" set MSBUILDLOCATION=%ProgramFiles(x86)%\MSBuild\14.0\bin
if exist "%ProgramFiles%\MSBuild\14.0\bin" set MSBUILDLOCATION=%ProgramFiles%\MSBuild\14.0\bin
"%MSBUILDLOCATION%\msbuild.exe" "path\to\my\project.csproj"
You can easily change the version number (14.0) or add lines with more version numbers (12.0 and 4.0 for example) if you wanted to support a range of versions.

Resources