views:

1256

answers:

6

I have moderate size solution in Visual Studio which takes around 5 minutes to build (It take that long because of FxCop and other post build steps). My problem is, Visual Studio stops responding while it's building. You can't continue working as VS almost hangs. I tried using two VS instances, just using one for build, but it keeps crashing every now and then.

My question is, How to not waste time looking at Visual Studio building your large/moderate project. Are there any best practices for this?

+7  A: 

Source.

tvanfosson
ref: http://www.xkcd.com
tvanfosson
+5  A: 

Two excellent MSBuild tips I just learned yesterday...

You can run tasks in parallel by using the /m:n switch where n is the number of processors to use. All you have to do is set BuildInParallel on your MSBuild task.

The other trick is that if you have several <exec /> tasks to run you can actually run them in parallel too by calling <exec command="sleep 10|sleep 10|sleep 20" /> by using the pipe character between each command. A more practical example:

<CreateItem Include="server1;server2;server3;server2">
  <Output ItemName="IISServer" TaskParameter="Include"/>
</CreateItem>
<CreateProperty Value="@(IISServer->'iisreset.exe /start %(Identity)', '|')">
  <Output TaskParameter="Value" PropertyName="IISServerStartAll" />
</CreateProperty>
<exec command="$(IISServerStartAll)" />
DavGarcia
That's interesting, sound like more speed for free. But I know *absolutely* nothing about build. If I am doing start and debug "builds" in VS where do I find this file or alter the setting in the UI?
Christopher Edwards
This would be in MSBuild scripts that you write yourself. I'd definitely recommend taking FxCop out of every build, that is unnecessary. You can set up separate build processes in VS. I'd suggest one for just compiling what you are working on and one that runs all your code checking and tests.
DavGarcia
+1 The You could use the [potentially in-target] PropertyGroup/ItemGroup syntax to make the example even clearer... Also Tools|Options Projects and Solutions|Build and Run|maximum number of parallel project builds controls it externally
Ruben Bartelink
Also buy the Hashimi MSBuild book
Ruben Bartelink
+5  A: 
  1. You certainly don't need to run a static code analysis each time you build your solution.
  2. Reduce the number of your project by merging some could also helps a lot.

What other post build tasks have you put in place ?

Romain Verdier
+1 A agree with that, you should consider running a build server with CruiseControl.NET which will run your static code analysis, unit tests, code coverage (Ncover), coding standards (StyleCop), class structure analysis (NDepends), etc... You can set up a build to do so just before you check in too.
DavGarcia
TeamCity is really easy to set up...
Ruben Bartelink
A: 

You might consider a dedicated build machine using MSBuild. From there, you'd be able to continue working while compiling. It does make it more complicated, though, as you're introducing networking issues.

Charlie Salts
A: 

You can create classes in another project by stubbing the classes that you would need to make the code compiles. This way, you can test and document your new code. After this, you just include it to the real project and you compile "for real". By the time it compiles, you are already working on another snippet of the project because you are 95% it will successfully compiles. Or, by the time it compiles, you can also write your unit tests..

+1  A: 

Use Incredibuild if you have more than one computer or setup this program to another friends at work. it is easy to setup and use. speed up is linear for compiling.

it is also good for multicore cpu's bacause normally vs uses one core for one project but incredibuild make it parallel for each .cpp file...

try and see.. :)

ufukgun