Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build VS2010 solution file from msbuild command line

I want to build my VS2010 .sln file (projects are .net 4.0) with msbuild from the command line. I expected this to work...

>C:/Windows/Microsoft.NET/Framework/v4.0.30319/msbuild.exe application.sln

However I get this message:

"Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5"."

The build continues but it can't find any of my references and fails.

I'm probably missing something obvious... any help would be appreciated.

Thanks,
-dk

like image 637
dk. Avatar asked Jun 18 '10 20:06

dk.


People also ask

How do I create a solution using MSBuild command line?

At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute. Specify the target after the -target: switch in the format <ProjectName>:<TargetName>.

How do I compile a SLN file?

Go to your folder with your solution sln file, and just type msbuild. It will automatically start building the sln files. If you use nuget packages, you will get errors about missing packages. You may have read somewhere that you only need to type “msbuild /t:restore”, but I think that it's only works for .

Can MSBuild build C++?

Microsoft Build Engine, or MSBuild, is a set of free and open-source build tools for managed code under the Common Language Infrastructure as well as native C and C++ code.


2 Answers

This article maybe helpful: http://blog.prabir.me/post/Downgrading-VS2010-solutions-to-VS2008.aspx

And it seems it's not targeting proper msbuild version (error comes from 3.5 msbuild ver), try to open the Visual Studio 2010 command prompt, go to the solution directory and run msbuild.exe SolutionName.sln

like image 197
Leszek Wachowicz Avatar answered Oct 24 '22 20:10

Leszek Wachowicz


That's odd. Does VS2010 work OK? If not is the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0 missing? (Install bad.)

Verify the .sln version number at the top is 11.

Those are the only reasons I can think of.

Dan

like image 21
dan Avatar answered Oct 24 '22 22:10

dan