Deploy.ps1 or PostDeploy.ps1 not executed?

I created a package for my site, and wanted to convert a subfolder into an application in iis. To achieve this, i created the following PostDeploy.ps1 and put it in my nuget package.

import-module WebAdministration
Write-Host "Converting admin to application…"
ConvertTo-WebApplication iis:\Sites\MySite\admin

Now, the log mentions that it is execute the PostDeploy, but the output is rather empty and the folder isn’t converted to a Web application. What am I missing?

2011-06-22 14:57:09 DEBUG Script ‘\PostDeploy.ps1’ completed.
2011-06-22 14:57:09 DEBUG Script output:
2011-06-22 14:57:09 DEBUG
2011-06-22 14:57:09 INFO Installing any Installers

There is a problem with the way script output is piped to the deployment output (originally I just invoked PowerShell.exe, but now I host PowerShell in an app domain, and I think there’s a bug there). However the script should still be executed. I’ll make sure the output is available in the next build.

I see, but unfortunately it looks like the script isn’t executed or fails. If the output would be shown I would know. Thanks for looking into it.

This bug was down to me passing a StringBuilder into the AppDomain which hosts PowerShell, which was being copied rather than used as a reference, so I never saw any output. It’s fixed in the latest build - you should definitely see script output and any errors now:

Thanks! That fixes the no output problem perfectly. However, the next proble I run into is the following. The output of the postdeploy powershell script looks more or less like this:

System.Management.Automation.CmdletInvocationException: Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). --->     System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
   at Microsoft.IIs.PowerShell.Framework.Configuration.QueryToStream(String xpath, String location, PipelineStreamWriter writer, QueryFlags queryFlags)
   at Microsoft.IIs.PowerShell.Framework.NamespaceNodeFactory.EnumerateInstances(TypeManager tm, CmdletProvider provider, String nodeTag, INamespaceNode parentNode)
   at Microsoft.IIs.PowerShell.Framework.NodeCollectionFactory.EnumerateInstances(TypeManager tm, CmdletProvider provider, String nodeTag, INamespaceNode parent)
   at Microsoft.IIs.PowerShell.Framework.NamespaceNode.ResetChildren(Boolean reRead)
   at Microsoft.IIs.PowerShell.Framework.NamespaceNode.get_Children()

This indeed is the output of the script when I execute it under the 32-bit PowerShell. However, when the script is executed in the default 64-bit one, then it succeeds without problems. Shouldn’t the 64-bit Powershell be the default?

Hi Thomas,

Nice find. The issue is that I run Tentacle as a x86 process, hoping it would make things more consistent - but I guess not.

I’ll change the build system to ensure everything is AnyCPU and publish a new build tomorrow. That should fix this issue.

I guess you could also work around it by having your Deploy.ps1 call the 64 bit PowerShell passing a second script as a parameter :slight_smile: