释放模式下的大文件问题

时间:2019-08-21 14:26:02

标签: asp.net azure docker asp.net-core swagger

我正在在docker linux容器中运行的asp.net core中构建应用程序。我的应用程序在调试模式下运行良好,但是当我尝试在发布模式下运行它并邮递员运行时,出现错误,提示为“ 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。

1 个答案:

答案 0 :(得分:0)

此问题是已知的,并已深入讨论here

this评论中所述,其中包括以下对我有用的东西:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DocumentationFile>C:\Users\xyz\source\repos\sms-test\Web\Web.xml</DocumentationFile>
  </PropertyGroup>

  <PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>

我还看到代码段和您上面发布的错误消息之间的路径不匹配。您可能还需要检查一下。