Creating a web site webdeploy package when solution builds

2k Views Asked by At

I have a VS 2010 WCF service solution which I would like to deploy to IIS 7.5 servers via web deploy package. I would like to have the web deploy package generated when the WCF service project builds. I have seen other examples of how to initiate a web deploy packaging after build via importing MS Build targets for web deploy into the .csproj. But I cannot wrap my head around things which I am may or may not be able to to do this way.

I want my web deploy package to do the following tasks when deployed on a target server:

  • Create a new web site on the target server with an app pool to target framework 4.0 which uses NETWORK SERVICE identity
  • Add site bindings to enable net.tcp on a specific port and enable http and net.tcp prootocols
  • Create a web application under this new site to point to a specific file system folder
  • Run a .bat file to start couple of net.tcp related services to support non http WCF activation

From whatever I have read about web deploy, some of these can be done via webdeploy manifest files and including specific providers. What I am not understanding is telling the MS build packaging mechanism to pass the providers to include in the manifest and the values. I am fairly new to Web deploy and any help/pointers to solve this would be greatly appreciated.

3

There are 3 best solutions below

1
On

Tried that but project fails to load thereafter: The element < Path > beneath < MsDeploySourceManifest > is unrecognized.

0
On

The approach I take is to use MSBuild to build the package and MSDeploy to deploy it to the server. I use the following command line, in my case I'm using cruise control:

/p:Configuration=Release 
/p:MSDeployPublishMethod=WMSVC 
/p:DeployOnBuild=True 
/p:DeployTarget=Package 
/p:CreatePackageOnPublish=True 
/p:DeployIisAppPath=$(SolutionName)/$(ProjectName) 
/p:MsDeployServiceUrl=https://<servername>:8172/MsDeploy.axd 
/p:AllowUntrustedCertificate=True 
/p:username=<username>
/p:password=<password>
/p:EnablePackageProcessLoggingAndAssert=True
/p:PackageLocation=$(WorkingMainDir)$(ProjectName)$(ProjectType)\Package\$(SolutionName).zip
/p:IntermediateOutputPath=$(WorkingMainDir)$(ProjectName)$(ProjectType)\Temp\
/p:AutoParameterizationWebConfigConnectionStrings=true
/p:UseWPP_CopyWebApplication=true

I then use msdeploy to deploy the resulting package, the following link (the accepted answer) is a good write up on how to do this:

msdeploy (Web Deploy) failing with 401 auth issues

3
On

The first three items can be done using the appHostConfig provider, which should be included if you set the IncludeIisSettings and UseIis properties both to true.

The last item can be done via the runCommand provider either as part of your manifest or via preSync / postSync.

WPP (the MSBuild stuff on top of MSDeploy) has no support for preSync / postSync, but you can include the runCommand provider explicitly using MsDeploySourceManifest:

<!-- Create a WebProjectName.wpp.targets file in the root 
     of your web application (WebProjectName)
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <AfterAddContentPathToSourceManifest>
      $(AfterAddContentPathToSourceManifest);
      AddPostSyncProviders
    </AfterAddContentPathToSourceManifest>
  </PropertyGroup>

  <Target Name="AddPostSyncProviders">
    <MsDeploySourceManifest Include="runCommand">
      <Path>absolute path to exe on target machine</Path>
    </MsDeploySourceManifest>
  </Target>
</Project>

FYI - runCommand can only execute absolute paths on the target machine as per this question.