I am writing a powershell script to automatically setup a website that I am hosting through IISExpress for development. What I've been stuck on is how to set the virtual directories of my site applications through appcmd. I've looked at the Microsoft documentation for appcmd but sadly it's pretty sparse.
I've tried:
appcmd set vdir /site.name:"testSite" /app.name:"/website" /path:"/" /vdir.name:"" /physicalPath:"newPathToSet" /config /apphostconfig:"C:\Users\Caleb\Repos\TEST\testsite\.vs\testsite\config\applicationhost.config"
but I just get this error message:
ERROR ( message:Must specify the VDIR object with identifier. )
The site in my applicationhost.config looks like this:
<site name="testSite" id="2">
<application path="/website" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\Caleb\repos\TEST\testSite\testSite" />
</application>
<application path="/images" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\Caleb\images" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:58375:localhost" />
<binding protocol="https" bindingInformation="*:44334:localhost" />
</bindings>
</site>
I managed to figure it out. Here is the solution that worked for me: