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!
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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With