Creating Build logs into the Specific project folder, while compiling a .sln file using MSbuild from Cmd console

StackOverflow https://stackoverflow.com/questions/22153572

  •  19-10-2022
  •  | 
  •  

Question

i have a solution file which contains .vcxproj files.

for all the .vcxproj project files the Build log file property is set to $(IntDir)$(MSBuildProjectName).log

when i load the solution to VS2013 and from the solution explorer i invoke Rebuild Solution, then the log files are getting generated within the respective folder.it works fine.

My problem is that i have many such .sln files. for which i want to create a batch file with MsBuild command for all the .sln files and run.

The msbuild command i use for each .sln file is C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /m /t:Rebuild /p:"Configuration=Release" /p:"Platform=x86" "xyz.sln"

But when i run the same from the command console the build log files are not gettin generated at all.

Am i missing some specific swith/option in this MS build command

No correct solution

OTHER TIPS

That build log property works together with Options->Projects and Solutions->VC++ Project Settings->Build logging and it only has effect when building inside Visual Studio. Internally visual studio does something like

msbuild /t:Rebuild [Properties] [FileLogger parameters] xyz.vcxproj

for each (C++) project in the solution. For all possibilities for the FileLogger parameters, enter msbuild /? on a command line - when VS invokes msbuild they would be equivalent to

/flp:Verbosity=[verbosity set in 'Build and run' in VS];LogFile=[value of BuildLog property]

Replicating this behaviour exactly when building the solution from the command line using msbuild is not easy, also see this unanswered question which is basically a duplicate: you'd have to parse the solution and get all projects out of it, then parse those to get the value of the BuildLog property, then invoke msbuild for each.

What you can do instead: use VS to build from the command line:

devenv xyz.sln /build

or use msbuild and gather all output in a single logfile

msbuild xyz.sln /fl:LogFile=xyz.log
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top