Setting scriptmaps: step two
Now that we know how to call aspnet_iisreg.exe all we need is its parameters. Executing aspnet_regiis /? indicates that we want:
-s <path>
Install scriptmaps for this version at the specified path, recursively.
E.g. aspnet_regiis.exe -s W3SVC/1/ROOT/SampleApp1
By this point in the install process, we already have properties set for us from the UI or the command line for TARGETSITE and TARGETVDIR. TARGETSITE takes a form like "/LM/W3SVC/1", and TARGETVDIR is something like "WebSite1Setup". How do we know that? All you have to do is run the original installer with verbose logging, and then examine the log file:
msiexec /i WebSite1Setup.msi /l*v LogFile.txt
This will write tons of information to the log file, and you'll find lines like:
MSI (c) (48:A4) [13:44:02:685]: Switching to server: TARGETDIR="C:\inetpub\wwwroot\WebSite1Setup\" TARGETVDIR="WebSite1Setup" _CFA818CA6DA647A5AF4DFFEA95FD19C1="C:\inetpub\wwwroot\WebSite1Setup\bin\" IISVERSION="#5" ALLUSERS="1" TARGETSITE="/LM/W3SVC/1" _F363883C8B9A46F08810E19D4D9A7B27="C:\inetpub\wwwroot\WebSite1Setup\App_Code\" REGIISDIR="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\" CURRENTDIRECTORY="C:\Documents and Settings\vank\My Documents\Visual Studio 2005\Research-WebSetup" CLIENTUILEVEL="0" CLIENTPROCESSID="2376" USERNAME="VanK" COMPANYNAME="Microsoft" SOURCEDIR="C:\Documents and Settings\vank\My Documents\Visual Studio 2005\Research-WebSetup\" ACTION="INSTALL" EXECUTEACTION="INSTALL" ROOTDRIVE="C:\" INSTALLLEVEL="1" SECONDSEQUENCE="1" ADDLOCAL=DefaultFeature
This is effectively a dump of all the public properties at this state in the installation, and is a quick and handy way to find out what we have to work with. Note that TARGETSITE is set when the user selects from the "Site" dropdown in the UI (assuming that we have more than one "web site" running on our web server) and TARGETVDIR is the Virtual Directory which the user entered in the text box of the dialog. So, all we have to do is combine the two with a slash in between, and we have our parameter!
Try it on the command line first:
aspnet_regiis /s /LM/W3SVC/1/WebSite1Setup
...and you get:
Start registering ASP.NET scriptmap (2.0.50727) recursively at /LM/W3SVC/1/WwebSite1Setup.
Installation stopped because the specified path(/LM/W3SVC/1/WebSite1Setup) is invalid.
What? Refer back to the /? output and we see the example includes /ROOT/; maybe that's it! Try:
aspnet_regiis /s /LM/W3SVC/1/ROOT/WebSite1Setup
...and we get the same unfortunate result. To make a long story short, it's the leading "/LM/", which stands for Local Machine. What we require is:
aspnet_regiis /s W3SVC/1/ROOT/WebSite1Setup
It would have been very nice for our purposes if aspnet_regiis ignored the leading "/LM/", but instead it returns an error. To register the scriptmaps we need to strip part of this string off, but unfortunately there's no built-in Custom Action that performs this kind of service for us. We have to write our own.