3

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?

Mark van Straten
  • 9,287
  • 3
  • 38
  • 57

2 Answers2

4

I've got success with the following combination of deployment parameters (in csproj) when publish web application project (WAP) to the virtual directory without marking it as IIS application:

<DeployOnBuild>True</DeployOnBuild>
<DeployAsIisApp>False</DeployAsIisApp>
<DeployIisAppPhysicalPath>MyWebSite/MyVirtualDirectory</DeployIisAppPhysicalPath>
Almas
  • 144
  • 2
4

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

tdykstra
  • 5,880
  • 2
  • 23
  • 20
  • Hmm when setting DeployAsIisApp to false it seems to work but now MsDeploy does not 'get' that the specified deploy dir is actually a virtual directory which resides somewhere else. ( Error: A value for the 'setAclUser' setting must be specified when the 'setAcl' provider is used with a physical path. ). – Mark van Straten Feb 21 '12 at 09:09
  • 1
    I also see <IncludeSetAclProviderOnDestination Condition="'$(IncludeSetAclProviderOnDestination)'==''">True</IncludeSetAclProviderOnDestination> in the targets file, so I'm guessing you could switch that off. – tdykstra Feb 22 '12 at 22:37
  • When setting IncludeSetAclProviderOnDestination to false in my .csproj the error is gone. But the error seems to originate from the fact that when you set DeployAsIisApp to False by default the "IIS Web Application Name" in the SetParameters.xml is suffixed with the (local) filepath (which does not exist on the server). Correcting this to the server path solves the issue (with IncludeSetAclProviderOnDestination=False). – Mark van Straten Feb 27 '12 at 10:29