简体   繁体   English

IIS CLI为我的项目生成带有site的applicationhost.config

[英]IIS CLI generate applicationhost.config with site for my project

I have a C# solution with several projects, one of which is a web server run by IIS. 我有一个包含多个项目的C#解决方案,其中一个是由IIS运行的Web服务器。 I have set <UseGlobalApplicationHostFile>True</UseGlobalApplicationHostFile> in the csproj file of that project. 我在该项目的csproj文件中设置了<UseGlobalApplicationHostFile>True</UseGlobalApplicationHostFile>

When I open Visual Studio, it generates this in ~/Documents/IISExpress/config/applicationhost.config: 当我打开Visual Studio时,它会在〜/ 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). 我希望能够从命令行使用IIS Express运行我的项目(用于构建服务器集成测试目的)。 How can I generate the SealingService site section of applicationhost.config from the command line (without opening Visual Studio)? 如何SealingService生成SealingService站点部分(无需打开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. 在我的解决方案文件夹中,但它只生成WebSite1部分。

If I understood correctly, what you want to do is to add the section you specified to the ~/Documents/IISExpress/config/applicationhost.config file. 如果我理解正确,您要做的是将您指定的部分添加到〜/ Documents / IISExpress / config / applicationhost.config文件中。

You can do this using the AppCmd.exe command line tool: 您可以使用AppCmd.exe命令行工具执行此操作:

"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 ; 使用第一个命令创建站点 ,设置其http绑定及其物理路径 ; with the second one we set its application pool with the desired one; 使用第二个,我们将其应用程序池设置为所需的应用程序池 ; and with the third one we add the https binding . 第三个我们添加https绑定

If you use the x86 version of IIS Express, you find AppCmd in C:\\Program Files (x86)\\IIS Express\\appcmd.exe 如果您使用x86版本的IIS Express,则可以在C:\\ Program Files(x86)\\ IIS Express \\ appcmd.exe中找到AppCmd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Applicationhost.config未更新 - Applicationhost.config not updated 如何将IIS ApplicationHost.config文件解析为.Net对象? - How to parse the IIS ApplicationHost.config file into .Net objects? 初始化 applicationhost.config 文件失败。 找不到 IIS Express - Initializing the applicationhost.config file failed. Cannot find IIS Express applicationHost.config 错误:由于 IIS 共享配置的权限不足,无法写入配置文件 - applicationHost.config Error: Cannot write configuration file due to insufficient permissions with IIS shared configuration 我是否必须手动编辑 applicationhost.config 以将特定绑定添加到 IIS Express - Must I manually edit the applicationhost.config to add specific bindings to IIS Express 以编程方式解锁applicationHost.config中的部分 - Unlock section in applicationHost.config programmatically applicationhost.config中的位置路径未映射到程序集 - Location path in applicationhost.config not mapping to assembly C# applicationHost.config 未找到但存在 - C# applicationHost.config not found but exists Microsoft.Web.Administration-ApplicationHost.Config中带有httpError的NullReferenceException - Microsoft.Web.Administration - NullReferenceException with httpErrors in ApplicationHost.Config 由于applicationHost.config无效,.Net构建失败 - .Net build is failing due to invalid applicationHost.config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM