Creating virtual directory under a specific website with NANT
I am able to create a virtual directory with 'mkiisdir', but it creates under default website only.
With using IISServer attribute it works fine in my test environment but not in Production env.
Scenario 1 (Test env)
- IIS with 2 websites, 1 hosted on 80 & other on 88.
- Use attribute IIServer='localhost' & port ='88', it creates the virtual directory under the right website
Scenario 2 开发者_运维技巧(Production env)
- IIS with 2 websites, 1 hosted on 80 & other as well on 80 but with a different hostheader.
What value should i use for IISServer & port so that virtual directory gets created under the website with the host header.
I know this post is very old but we recently encountered the same problem. If you are using IIS 7 (or above) then there is a work-around. You can use AppCmd.exe
that comes with IIS 7 to perform lots of different actions, in your case create Applications under different web sites.
You could create a sample Nant task (macro):
<macrodef name="Install.App">
<attributes>
<attribute name="websiteName" default="Default Web Site" />
<attribute name="vdir" />
<attribute name="physicalPath" />
<attribute name="appPool" default="DefaultAppPool" />
</attributes>
<sequential>
<exec program="c:\windows\System32\InetSrv\appcmd.exe" workingdir="${project::get-base-directory()}" verbose="true" failonerror="false" >
<arg value="ADD"/>
<arg value="APP" />
<arg value=""/site.name:${websiteName}""/>
<arg value="/path:${vdir}" />
<arg value="/physicalPath:${physicalPath}" />
<arg value="/apppool.name:${appPool}" />
</exec>
</sequential>
</macrodef>
Then you can simply call it with something like this:
<Install.App websiteName="SomeOtherWebsite" vdir="/MyApp" physicalPath="C:\apps\myapp" appPool="MyAppPool" />
This would create an application named "MyApp" inside the "SomeOtherWebsite" web site on that server.
This creates an application but you could also create a plain virtual directory by simply changing <arg value="APP" />
to <arg value="VDIR" />
. For more information and options you can read more here.
I hope that helps some other people who are also stuck in the same position!
Specify iisserver parameter and identify your site be hostname:port combination
<mkiisdir iisserver="host:port" dirpath="c:\siteroot\test" vdirname="Test" />
You can specify website as a parameter to mkiisdir
<mkiisdir iisserver="host" website="${project.service.iiswebsite}" " dirpath="c:\siteroot\test" vdirname="Test"/>
Should work fine
精彩评论