gpt4 book ai didi

asp.net-core - dotnetpublish-iis 在错误的位置寻找 web.config

转载 作者:行者123 更新时间:2023-12-01 18:40:24 25 4
gpt4 key购买 nike

我无法正确运行 dotnetpublish-iis

要发布我正在使用的项目:

dotnet publish ./src/RetailGuardian.Web/ -o ./code_drop/RetailGuardian.Web --runtime dnet452

我已经在我的 project.json 中设置了一个发布后脚本:

"scripts": {
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
}

初始发布工作正常,并按预期将代码放置在 code_drop 目录中(这是我在 RC1 中部署的内容,并且工作正常)。但是,当尝试查找 web.config 时,publish-iis 似乎不使用输出路径。这是运行时的输出:

Configuring the following project for use with IIS: './code_drop/RetailGuardian.Web'
No web.config found. Creating './code_drop/RetailGuardian.Web\web.config'
Could not find a part of the path 'G:\Projects\retailguardian\src\RetailGuardian.Web\code_drop\RetailGuardian.Web\web.config'.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'G:\Projects\retailguardian\src\RetailGuardian.Web\code_drop\RetailGuardian.Web\web.config'.
at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32
bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Microsoft.AspNetCore.Server.IISIntegration.Tools.PublishIISCommand.Run()
at Microsoft.AspNetCore.Server.IISIntegration.Tools.Program.<>c__DisplayClass0_0.<Main>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.AspNetCore.Server.IISIntegration.Tools.Program.Main(String[] args)
publish: Published to ./code_drop/RetailGuardian.Web
Published 1/1 projects successfully

因此它尝试使用 G:\Projects\retailguardian\src\RetailGuardian.Web\code_drop\RetailGuardian.Web\web.config 这是源目录,而不是 G:\Projects\retailguardian\code_drop\RetailGuardian.Web\web.config 这是发布输出的位置。

(奇怪的是,它还报告发布成功,即使发布后失败)

最佳答案

这似乎是一个错误,其中 dotnet 命令解析相对路径,然后更改当前目录以调用尝试再次解析路径的工具,但现在它相对于不同的文件夹解析它,因此最终路径不同。感谢您报告此问题 - 我在 cli 存储库中提出了一个问题:https://github.com/dotnet/cli/issues/3528

可能的解决方法:

  • 发布时使用绝对路径作为输出路径
  • 从项目文件夹发布

关于asp.net-core - dotnetpublish-iis 在错误的位置寻找 web.config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37773621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com