From 21dacc2e8e169e90fc38c7a8b7dcb5ac81f335e2 Mon Sep 17 00:00:00 2001 From: Charlie Chu Date: Fri, 11 Nov 2016 16:10:48 +0800 Subject: [PATCH] Solve cross platform issue fix issue - "Unhandled Exception: System.IO.FileNotFoundException" run on Mac --- aspnetcore/tutorials/web-api-help-pages-using-swagger.md | 2 +- .../sample/src/TodoApi/Startup.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/aspnetcore/tutorials/web-api-help-pages-using-swagger.md b/aspnetcore/tutorials/web-api-help-pages-using-swagger.md index d12f0ba27a..dd62c57803 100644 --- a/aspnetcore/tutorials/web-api-help-pages-using-swagger.md +++ b/aspnetcore/tutorials/web-api-help-pages-using-swagger.md @@ -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. diff --git a/aspnetcore/tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs b/aspnetcore/tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs index 7237294fe3..ac032ec064 100644 --- a/aspnetcore/tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs +++ b/aspnetcore/tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs @@ -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); }); }