WebApplicationFactory throws error that contentRootPath does not exist in ASP.NET Core integration test

后端 未结 6 1232
醉梦人生
醉梦人生 2021-02-13 18:52

I have a ASP.NET Core project with some simple Razor pages and a Web API controller.

I\'m using Clean Architecture as a starting point. I\'ve renamed the project names,

6条回答
  •  一整个雨季
    2021-02-13 19:34

    If you are using ReSharper it may well be related to the version. We found the issue with version 2018.3. Adding UseSolutionRelativeContentRoot resolved it.

        protected override void ConfigureWebHost(IWebHostBuilder builder)
        {
                builder.UseKestrel()
                .UseSolutionRelativeContentRoot("")
                .ConfigureAppConfiguration((context, configBuilder) =>
                {
                  // Config code
                })
                .UseStartup();
        }
    

提交回复
热议问题