tntwist / NL.Serverless.AspNetCore

Hosting an AspNet Core App inside an Azure Function V3 HTTP Trigger
MIT License
20 stars 3 forks source link

Startup fails because it cannot locate solution? #49

Closed mauve closed 3 years ago

mauve commented 3 years ago

Running in .net5 dotnet-isolated worker in Azure after deploying it fails with the following stack trace (however works like a charm locally):

2021-08-19T09:39:52.644 [Information] Unhandled exception. System.InvalidOperationException: Solution root could not be located using application root C:\home\site\wwwroot\.

Full stack trace:

2021-08-19T09:39:52.644 [Information] Unhandled exception. System.InvalidOperationException: Solution root could not be located using application root C:\home\site\wwwroot\.
2021-08-19T09:39:52.644 [Information] at Microsoft.AspNetCore.TestHost.WebHostBuilderExtensions.UseSolutionRelativeContentRoot(IWebHostBuilder builder, String solutionRelativePath, String applicationBasePath, String solutionName)
2021-08-19T09:39:52.644 [Information] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.SetContentRoot(IWebHostBuilder builder)
2021-08-19T09:39:52.645 [Information] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
2021-08-19T09:39:52.645 [Information] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
2021-08-19T09:39:52.646 [Information] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers)
2021-08-19T09:39:52.646 [Information] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
2021-08-19T09:39:52.646 [Information] at NL.Serverless.AspNetCore.AzureFunctionsHost.HostBuilderExtensions.ConfigureWebAppFunctionHost[TStartup](IHostBuilder builder)
2021-08-19T09:39:52.646 [Information] at api.FunctionApp.Program.Main(String[] args) in /home/vsts/work/1/s/api/src/api.FunctionApp/Program.cs:line 11
2021-08-19T09:39:52.646 [Information] at api.FunctionApp.Program.<Main>(String[] args)
tntwist commented 3 years ago

@mauve I could find a way to fix this. You need to create an application setting within the function app that points to the content root for the web app:

image

The name of the setting should be ASPNETCORE_TEST_CONTENTROOT_NAME_OF_YOUR_WEBAPP_ASSEMBLY and point the value to C:\home\site\wwwroot\

I leave the issue open until I updated the readme.

tntwist commented 3 years ago

Closed with v5.1.0