Solve cross platform issue

fix issue - "Unhandled Exception: System.IO.FileNotFoundException" run
on Mac
pull/2149/head
Charlie Chu 2016-11-11 16:10:48 +08:00
parent 401228c695
commit 21dacc2e8e
2 changed files with 3 additions and 2 deletions

View File

@ -227,7 +227,7 @@ Configure Swagger to use the generated XML file.
> [!NOTE]
> For Linux or non-Windows operating systems, file names and paths can be case sensitive. So `ToDoApi.XML` would be found on Windows but not CentOS for example.
[!code-csharp[Main](../tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs?name=snippet_Configure&highlight=29,32)]
[!code-csharp[Main](../tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs?name=snippet_Configure&highlight=29,33)]
In the code above, ApplicationBasePath gets the base path of the app, which is needed to set the full path to the XML comments. `TodoApi.xml` only works for this example, the name of the generated XML comments file is based on the name of your application.

View File

@ -45,7 +45,8 @@ namespace TodoApi
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
//Set the comments path for the swagger json and ui.
options.IncludeXmlComments(basePath + "\\TodoApi.xml");
var xmlPath = Path.Combine(basePath, "TodoApi.xml");
options.IncludeXmlComments(xmlPath);
});
}