I have a C# solution with several projects, one of which is a web server run by IIS. I have set <UseGlobalApplicationHostFile>True</UseGlobalApplicationHostFile>
in the csproj file of that project.
When I open Visual Studio, it generates this in ~/Documents/IISExpress/config/applicationhost.config:
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="SealingService" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\sehch\Documents\Paragon\ParagonCore\servers\SealingService\SealingService" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:61800:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
I want to be able to run my project with IIS Express from the command line (for build server integration testing purposes). How can I generate the SealingService
site section of applicationhost.config from the command line (without opening Visual Studio)?
I have tried running
"C:\Program Files (x86)\IIS Express\iisexpress.exe"
in my solution folder, but it only generates the WebSite1
section.
If I understood correctly, what you want to do is to add the section you specified to the ~/Documents/IISExpress/config/applicationhost.config file.
You can do this using the AppCmd.exe command line tool:
"C:\Program Files\IIS Express\appcmd.exe" add site /name:SealingService /bindings:"http/*:61800:localhost" /physicalPath:"C:\Users\sehch\Documents\Paragon\ParagonCore\servers\SealingService\SealingService"
"C:\Program Files\IIS Express\appcmd.exe" set site /site.name:SealingService /[path='/'].applicationPool:Clr4IntegratedAppPool
"C:\Program Files\IIS Express\appcmd.exe" set site /site.name:SealingService /+bindings.[protocol='https',bindingInformation='*:44300:localhost']
With the first command we create the site , set its http binding and its physical path ; with the second one we set its application pool with the desired one; and with the third one we add the https binding .
If you use the x86 version of IIS Express, you find AppCmd in C:\\Program Files (x86)\\IIS Express\\appcmd.exe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.