Mag*_*son 6 azure asp.net-web-api .net-core azure-web-app-service visual-studio-2017
更新 2:该文件未发布。那是错误的。但是,我无法弄清楚为什么我的一台计算机可以以正确的方式发布它而另一台在 Visual Studio 升级后却不能。
更新:在两台不同的计算机上运行相同的解决方案,其中 APIProject.xml 文件从一台计算机正确发布,但不是另一台计算机,现在只剩下一个差异。用于发布的计算机运行未更新版本的 Visual Studio 2017 Enterprise。15.5.2 不起作用而 15.4.2 起作用。
我收到此错误:
FileNotFoundException: 找不到文件“D:\home\site\wwwroot\APIProject.xml”。
该文件位于 bin\Debug\netcoreapp2.0 它在本地工作,但发布到 Azure App 服务时崩溃。
我正在发布到我创建的暂存槽,但尚未尝试生产。发布会替换目的地的所有文件。
这是我对 Swagger 的设置,但它曾经可以工作:)
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
// Register the Swagger generator, defining one or more Swagger documents
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
{
Version = "v1",
Title = "Ecommerce/Product API",
Description = "Handles API based shopping functionality",
TermsOfService = "Terms of service should be contracted with inidividually",
Contact = new Contact { Name = "Magnus", Email = "magnus@secret", Url = "" },
License = new License { Name = "Use under permission from our Group", Url = "http://aboutno" }
});
// Set the comments path for the Swagger JSON and UI.
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var xmlPath = Path.Combine(basePath, "APIProject.xml");
c.IncludeXmlComments(xmlPath);
});
}
Run Code Online (Sandbox Code Playgroud)
发生变化的是我在 Program.cs 中添加了“UseSetting”行以获取有关它为什么不启动的错误。在添加该行之前,我没有收到开发人员错误,只有最终用户错误页面。
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseApplicationInsights()
.UseSetting(WebHostDefaults.DetailedErrorsKey, "true")
.UseStartup<Startup>()
.Build();
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用调试模式发布。还尝试使用 Release 作为下面的一个答案,但没有区别。
我在另一台计算机上检查了代码并从那台计算机上发布了代码,所以这个问题对我来说变得更奇怪了!
Mik*_*ill 16
我的.Net Core 2.0应用程序在本地运行良好,但在部署到 Azure 时抛出了一个毫无意义的“启动应用程序时出错。 ”错误。
检查日志,原因是 Swagger 找不到特定的 .xml 文件(为什么错误消息不让我们知道?!)
解决方案是选择 Build 选项卡,将 Configuration 下拉列表更改为“Release”,然后勾选此框:
就是这样。
出于某种原因,默认情况下它被勾选(填充了 .xml 文件名)用于调试,而不是用于发布。
(叹。)
确保调试和发布模式下的 csproj 文件中存在等效块。我猜你正在发布发布模式。
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp2.0\APIProject.xml</DocumentationFile>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3775 次 |
| 最近记录: |