From the command line, when would I call MSBuild directly on a project, and when would I call MSBuild on the projec's sln
file, passing /t:Build /t:ProjectName
?
Example: I have a simple solution containing several projects (A, B, C, ...). Development is done through the VS GUI, by opening and working with the solution.
Now, in a specific automated case, I want to build just project B from the command line:
What should I call?:
(a) MSBuild "my.sln" "/t:Build" "/t:ProjB" "/p:Configuration=Release" "/p:Platform=Any CPU"
(b) MSBuild "ProjB.vcxproj" "/t:Build" "/p:Configuration=Release" "/p:Platform=Any CPU"
sln
file that gets missed this way? (I certainly don't see any additional info in our VS2015 sln
file.)I can, so far, identify these issues:
sln
based dependencies, these will simply be ignored.
$(SolutionFileName)
and quite everything else that starts with solution. If your project, or its dependencies, use any of these: subtly different result may ensue.Platform. Oh my. You see, they way solution platforms work, they're basically just a named container to group together project platform selections.
What this means is, esp. for C++, that when invoking the sln
file it might very well be that you need to specify a different platform. For example, with the solution, you'd build 'Mixed Platforms' or maybe 'Any CPU', but for the project you actually need to specify x64
or Win32
.
So the Platform that needs to be passed might have to differ.