New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible Bug - System.ArgumentException : The content root '' does not exist #7063
Comments
Hello @rguthriemsft You might need to set the content root path explicitly with Beyond that, the docs repo primarily handles docs issues ... we aren't really staffed to handle support requests. You'd probably need to open this on the Home repo (https://github.com/aspnet/Home/issues) for help or try Stack Overflow. Certainly if you run into a docs problem that would have helped, please let us know so we can update the content. |
@rguthriemsft FWIW I have the exist same error, and google has lead me to the only other person on the planet who has seen the same error. In my case the Content root is also missing a I've followed the article which guardrex suggested, and in my case adding public class ProviderStateApiFactory : WebApplicationFactory<ProviderStateApi>
{
protected override IWebHostBuilder CreateWebHostBuilder()
{
return WebHost.CreateDefaultBuilder()
.UseStartup<ProviderStateApi>();
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseContentRoot(".");
base.ConfigureWebHost(builder);
}
} |
Found a simpler workaround. public class BlogAppFactory : WebApplicationFactory<Startup>
{
protected override IWebHostBuilder CreateWebHostBuilder()
{
return WebHost.CreateDefaultBuilder()
.UseStartup<TestStartup>();
}
} |
@maurei @mattfrear workaround works for me with Net Core 3.1. |
The workaround from @mattfrear works for me also with Net Core 3.1. |
I am seeing an issue when I try to create an integration test with a custom WebApplicationFactory. I get the error below but what is puzzling is the path is missing one folder in the path and I don't know where this value is coming from. It should be '/Users/richardguthrie/go/src/github.com/Azure-Samples/openhack-devops-team/apis/poi/tests/IntegrationTests'
The code is checked in at: https://github.com/Azure-Samples/openhack-devops-team/tree/unit_test3
Is this a bug or am I missing something when I try to init the webhost that would fix this? My intent is to spin up a server locally with in memory db to run the integration test. This happens when I run Debug Test from within VSCode using C# extension.
[xUnit.net 00:00:26.3698120] IntegrationTests.POIIntegrationTests.Get_EndpointsReturnSuccessAndCorrectContentType(url: "/api/poi/") [FAIL]
[xUnit.net 00:00:26.3715660] System.ArgumentException : The content root '/Users/richardguthrie/go/src/github.com/Azure-Samples/openhack-devops-team/apis/poi/IntegrationTests' does not exist.
[xUnit.net 00:00:26.3716860] Parameter name: contentRootPath
[xUnit.net 00:00:26.3732960] Stack Trace:
[xUnit.net 00:00:26.3754940] at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize(IHostingEnvironment hostingEnvironment, String contentRootPath, WebHostOptions options)
[xUnit.net 00:00:26.3756430] at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
[xUnit.net 00:00:26.3757000] at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
[xUnit.net 00:00:26.3758120] at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
[xUnit.net 00:00:26.3758790] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.CreateServer(IWebHostBuilder builder) [xUnit.net 00:00:26.3760500] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.EnsureServer()[xUnit.net 00:00:26.3761230] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.CreateDefaultClient(DelegatingHandler[] handlers) [xUnit.net 00:00:26.3762400] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory
1.CreateClientThe text was updated successfully, but these errors were encountered: