views:

116

answers:

4

Given a Solution where:

  • Project P1 has a reference to P2
  • P2 has a reference to P3
  • P3 has reference to P4

When you call msbuild this way:

msbuild.exe /v:m "c:\mysolution\p1\p1.csproj"

msbuild checks all project dependencies is builds dependencies if necessary. The typical output is:

Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

  P4 -> c:\mysolution\P4\bin\Debug\P4.dll
  p3 -> c:\mysolution\p3\bin\Debug\p3.dll
  p2 -> c:\mysolution\p2\bin\Debug\p2.dll
  p1 -> c:\mysolution\p1\bin\Debug\p1.dll

In my case, I know the dependencies exist and are all right.

Is there a way to build only project p1.csproj without verifying dependencies? The solution can be with msbuild or with something else.

+3  A: 

What's the goal (why do you care)?

You could use assembly references rather than project references (but beware debug v release path differences).

Brian
I care because in a solution with 100 projects, this step takes very long; 10 times more time than compiling the project I'm interested in. Changing the structure of the solution or using assembly references are not good options for me.
Sly
That's not what I see here on my machine. If a run msbuild on my project, it take about 30 sec do figure out that there is nothing to do. If I do it again immediately, it takes another 30 seconds. It's process of checking the dependencies that takes time. That's why I want to skip that part.
Sly
Brian
I'll check that. By the way, my PC is an Intel i7 with 6GB and a fast hard drive so I don't think it's the hardware.
Sly
+1  A: 

Perhaps you could use the Configuration Manager in Visual Studio, and uncheck all the projects but the one you want to build.

grefly
I need a solution that works without changing the solution or the projets. I need this to work from the command line.
Sly
@Sly: Add separate configurations to your solution. You are able to select which configuration to build from the command line. This is similar to the targets in classical *make*. E.g. have a configuration *Release All*, *Debug All*, *Release Subbranch*, *Debug Subbranch*, ...
0xA3
+1  A: 

Check out Microsoft's best practices for structuring solutions and projects:

Microsoft Patterns & Practices: Structuring Solutions and Projects

What you currently have is a is a single solution. This is the ideal case which should be used whenever possible. However, a single solution might turn out to be impractical for very large solutions like yours.

You might want to consider to partition the solution, i.e. use separate solutions for partitions of the dependency tree. Or you might even consider to use a so-called multi-solution. Check out the linked article to see about the consequences and drawbacks of such a change. Maybe using faster hardware might be the preferable option.

0xA3
As I wrote in my comment to grefly, I need a solution that works without changing the solution or the projets.
Sly
By the way, we used to have multiple solutions (for several years) but when you do that, you have to say good by to all refactoring tools and "find references" and "go to definition" and that's worst then long build times.
Sly
@Sly: 1.) A partitioned solution works without modifying the existing solution and projects, it just adds solutions for the sub-branches of the partition tree. 2.) Sorry, but you can't have both. For refactoring and *find references* to work all source code must be loaded, i.e. you must use project references. This is one of the reason to use a single solution whenever possible (The main reason is to have your dependencies always up-to-date and in the currect version and ready to debug).
0xA3
I know and that's why I'm not looking for a solution that requires a redesign of my solution and projets. All I want is a "trick" to bypass this unnecessary step in some very specific scenarios.
Sly
@Sly: The only "trick" to tell the compiler not to check a project for modifications would be the one mentioned by @grefly, i.e. to exclude a project from build in Configuration Manager or to use a separate configuration. Probably the latter would be the best to do for you as it allows to switch you with a single-click between the configurations.
0xA3
A: 

You should check out a product called OpenMake. My lead build engineer tells me they have done alot with dependency examination and build parallelization.

OpenMake

Christopher Painter