title: Azure App Service API gets FileNotFoundException: Could not find file 'D:\home\site\wwwroot\MyApi.xml when trying to start swagger
body: <p>I am working on an ASP.NET Core 2.2 API deployed to Azure App Services. I am deploying to a DEV slot.</p>
  
  <p>I am using Swagger, which works fine on my localhost, but when I go to the URL of by DEV slot and use /swagger, I get the error;</p>
  
  <pre><code>FileNotFoundException: Could not find file 'D:\home\site\wwwroot\MyApi.xml 
  </code></pre>
  
  <p>I have the following in my *.csproj file;</p>
  
  <pre><code>&lt;PropertyGroup&gt;
    &lt;GenerateDocumentationFile&gt;true&lt;/GenerateDocumentationFile&gt;
  &lt;/PropertyGroup&gt;  
  </code></pre>
  
  <p>And when I go to Kudu for the DEV slot, I can see the MyApi.xml file in the /site/wwwroot folder. If I edit it in Kudu, I can see that the content is as expected.</p>
  
  <p>In my project's Startup.cs class --> Configure method, I have;</p>
  
  <pre><code>app.UseStaticFiles(); 
  </code></pre>
  
  <p>This is similar to the SO post <a href="https://stackoverflow.com/questions/47919553/azure-app-service-cant-start-because-it-cant-find-swagger-documentation-xml-us">here</a> but in that post, the file was not actually showing up in wwwroot, whereas in my case, it does.</p>
  
  <p>The API otherwise works correctly in that I can use Postman to test all of the APIs endpoints in the DEV slot. It is just that when I try to access DEV slot URL + /swagger from Chrome, I get the FileNotFound exception.</p>
  
  <p>My Startup.cs --> ConfigureServices method has the following;</p>
  
  <pre><code>services.AddSwaggerGen(
      options =&gt;
      {
          // integrate xml comments
          options.IncludeXmlComments(XmlCommentsFilePath);
      });
  </code></pre>
  
  <p>and the XmlCommentsFilePath method is below;</p>
  
  <pre><code>private static string XmlCommentsFilePath
  {
      get
      {
          var basePath = PlatformServices.Default.Application.ApplicationBasePath;
          var fileName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name + ".xml";
          return Path.Combine(basePath, fileName);
      }
  }
  </code></pre>
  
  <p>I assume that the Swagger setup is correct since it works locally and the error I get when deployed to the DEV slot is the FileNotFound pointing to D:\home\site\wwwroot\MyApi.xml where that file <strong>actually does exist</strong> according to Kudu for that slot.</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I also tried the recommendation for ASP.NET 2.2 in <a href="https://stackoverflow.com/questions/37968322/xml-comments-file-could-not-be-found-swagger">this SO link</a> with no luck.</p>
  
  <p>What am I missing here? </p>