views:

1875

answers:

4

I'm a complete noob with respect to msbuild but am encouraged to use it based on a previous answer to a question I posted a few days back.

Anyhow, I'm looking for some recommendations on getting started with MSBuild ... and in particular, using it to automate the deployment of ASP.NET MVC applications.

Thanks much!

A: 

I've used MSBuild in a larger CI scheme. I use Hudson to trigger build jobs that us MSBuild to build the assemblies, but not to deploy. For deployment, I'm using BeyondCompare to "sync" the files to the IIS site folder.

Trinition
+2  A: 

I use msbuild directly, skipping nAnt. You can call it with a build file as a property and specify the target from the command line. Here is a sample soultion.build file:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
     <!-- Import the MSBuild Tasks -->
  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <ClassLibraryOutputDirectory>bin$(Configuration)</ClassLibraryOutputDirectory>
    <ProjectDir>.\</ProjectDir >
    <ProjectTestDir>DALTests\</ProjectTestDir >
    <ProjectFile>$(ProjectDir)SSN.sln</ProjectFile >
    <TestProjectFile>$(ProjectTestDir)DALTests.csproj</TestProjectFile >
  </PropertyGroup>

  <!-- Build projects by calling the Project files generated by VS -->
  <Target Name="Build">
    <MSBuild Projects="$(ProjectFile)" />
    <MSBuild Projects="$(TestProjectFile)" />
  </Target>

  <!-- Run Unit tests -->
  <Target Name="Test" DependsOnTargets="Build">
    <CreateItem Include="DALTests\Bin\Debug\DALTests.exe">
      <Output TaskParameter="Include" ItemName="DALTests" />
    </CreateItem>
    <NUnit Assemblies="@(DALTests)" ToolPath="D:\Program Files\NUnit 2.4.5\bin" ContinueOnError="false" OutputXmlFile="SoultionTestResults.xml" />
  </Target>
</Project>

I call this from a batch file like this: (in the same dir as soultion.build)

C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe Soultion.Build /Target:Build

You will need the MSBuild Community Tasks dll, just google it.

Decker97
+4  A: 

For web stuff you should use Web Deployment Projects. It is a free add on from Microsoft that will run the aspnet_compiler and aspnet_merge tool on your web site or web project (MVC in your case). You can customize the build there to help you prepare for deployment.

About getting started with MSBuild here are some links, also the link to my book is below my name.

Sayed Ibrahim Hashimi
This was perfect for me too, thanks.
John Gietzen
A: 

I wrote a pretty detailed blog post on achieving exactly what you after using TeamCity and Web Deployment projects:

http://www.diaryofaninja.com/blog/2010/05/09/automated-site-deployments-with-teamcity-deployment-projects-amp-svn

Doug