I was about to build a Visual Studio solution file using msbuild. I used the following commandline for building the solution
msbuild.exe SolutionFile.sln /t:Build/p:Configuration=Release;Platform=Win32
Even though the build starts at some point the build is looking hang and fails to move forward as shown below
Done Building Project "D:\SolutionPath\ProjectFile10.vcxproj" (default targets).
There are a lot of .proj
under SolutionFile.sln
those I have to build.
I have to use msbuild.exe
rather than devenv.com
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 .
The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software.
There's a technique for diagnosing what's happening inside msbuild which may help you work out what's happening here. From a command prompt set an environment variable:
set msbuildemitsolution=1
Once you have run msbuild then this will generate a .metaproj
file. This file is what msbuild uses internally but then deletes. You can read it to find out the name of the actual targets are. The Build
target is expanded to show what it actually calls. You can then try building the individual targets with the /t
flag of msbuild to work out which target is causing the problem.
Set the verbosity property to diagnostic and save the output to a file. This will help you determine which project in your solution is hanging and help diagnose your problem.
The command line syntax would be as follows to save the output to a file named MyProjectOutput.log :
msbuild SolutionFile.sln /t:build /fl /flp:logfile=MyProjectOutput.log;verbosity=diagnostic
It also appears that you need a space after the /t target to build parameter passed in the command you listed.
msbuild.exe SolutionFile.sln /t:Build /p:Configuration=Release;Platform=Win32
Also, are you sure that every project contains a "Release" and "Win32" configuration? You could try just running the below command as well and see what gets compiled. Msbuild will automatically run the default target and configurations needed.
msbuild SolutionFile.sln
Another option you can try is to just compile the project and see what is produced:
msbuild "D:\SolutionPath\ProjectFile10.vcxproj" /fl /flp:logfile=MyProjectOutput.log;verbosity=diagnostic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With