views:

1696

answers:

5
devenv mysolution.sln /build "Release|Win32" /project myproject

When building from the command line, it seems I have the option of doing a /build or /rebuild, but no way of saying I want to do "project only" (i.e. not build or rebuild the specified project's dependencies as well). Does anyone know of a way?

+2  A: 

Don't call devenv, use the genericized build tool instead:

vcbuild subproject.vcproj "release|win32"
Ben Straub
Does vcbuild have any advantages or drawbacks compared to msbuild?
Owen
For C/C++ projects, msbuild actually runs vcbuild as a child process. So yes. And no. :)
Ben Straub
+8  A: 

MSBuild is what you want

MSBuild.exe MyProject.proj /t:build
Xian
+1  A: 

Depending on the structure of your build system, this may be what you're looking for:

msbuild /p:BuildProjectReferences=false project.proj
nullptr
Is the BuildProjectReferences=false going to make a difference when we're only in the context of a project (not solution) file?
Owen
A: 

Thanks for the answers. I see from a bit of looking into msbuild that it can deal with a .sln file rather than a .vcproj; can this be accomplished that way instead of having to know the location of the .vcproj?

Let me take a step back. We have a big solution file and I want a script to do this:

  1. Do a /build on the whole solution.
    (Sometimes some projects fail because devenv doesn't do quite as much building as necessary for the amount of change since the last build.)
  2. For each project that fails, do a /rebuild on it.

When I get to step 2 all I know is the solution filename and the names (not filenames) of the projects that failed. I could easily grep/awk/whatever the .sln file to map from one to the other, but I'm curious if msbuild offers a way to do it directly.

(Ideally I could give msbuild the .sln and the names of all the projects to rebuild in a single command line, as it's a large file and takes a while to load. If that's not possible then the option of manually finding all the project filenames is probably better as loading the solution file every time would be most inefficient.)

Owen
A: 

According to MSDN How To: Build Specific Targets in Solutions with MSBuild.exe:

msbuild foo.sln /t:proj1:Rebuild;folder_of_proj2\proj2:Clean
Ilia K.