【问题标题】:ASP.Net Core 1.0 RC2 : What are LAUNCHER_PATH and LAUNCHER_ARGS mentioned in web.config?ASP.Net Core 1.0 RC2:web.config 中提到的 LAUNCHER_PATH 和 LAUNCHER_ARGS 是什么?
【发布时间】:2016-09-24 14:17:36
【问题描述】:

在 ASP.NET 5 RC2 版本中有breaking changes

  • 更名为 ASP.NET Core 1.0 (ASP.NET 5 is dead)
  • 再见dnvmdnu命令行,它们被dotnet替换
  • 各种必要的代码更改

我正在尝试部署dotnet publish 生成的文件。文件结构与 RC1 不同。我在事件查看器中看到以下错误:

Failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%', Error Code = '0x80070002'.

web.config 中提到了这些环境变量,取自official rc1-to-rc2 文档。

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*"
              modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
        stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
        forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

%LAUNCHER_PATH%%LAUNCHER_ARGS% 的正确值是多少?这些值在其github publish document 中未提及。

【问题讨论】:

    标签: asp.net asp.net-core


    【解决方案1】:

    来自 github IISSample(谢谢@Pawel 和 Luke),这里是价值可能性:

    <!-- This set of attributes are used for launching the sample using IISExpress via Visual Studio tooling -->
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    
    <!-- This set of attributes are used for launching the sample for full CLR (net451) without Visual Studio tooling -->
    <aspNetCore processPath=".\IISSample.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    
    <!-- This set of attributes are used for launching the sample for Core CLR (netcoreapp1.0) without Visual Studio tooling -->
    <aspNetCore processPath="dotnet" arguments=".\IISSample.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    

    经过几个小时的处理,我发现有两个我们需要处理的 web.config:src\ProjectName\wwwroot\web.configsrc\ProjectName\web.config。如果你没有后者,VS2015 publish 会默认为你生成一个%LAUNCHER_PATH%%LAUNCHER_ARGS%

    要让项目在 VS2015 下通过 IISExpress 在本地运行和调试,web.config 都需要具有以下默认值。将 LAUNCHER_PATH 和 LAUNCHER_ARGS 替换为其他内容会导致 VS2015 无限期挂起。

    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    

    但是,在部署到 IIS 时(我在 WinServer 2012 R2 上使用 8.5),src\ProjectName\web.config 上的值必须替换为以下内容。如果已配置,dotnet publish-iis 命令会为您进行替换(见下文)。

    <aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    

    如果您从 RC1 迁移,change http 绑定目录以及项目根文件夹,而不是 wwwroot。示例:从C:\inetpub\ProjectName\wwwrootC:\inetpub\ProjectName

    configurepublish-iis做自动替换,把这个sn-p添加到你的project.json中:(谢谢@Pawel)

      "tools": {
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
          "version": "1.0.0-preview1-final"
        }
      },
      "scripts": {
        "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
      }
    

    IISIntegration 工具段将这些 Launcher 变量转换为适当的部署值。没有它,你会得到以下错误:

    No executable found matching command "dotnet-publish-iis"
    

    我正在使用 RC2 Toolkit Preview 1。

    【讨论】:

    • 我认为 RC2 不需要 2 个 web.config。我相信 wwwroot 中的那个现在没用了。
    • @maxisam 不是真的。 project\wwwroot\web.config 用于生成 project\web.config 。如果你像上面那样配置你的project.json,它将使用你的project\wwwroot\web.config作为模板。
    • 啊……你可以自己试试。它可以在 wwwroot 中没有 web.config 的情况下正常工作。是的,我在 project.json 中使用了相同的脚本。其实升级到1.0.0-preview1-002702新模板就是这样的
    • 为此"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"+1。我正在从 RC2 迁移到 1.0 final 并且 IIS 部署没有改变 web.config
    【解决方案2】:

    %LAUNCHER_PATH%%LAUNCHER_ARGS% 被 VS 使用。 publish-iis 工具(如果已配置)将在您发布应用程序时覆盖它们。

    【讨论】:

    • 在哪里可以找到发布-iis 工具?我可以在某处通过命令行调用它吗?
    • 该工具是通过在您的 poject.json 和 dotnet restoreing 您的项目的 tools 部分中指定引用来提供给您的。您可以从命令行运行该工具,典型用法是将其配置为发布后脚本。更多详情见我的帖子:blog.3d-logic.com/2016/06/08/…
    【解决方案3】:

    这是 VS 中 web.config 的一部分:

    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
        stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
        forwardWindowsAuthToken="false"/>
    

    这是发布后在服务器上的:

    <aspNetCore processPath="dotnet" arguments=".\AppName.dll" 
        stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" 
        forwardWindowsAuthToken="false" />
    

    在此示例中,%LAUNCHER_PATH% 替换为 dotnet%LAUNCHER_ARGS% 替换为 application name,扩展名为 .dll

    【讨论】:

    • 为什么 forwardWindowsAuthToken="false" ?似乎有必要在 IIS Express 上运行 processPath="dotnet"
    • 那么如果应用程序在本地 IIS 下运行,那么如何更正这些值呢?直接从 IIS 运行应用程序时没有“发布”。
    【解决方案4】:

    感谢大家的帮助,我使用的是模板 (https://github.com/MarkPieszak/aspnetcore-angular2-universal) 和命令

    dotnet publish
    

    下建了一个文件夹
    bin/Debug/netcoreapp1.1/publish
    

    将此路径设置为站点的根目录使其工作!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多