Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to MSDeploy a built website package to a virgin IIS website

I am trying to automate our build/deployment process.

So far I am using:

  • a Visual Studio 2010 solution with a main Web Application project (and dependent projects)
  • MSBuild
  • MSDeploy
  • CruiseControl.Net

So after much wrangling and gnashing of teeth, I now have CCNet kicking off an MSBuild script to build, package and deploy the website. The MSBuild script is below:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build"> 
    <MSBuild Projects="$(CCNetWorkingDirectory)\src\Product.sln"
                    Targets="Clean;Rebuild"
                    Properties="Configuration=$(Configuration)"
    />
</Target>

<!--<Target Name="Test" DependsOnTargets="Build">
    <MSBuild Projects="$(CCNetWorkingDirectory)\src\Product.Web.Tests\Product.Web.Tests.csproj"
                    Properties="Configuration=$(Configuration);OutputPath=$(CCNetArtifactDirectory)\Tests\" />
    <Exec Command="$(MSTestPath) /testcontainer:$(CCNetArtifactDirectory)\Tests\Product.Web.Tests.dll /runconfig:$(CCNetWorkingDirectory)\src\Local.testsettings" ContinueOnError="false" />
</Target>-->

<Target Name="Package" DependsOnTargets="Build"> 
    <MSBuild Projects="$(CCNetWorkingDirectory)\src\Product.Web\Product.Web.csproj"
                    Targets="Package"
                    Properties="Configuration=$(Configuration);PackageLocation=$(PackageDir)\Product.zip"
    />
</Target>

<Target Name="Deploy" DependsOnTargets="Package">
    <Exec Command="&quot;$(MSDeployPath)&quot; -source:package='$(PackageDir)\Product.zip' -dest:auto,computerName='$(MSDeployComputerName)',includeAcls='False' -verb:sync -setParamFile:$(PackageDir)\Product.SetParameters.xml" ContinueOnError="false" />
</Target>

This all works fine as long as on the target machine there is already a website configured in IIS. This doesn't need to be an existing "real" site (it could just be a shell).

While this is great, I really want MSDeploy to automatically create the website, as it seems it can do with a web app. Is this possible? And if so any help would be greatly appreciated!

like image 332
Eric Amodio Avatar asked Sep 03 '10 19:09

Eric Amodio


2 Answers

MSDeploy has the capability, you just have to hook the right provider.

For example, you are using the "auto" provider in your destination, which basically says the destination is going to be the same as (or compatible with) the source, which you are setting up as a package. Since a package does not specify its hosting environment, msdeploy isn't going to try to do anything with it, it just going to copy files from the package basically.

You are calling auto in (the "-dest: auto"):

-dest:auto,computerName='$(MSDeployComputerName)'

To get msdeploy to create the site, you need to use a more specific provider which understand the concepts of a "site" and an "app" and how they can use the package as the contents of a website element.

I haven't done this in awhile, so I don't want to lay out specifics (as I'll prob steer you wrong), but take a look at the MSDN document on msdeploy providers.

1st look at auto, your current setting. Then take a look at iisApp and appHostconfig.

http://technet.microsoft.com/en-us/library/dd569040(WS.10).aspx

I believe one of those 2 will create the site/app for you if used correctly, and will give you the result you need.

like image 79
Taylor Bird Avatar answered Sep 23 '22 12:09

Taylor Bird


Pretty sure MSDeploy can't do that. One thing I have done in the past is have an Exec task call appcmd.exe to tear down/build up a new web site. The MSBuild Community Tasks have some web site capabilities as well as the MSBuild Extension Pack.

like image 34
Adam Fyles Avatar answered Sep 23 '22 12:09

Adam Fyles