tags:

views:

1986

answers:

1

Hi,

I'm trying to configure NAnt to automate my build process - once I've got this step nailed, I'll be integrating the unit tests.

Perhaps I don't exactly know what I want, so please correct me if there is a completely different way of doing all of this...

I want two NAnt targets, one to do quick, debug builds to make sure everything works and the tests pass, and another target to do a proper compile and publish (its a web application project)

My problems are...

  1. I can't get MSBuild to compile just the dlls, it's always copying all of the web-app junk (images, css, .aspx files etc) with it. Is there a way to stop this? If so, how?
  2. When I compile using /t:Compile, its still creating .pdb files for the dlls. Is this correct? I Thought these were for the debugger, and therefore shouldnt be present when doing a release compile?

here is my NAnt target for the full release compile (publish):

<target name="build.deploy" description="Compile Web Site." depends="init">
    <exec basedir="." program="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe" commandline=" MyProj/Interface/Interface.csproj /nologo
        /t:Compile
        /t:ResolveReferences;_CopyWebApplication
        /p:OutDir=../../deploy/bin/
        /p:WebProjectOutputDir=../../deploy/;AspNetConfiguration=Release"
        workingdir="." failonerror="true" />
</target>

Thanks for you help!

P.S. I dont have to use msbuild if there is an easier way. I tried to use CSC first, but I couldnt resolve all the referencing problems i was getting. Suggestions very welcome

+4  A: 

Rather than invoke MSBuild directly, I'd suggest using the NAnt-Contrib msbuild task.

For instance, in my Protocol Buffers project I have this:

<target name="build"
        description="Builds all C# code">
  <msbuild project="${src}/ProtocolBuffers.sln">
    <property name="Configuration"
              value="${build-configuration}" />
  </msbuild>
</target>

When build-configuration is Release it doesn't build the PDBs. This depends on how you've got the project set up in Visual Studio though - you can still build PDBs for the optimised release version.

EDIT: As for the "extra junk" stuff - it will do whatever a build in Visual Studio does. If you can mess around in VS to switch various options the way you want them, it should work fine from NAnt/MSBuild too.

Jon Skeet
Ta, ill look into this now :)
Andrew Bullock
Thanks, can you point me at a reference list of all properties for msbuild, I cant find it anywhere :(
Andrew Bullock