views:

313

answers:

2

We have a Library Project that we use for all our central reused code called "CentralLibs.dll"

This library gets GAC'd on all our servers during deployment so to make things handier for the DEVs when they're working locally, theres a post-build event that auto updates their local GAC with the new DLL post build.

cd $(ProjectDir)\bin\Debug
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /if CentralLibs.dll

We've recently setup Cruise Control, which is puking on the post-build event because the SDK isn't installed on the build server, but thinking about it, I don't really want the Library GAC'd everytime a build occurs there anyway.

Is there any way to apply an additional switch to our CC.NET MSBuild Command to tell it not to run the post-build event. currently it looks like.

<msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
    <workingDirectory>C:\BuildRepo\trunk\CentralLibs\</workingDirectory>
    <projectFile>CentralLibs.sln</projectFile>
    <buildArgs>/noconsolelogger /p:Configuration=Debug /v:quiet</buildArgs>
    <targets>Build</targets>
    <timeout>600</timeout>
</msbuild>

I guess I'm looking for something like a /nopostbuild switch that I can apply to the <buildArgs> tag

Does such a param exist. Not having a whole lot of luck with the MSBuild.exe /? details

A: 

One way would be to define an environment variable NO_GACUTIL, and only run gacutil.exe in the step when the environment variable is not set.

Alternatively, only run gacutil.exe if it exists (using cmd.exe's if exist)

Martin v. Löwis
+1  A: 

I would probably create a custom msbuild script just for cruise control but thats probably more work than you wanted.

Instead what you can do is add a condition to the Build event property group step in the project file like so:

  <PropertyGroup Condition="$(DoEvents)!='false'">
      <PostBuildEvent>cd $(ProjectDir)\bin\Debug"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /if CentralLibs.dll</PostBuildEvent>
  </PropertyGroup>

Then in cruise control add the DoEvents property like:

<msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
    <workingDirectory>C:\BuildRepo\trunk\CentralLibs\</workingDirectory>      
    <projectFile>CentralLibs.sln</projectFile>  
    <buildArgs>/noconsolelogger /p:Configuration=Debug /p:DoEvents=false /v:quiet</buildArgs>    
    <targets>Build</targets>
    <timeout>600</timeout>
</msbuild>
John Hunter
Excellent John. Very much appreciated. That did the trick nicely.
Eoin Campbell