Search code examples
deploymentmsbuildcontinuous-integrationmsdeployn2cms

MsDeploy Virtual Directory gets converted to Virtual Application on deploy


For my CMS to work properly it needs to be deployed to a virtual directory underneath the www root so it can access (via reflection) the website to manage (note: CMS = N2CMS). When using Visual Studio 'Publish To Web' all is fine. But when I generate the package via msbuild commandline and publish that version my virtual directory is converted to a virtual application.

I configured my remote server to have a virtual directory '/n2' underneath my IIS web application ('exampleapp') and configured this path in the Package/Publish Web settings (IIS Website/Application name to use on the destination server) within my project in Visual Studio.

To generate the deploy package:

msbuild.exe myproject.csproj /T:Package

This generates the zipped package of my code together with MsDeploy commandline batch files to execute (standard msbuild/msdeploy target).

The generated SetParameters.xml contains the following:

<?xml version="1.0" encoding="utf-8"?>
<parameters>
  <setParameter name="IIS Web Application Name" value="exampleapp/n2" />
</parameters>

The generated SourceManifest.xml contains the following

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <IisApp path="C:\...shortened-path...\PackageTmp" managedRuntimeVersion="v4.0" />
  <setAcl path="C:\...shortened-path...\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\...shortened-path...\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

Anybody got a clue why the virtual directory gets converted to virtual application?


Solution

  • In the Microsoft.Web.Publishing.targets file, DeployAsIisApp defaults to true:

    <DeployAsIisApp Condition="'$(DeployAsIisApp)'==''">true</DeployAsIisApp>

    You should be able to override it to false by adding it to the appropriate PropertyGroup element in the project file or in a .wpp.targets file in the project folder; on editing the project file, see

    http://msdn.microsoft.com/en-us/library/ff398069.aspx