1

I am building an application in asp.net core running in docker linux container. My application is running good in debug mode but when i tried to run it in release mode and postman it i am getting error as "FileNotFoundException: Could not find file '/app/AuthorAdmin.Command.API.XML'".

Please find my startup.cs file as below:

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);
});

My project file code is as follows:

<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>

I want to access api's in release mode similar to debug mode.

Ashish Kamble
  • 2,555
  • 3
  • 21
  • 29
  • Possible duplicate of [Azure App Service API gets FileNotFoundException: Could not find file 'D:\home\site\wwwroot\MyApi.xml when trying to start swagger](https://stackoverflow.com/questions/55300452/azure-app-service-api-gets-filenotfoundexception-could-not-find-file-d-home-s) Also please check the path in the deployables as i can see the error says "/app/AuthorAdmin.Command.API.XML" but yout file path is bin\Release\netcoreapp2.2\AuthorAdmin.Command.API.xml – Mohit Verma Aug 27 '19 at 09:14

2 Answers2

1

This issue is known and has been discussed in great depth here.

As mentioned in this comment, including the following worked for me:

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

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

I also see a path mismatch between the code snippet and the error message that you posted above. You might want to check that as well.

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30
0

These answers pointed me in the right direction. I removed the condition from the property group so that it would work the same, regardless of the build type (debug/release).

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

Would become:

<PropertyGroup>
    <DocumentationFile>C:\Users\xyz\source\repos\sms-test\Web\Web.xml</DocumentationFile>
</PropertyGroup>