3

I have an MSBuild script that is generating a deployment script for my web app.

Project.build (excerpt)

<MSBuild Projects="xxxxx.sln" Properties="
                CreatePackageOnPublish=true;
                DeployOnBuild=true;
                IncludeIisSettings=true;
                IncludeAppPool=true;" >
  <Output TaskParameter="TargetOutputs" ItemName="CompiledAssembly" />
</MSBuild>

When this is executed, it does produce a Package folder in the output that contains a deployment .cmd file and associated .zip file.

xxxx.SetParameters.xml (generated)

<?xml version="1.0" encoding="utf-8"?>
<parameters>
  <setParameter name="IIS Web Application Name" value="Default Web Site\xxxxx" />
  <setParameter name="DefaultConnection-Web.config Connection String" 
         value=" ... snipped ..." />
</parameters>

As you can see, there is no reference to app pool here. Likewise, there is mention of app pool in the generated xxxx.zip\parameters.xml

When I execute xxxxxx.deploy.cmd /Y, it correctly creates the application in IIS. The problem is, it seems to use the default application pool for the machine. It's a .net 4 app, so if the default is .net 2, the app fails to run.

Is there a way to make the deployment script include an app pool definition so that it won't require manual app pool changes to run?

I did find this question, which seems to be the same. However, as you can see, I've already included the answer from that question, and it has no effect.

Community
  • 1
  • 1
recursive
  • 83,943
  • 34
  • 151
  • 241

1 Answers1

3

If you're trying to deploy a 4.0 app to a 2.0 default app pool without providing an override it will not fail to run but fail to deploy, MSDeploy would simply fail to precreate a virtual app with ERROR_APPPOOL_VERSION_MISMATCH error.

IncludeAppPool is the correct property, but it only tells the packager to include the settings, you have to provide the source, i.e. the "master" virtual app with correct app pool to copy from.

Open project properties and switch from IIS Express to Local IIS, this will enable app pool flag under the package/publish options. I believe you can switch back afterwards, the settings will remain.

enter image description here

enter image description here

This would basically do 2 things, add <IncludeAppPool>true</IncludeAppPool> as well as add the master app under <WebProjectProperties> section. Now when you build or package your source manifest will not have the managedRuntimeVersion requirement but your parameters will now have IIS Web Application Pool Name to customize.

If you want to actually create a new app pool then it gets tricky. I'm not aware of a way to create it during iisApp creation or with some MSBuild flag, but with MSDeploy (the tool behind your .cmd) it would require a dump of your local pool and sync up with appPoolConfig provider, probably as part of your .build script before the .cmd call.

msdeploy -verb:sync -source:appPoolConfig=Foo -dest:package=foo.zip
msdeploy -verb:sync -source:package=foo.zip -dest:appPoolConfig=Foo,computerName=Bar

Keep in mind that without specifying individual appPoolConfig the sync, as it should, would destroy other pools, so do -whatIf first just in case.

You can probably try to merge the archive.xml of your package and the archive.xml with the app pool definition, but I can't image how it would work and what relationship between iisApp and appPoolConfig providers is there.

Edit: You can use manifest provider to combine package or iisApp with appPoolConfig

Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70