Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET equivalents for ANT and WAR files?

The majority of our internal apps are built on a Java EE stack using Ant, and deployed to Tomcat with a WAR file. We have a build box that creates a Production-targeted WAR, and the WAR is then delivered to the Test environment. A script is run to convert the deployed webapp to point to Test data environments.

After a few cycles of Test -> Bug Fix -> Build -> Redeploy to test, the WAR file is then deployed to Production, and is then live.

I've recently inherited some ASP.NET 4.0 webapps, and their Build/Deploy is quite different; the code is built in VS, and then the entire project directory is copied to each environment. It is then tweaked by hand, and is occasionally rebuilt with a VS instance on the server.

This is a bit scary, as there are plenty of opportunities for tweaks in one environment to be forgotten, and thus require that we're playing around with our apps after they're "live", outside the bounds of testing, version control, etc.

So, all of this being said: Is there an equivalent to the Ant/WAR mechanism in a .NET world? What's the safest way to create an executable artifact from a .NET webapp and move it between environments with minimal modification? I know that "best pratices" is a taboo phrase, but I'd like to dip into some expert knowledge before I remake Ant in .NET. :-)

like image 675
IVR Avenger Avatar asked Aug 01 '12 15:08

IVR Avenger


1 Answers

Three technologies you need to know about to automate web deployments:

  1. MSBuild - This is Microsoft's equivalent of ANT. Project files are basically just a series of MSBuild tasks.
  2. WebDeploy - This is essentially your WAR/Tomcat equivalent, except that it creates deploy packages, and is meant for IIS.
  3. XML Transforms - You should never have to manually edit configuration by hand. Config transforms are essential if you have multiple environments you need to deploy to.

Put all these together with your favorite Build server (I use Jenkins), and you can totally automate your entire deployment process to any environment. Each of these individual topics is too broad to cover in depth here, but you should be able to get started with minimal knowledge of each.

To give you an example of how simple it can be, here is a sample command line build that will deploy a website to a 2003/IIS6 box.

MSBUILD "MyWebSite.csproj" 
    /p:Configuration=Dev 
    /p:OutputPath=bin 
    /t:Rebuild 
    /p:DeployOnBuild=true 
    /p:DeployTarget=MSDeployPublish 
    /P:AllowUntrustedCertificate=True 
    /p:MSDeployPublishMethod=RemoteAgent 
    /p:MsDeployServiceUrl=http://MyDevServer    
    /p:DeployIisAppPath="Default Web Site/MyWebSite" 
    /p:username=deployUser 
    /p:password=deployPassword
like image 153
Josh Avatar answered Sep 29 '22 07:09

Josh