views:

85

answers:

2

This is similar to these 2 questions:

http://stackoverflow.com/questions/2604594/why-does-msbuild-fail-from-the-command-line-where-vs2008-succeeds

http://stackoverflow.com/questions/280559/how-to-get-cmd-line-build-command-for-vs-solution

When I build from Visual Studio 2008, the build succeeds. If I build from the command line using the MSBuild that comes with the .NET Framework 3.5 install, it normally fails. However if I use the Visual Studio 2008 Command Prompt that gets installed with VS2008 it succeeds. The answers (which I only partially understood) to the first two questions I linked to seem to be the reason why this fails from the command line. My question is specific to CruiseControl.NET. How can I apply their answers so that a CruiseControl.Net MSBuild task is always successful even after future changes as long as it builds correctly in VS 2008?

Thanks in advance for the help!

A: 

The first step is to get your project to build correctly using MSBuild from the command line. For me this was a matter of installing some missing dependencies on the CI server that I will now list.

1) I needed to download and install Power Toys for Compact Framework 3.5 to enable building a .NET Compact Framwork 3.5 project. Alternatively I could have installed Visual Studio 2008 Professional Edition.

2) I was missing SQL Server Compact 3.5. After downloading and installing this for Windows Mobile, the dependency still could not be found. I solved this by including a copy of the SqlServerCe.dll file in the repository of my project and changing all references to this file to use the one downloaded from the repository instead of expecting the system to know where to find this file. Alternatively installing Visual Studio 2008 Professional Edition may have solved this problem without the need for me to include a copy of the dll in my repository, but I don't know for sure.

Since I got my project to compile using MSBuild from the command line without having to do any special initialization or use any specialized command prompts, the MSBuild task in CruiseControl.Net works without doing anything special. Hopefully using MSBuild from a command prompt will continue to be this straightforward for me, but others seem to not have been so lucky according to the 2 questions I linked to at the top of my question.

INTPnerd
A: 

IMHO, if you can't get your application to do a clean build from the command line I would suggest fixing that problem instead of fixing the symptom of the problem.

Here is what I did to solve a similar issue but using VS2010:

Installed VS2010 Pro on the build server

From the command line, on my build server, I ran msbuild on my project's .sln file:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild \\build-share\dev\projects\TestProject\trunk\TestProject.sln /t:Rebuild /v:diag /p:Configuration=Release

Note: \build-share\ is a network file share used just for builds.

Once that was working the way I wanted it to, I added the task to my ccnet.config:

<project ...>
  ...
  <tasks>
    ...
    <msbuild>
      <executable>c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe</executable>
      <workingDirectory>\\build-share\dev\projects\TestProject\trunk</workingDirectory>
      <projectFile>TestProject.sln</projectFile>
      <buildArgs>/p:Configuration=Release /v:diag /t:rebuild</buildArgs>
      <timeout>300</timeout>
    </msbuild>
    ...
  </tasks>
</project>
Al Dass