ASP.NET 5 RC2版本中有重大更改:
dnvm
和dnu
命令行,它们被替换为dotnet
我正在尝试部署生成的文件dotnet publish
。文件结构与RC1不同。我在事件查看器中看到以下错误:
Failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%', Error Code = '0x80070002'.
在中提到了这些环境变量web.config
,该变量取自官方的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发布文档中提及。
来自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.configs:src\ProjectName\wwwroot\web.config
和src\ProjectName\web.config
。如果你没有后者,VS2015发布将会为您生成一个与%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
必须使用以下内容替换on上的值。如果已配置,该dotnet publish-iis
命令将为您进行替换(请参见下文)。
<aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
如果要从RC1迁移,则将http绑定目录也更改为Project根文件夹,而不是wwwroot。范例:从C:\inetpub\ProjectName\wwwroot
到C:\inetpub\ProjectName
。
要配置 publish-iis
为执行自动替换,请将此代码段添加到您的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。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句