Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MSBuild to deploy an ASP.NET MVC application [closed]

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!

like image 999
wgpubs Avatar asked Aug 04 '09 17:08

wgpubs


3 Answers

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

  • Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build (Book)
  • Inside MSBuild
  • 7 Steps To MSBuild
  • MSDN MSBuild Docs
like image 131
Sayed Ibrahim Hashimi Avatar answered Nov 15 '22 12:11

Sayed Ibrahim Hashimi


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.

like image 40
Decker97 Avatar answered Nov 15 '22 11:11

Decker97


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

like image 2
Doug Avatar answered Nov 15 '22 11:11

Doug