Misunderstanding or bug of Iis6VirtualDirectory?

May 2, 2011 at 6:57 PM

My build script first deletes the existing website and app pool (if exists) and then recreates them.  I am getting the following error:

     [echo] Creating website checkin.Dev.JhPortal for c:\BuildTools\Hudson\workspace\CI.Jh.Portal.2010\trunk\web
  [msbuild] Build started 5/2/2011 1:42:43 PM.
  [msbuild] Project "c:\BuildTools\Hudson\deploy.4.msbuild" on node 1 (CreateWebsite target(s)).
  [msbuild] CreateWebsite:
  [msbuild]   Creating AppPool: checkin.Dev.JhPortal
  [msbuild]   Creating Website: checkin.Dev.JhPortal
  [msbuild]   Creating Virtual Directory: ROOT under checkin.Dev.JhPortal
  [msbuild]   Adding Property: Path(c:\BuildTools\Hudson\workspace\CI.Jh.Portal.2010\trunk\web)
  [msbuild] c:\BuildTools\Hudson\deploy.4.msbuild(34,7): error : ObjectDisposedException: Cannot access a disposed object.
  [msbuild] c:\BuildTools\Hudson\deploy.4.msbuild(34,7): error : Object name: 'DirectoryEntry'.
  [msbuild] c:\BuildTools\Hudson\deploy.4.msbuild(34,7): error : 
  [msbuild] Done Building Project "c:\BuildTools\Hudson\deploy.4.msbuild" (CreateWebsite target(s)) -- FAILED.

My MSBuild targets are these:

    <Target Name="DeleteWebsite">
        <MSBuild.ExtensionPack.Web.Iis6Website TaskAction="Delete" Name="$(webSiteName)"/>
        <MSBuild.ExtensionPack.Web.Iis6AppPool TaskAction="Delete" Name="$(webSiteName)"/>
    </Target>
 
    <Target Name="CreateWebsite">
      <MSBuild.ExtensionPack.Web.Iis6AppPool TaskAction="Create" Name="$(webSiteName)"/>
 
      <MSBuild.ExtensionPack.Web.Iis6Website TaskAction="Create" Name="$(webSiteName)"/>
      <!-- Create an IIsWebVirtualDir at the ROOT of the website. -->
      <MSBuild.ExtensionPack.Web.Iis6VirtualDirectory
        TaskAction="Create"
        Website="$(webSiteName)"
        AppPool="$(webSiteName)"
        Properties="Path=$(homeDir);Port=$(webSitePort);DirBrowseFlags=EnableDirBrowsing;"/>
    </Target>
I have JUST started using MSBuild extensions.  We were using the SDC version until we needed to build 4.0 framework apps.  Am I just doing something wrong?

 Another oddity, when I look at the App Pools on the build box I do not see the one for Dev.checkin.JhPortal.

Any help is GREATLY appreciated,

Vance

Coordinator
May 3, 2011 at 9:28 PM

You need some properties for the apppool to get created properly, e.g.

        <MSBuild.ExtensionPack.Web.Iis6AppPool TaskAction="Create" Name="$(webSiteName)" Properties="AppPoolAutoStart=TRUE;PeriodicRestartTime=0;PeriodicRestartRequests=0;PeriodicRestartMemory=0;PeriodicRestartPrivateMemory=0;PeriodicRestartSchedule=04:00;IdleTimeout=0;AppPoolQueueLength=2000;CPULimit=0;CPUResetInterval=5;CPUAction=0;MaxProcesses=1;PingingEnabled=TRUE;PingInterval=60;PingResponseTime=90;RapidFailProtection=FALSE;RapidFailProtectionMaxCrashes=5;RapidFailProtectionInterval=5;StartupTimeLimit=60;ShutdownTimeLimit=60;AppPoolIdentityType=3;"/>

<form id="aspnetForm" action="http://msbuildextensionpack.codeplex.com/discussions/256035?ProjectName=msbuildextensionpack" enctype="multipart/form-data" method="POST">
DirBrowseFlags
is a bitmask, but it looks like you just want to set EnableDirBrowsing, so try this
<MSBuild.ExtensionPack.Web.Iis6VirtualDirectory        TaskAction="Create"        Website="$(webSiteName)"        AppPool="$(webSiteName)"        Properties="Path=$(homeDir);EnableDirBrowsing=true"/>
</form>

I don this Port is a valid metadata property. Look at bindings to set that info. There is a sample in the help.

 

Mike

May 4, 2011 at 11:14 AM

Thank you very much for you input.  However, I still seem to be having the same problem here is what I have now and here are the results:

 

      <MSBuild.ExtensionPack.Web.Iis6AppPool
        TaskAction="Create"
        Name="$(webSiteName)"
        Properties="AppPoolAutoStart=TRUE;PeriodicRestartTime=0;PeriodicRestartRequests=0;PeriodicRestartMemory=0;PeriodicRestartPrivateMemory=0;PeriodicRestartSchedule=04:00;IdleTimeout=0;AppPoolQueueLength=2000;CPULimit=0;CPUResetInterval=5;CPUAction=0;MaxProcesses=1;PingingEnabled=TRUE;PingInterval=60;PingResponseTime=90;RapidFailProtection=FALSE;RapidFailProtectionMaxCrashes=5;RapidFailProtectionInterval=5;StartupTimeLimit=60;ShutdownTimeLimit=60;AppPoolIdentityType=3;"/>
      
      <MSBuild.ExtensionPack.Web.Iis6Website TaskAction="Create" Name="$(webSiteName)"
                                             Properties="AspEnableApplicationRestart=False;AspScriptTimeout=1200;ContentIndexed=False;LogExtFileFlags=917455;ScriptMaps=;ServerBindings=:$(webSitePort):$(webSiteName);SecureBindings=;ServerAutoStart=True;UseHostName=True"/>
      <MSBuild.ExtensionPack.Web.Iis6VirtualDirectory
        TaskAction="Create"
        Website="$(webSiteName)"
        AppPool="$(webSiteName)"
        Properties="Path=$(homeDir);EnableDirBrowsing=true;"/>

