diff --git a/src/Microsoft.AspNetCore.TestHost/WebHostBuilderExtensions.cs b/src/Microsoft.AspNetCore.TestHost/WebHostBuilderExtensions.cs index 4c45c9feb9..770ac3d3b1 100644 --- a/src/Microsoft.AspNetCore.TestHost/WebHostBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.TestHost/WebHostBuilderExtensions.cs @@ -53,13 +53,25 @@ namespace Microsoft.AspNetCore.TestHost this IWebHostBuilder builder, string solutionRelativePath, string solutionName = "*.sln") + { + return builder.UseSolutionRelativeContentRoot(solutionRelativePath, AppContext.BaseDirectory, solutionName); + } + + public static IWebHostBuilder UseSolutionRelativeContentRoot( + this IWebHostBuilder builder, + string solutionRelativePath, + string applicationBasePath, + string solutionName = "*.sln") { if (solutionRelativePath == null) { throw new ArgumentNullException(nameof(solutionRelativePath)); } - var applicationBasePath = AppContext.BaseDirectory; + if (applicationBasePath == null) + { + throw new ArgumentNullException(nameof(applicationBasePath)); + } var directoryInfo = new DirectoryInfo(applicationBasePath); do