24

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!

4 Answers 4

17

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 resources

Sign up to request clarification or add additional context in comments.

1 Comment

Good answer at the time, but MS no longer supports them in VS 2012.
5

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">
     <!-- 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.

2 Comments

where would the msbuild community tasks dll go? do I reference that from my asp.net mvc application?
Sorry... How would you use this for an asp.net mvc application?
2

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

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.