Here is the log:

     [echo] Creating website checkin.Dev.JhPortal for c:\BuildTools\Hudson\workspace\CI.Jh.Portal.2010\trunk\web
  [msbuild] Build started 5/4/2011 5:58:16 AM.
  [msbuild] Project "c:\BuildTools\Hudson\deploy.4.msbuild" on node 1 (CreateWebsite target(s)).
  [msbuild] CreateWebsite:
  [msbuild]   Creating AppPool: checkin.Dev.JhPortal
  [msbuild]   Applying Property: AppPoolAutoStart(TRUE)
  [msbuild]   Applying Property: PeriodicRestartTime(0)
  [msbuild]   Applying Property: PeriodicRestartRequests(0)
  [msbuild]   Applying Property: PeriodicRestartMemory(0)
  [msbuild]   Applying Property: PeriodicRestartPrivateMemory(0)
  [msbuild]   Applying Property: PeriodicRestartSchedule(04:00)
  [msbuild]   Applying Property: IdleTimeout(0)
  [msbuild]   Applying Property: AppPoolQueueLength(2000)
  [msbuild]   Applying Property: CPULimit(0)
  [msbuild]   Applying Property: CPUResetInterval(5)
  [msbuild]   Applying Property: CPUAction(0)
  [msbuild]   Applying Property: MaxProcesses(1)
  [msbuild]   Applying Property: PingingEnabled(TRUE)
  [msbuild]   Applying Property: PingInterval(60)
  [msbuild]   Applying Property: PingResponseTime(90)
  [msbuild]   Applying Property: RapidFailProtection(FALSE)
  [msbuild]   Applying Property: RapidFailProtectionMaxCrashes(5)
  [msbuild]   Applying Property: RapidFailProtectionInterval(5)
  [msbuild]   Applying Property: StartupTimeLimit(60)
  [msbuild]   Applying Property: ShutdownTimeLimit(60)
  [msbuild]   Applying Property: AppPoolIdentityType(3)
  [msbuild]   Creating Website: checkin.Dev.JhPortal
  [msbuild]   Adding Property: AspEnableApplicationRestart(False)
  [msbuild]   Adding Property: AspScriptTimeout(1200)
  [msbuild]   Adding Property: ContentIndexed(False)
  [msbuild]   Adding Property: LogExtFileFlags(917455)
  [msbuild]   Adding Property: ScriptMaps()
  [msbuild]   Adding Property: ServerBindings(:8600:checkin.Dev.JhPortal)
  [msbuild]   Adding Property: SecureBindings()
  [msbuild]   Adding Property: ServerAutoStart(True)
  [msbuild]   Adding Property: UseHostName(True)
  [msbuild]   Creating Virtual Directory: ROOT under checkin.Dev.JhPortal
  [msbuild]   Adding Property: Path(c:\BuildTools\Hudson\workspace\CI.Jh.Portal.2010\trunk\web)
  [msbuild] c:\BuildTools\Hudson\deploy.4.msbuild(38,7): error : ObjectDisposedException: Cannot access a disposed object.
  [msbuild] c:\BuildTools\Hudson\deploy.4.msbuild(38,7): error : Object name: 'DirectoryEntry'.
  [msbuild] c:\BuildTools\Hudson\deploy.4.msbuild(38,7): error : 
  [msbuild] Done Building Project "c:\BuildTools\Hudson\deploy.4.msbuild" (CreateWebsite target(s)) -- FAILED.
  [msbuild] 
  [msbuild] Build FAILED.

BTW, the path being set does exist.
Coordinator
May 4, 2011 at 3:35 PM

I cant repro that. though im running it against iis7. I'll try get hold of an IIS6 box. This is an odd one. If possible, I would download the sourcecode and step into the debugger.

May 4, 2011 at 3:42 PM

Already got the source, I am trying to build it now.  However, the tricky bit will be getting a Windows Server 2003 debugging environment.  I should be able to get Win2003 server VM and then install remote debugging.  Which is why I didn't do that initially.

May 5, 2011 at 7:40 PM

I found the error in the code.  It was a bug.  The original code in IIs6VirtualDirectory.LoadVirtualRoot returns a DirectoryEntry which has been disposed!  Which explains the ObjectDisposedException.

Original code:

if (string.Compare(webEntry.Properties["ServerComment"][0].ToString(), websiteName, StringComparison.CurrentCultureIgnoreCase) == 0)

{

    int websiteIdentifier = int.Parse(webEntry.Name, CultureInfo.InvariantCulture);

    string rootVdirPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}/ROOT", this.IisPath, websiteIdentifier);

    DirectoryEntry returnedvdirEntry;

    using (DirectoryEntry vdirEntry = new DirectoryEntry(rootVdirPath))

    {

        returnedvdirEntry = vdirEntry;

    }

    return returnedvdirEntry;

}

 

I changed to code to this and it started working:

if (string.Compare(webEntry.Properties["ServerComment"][0].ToString(), websiteName, StringComparison.CurrentCultureIgnoreCase) == 0)

{

    int websiteIdentifier = int.Parse(webEntry.Name, CultureInfo.InvariantCulture);

    string rootVdirPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}/ROOT", this.IisPath, websiteIdentifier);

    return new DirectoryEntry(rootVdirPath);

}

Coordinator
May 21, 2011 at 8:05 PM

Resolved here: http://msbuildextensionpack.codeplex.com/workitem/8750