Skip to content

Commit 400809f

Browse files
committed
Rely on AppContext.BaseDirectory as content root, rather than trying to get assume the path based on the solution folder, which doesn't work for many customers.
1 parent 627ec69 commit 400809f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,28 @@ private void SetContentRoot(IWebHostBuilder builder)
246246
return;
247247
}
248248

249-
var fromFile = File.Exists("MvcTestingAppManifest.json");
250-
var contentRoot = fromFile ? GetContentRootFromFile("MvcTestingAppManifest.json") : GetContentRootFromAssembly();
249+
string? contentRoot = null;
250+
if (File.Exists("MvcTestingAppManifest.json"))
251+
{
252+
var manifestContentRoot = GetContentRootFromFile("MvcTestingAppManifest.json");
253+
if (manifestContentRoot is not null && Directory.Exists(manifestContentRoot))
254+
{
255+
contentRoot = manifestContentRoot;
256+
}
257+
}
258+
259+
if (contentRoot is null)
260+
{
261+
contentRoot = GetContentRootFromAssembly();
262+
}
251263

252-
if (contentRoot != null && Directory.Exists(contentRoot))
264+
if (contentRoot is not null && Directory.Exists(contentRoot))
253265
{
254266
builder.UseContentRoot(contentRoot);
255267
}
256268
else
257269
{
258-
builder.UseSolutionRelativeContentRoot(typeof(TEntryPoint).Assembly.GetName().Name!);
270+
builder.UseContentRoot(AppContext.BaseDirectory);
259271
}
260272
}
261273

0 commit comments

Comments
 (0)