【发布时间】:2019-12-26 20:50:20
【问题描述】:
我正在构建一个在 docker linux 容器中运行的 asp.net 核心应用程序。我的应用程序在调试模式下运行良好,但是当我尝试在发布模式和邮递员下运行它时,我收到错误为“FileNotFoundException:找不到文件'/app/AuthorAdmin.Command.API.XML'”。
请在下面找到我的 startup.cs 文件:
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
{
Version = "v1",
Title = "Taxathand AuthorAdminAPI",
Description = "Taxathand AuthorAdminAPI",
TermsOfService = "None",
Contact = new Contact() { Name = "tax@hand Author", Email = "prteja@deloitte.com", Url = "" }
});
//Locate the XML file being generated by ASP.NET...
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML";
var xmlPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, xmlFile);
//... and tell Swagger to use those XML comments.
c.IncludeXmlComments(xmlPath);
});
我的项目文件代码如下:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>CommandStack\AuthorAdmin.Command.API\AuthorAdmin.Command.API.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
<OutputPath>bin\Debug\netcoreapp2.2\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>bin\Release\netcoreapp2.2\</OutputPath>
<DocumentationFile>bin\Release\netcoreapp2.2\AuthorAdmin.Command.API.xml</DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
我想在类似于调试模式的发布模式下访问 api。
【问题讨论】:
-
Azure App Service API gets FileNotFoundException: Could not find file 'D:\home\site\wwwroot\MyApi.xml when trying to start swagger 的可能重复项另外请检查可部署文件中的路径,因为我可以看到错误为“/app/AuthorAdmin.Command.API.XML”,但您的文件路径是
bin \Release\netcoreapp2.2\AuthorAdmin.Command.API.xml
标签: asp.net azure docker asp.net-core swagger