ASP.NET Core 3.1 Get wwwroot Path In Separate Class Library

The link by poke about seeing the documentation is an answer but since links can die, here is the solution.

As of .NET Core 3.0, projects using the Microsoft.NET.Sdk.Web MSBuild SDK implicitly reference the shared framework. Projects using the Microsoft.NET.Sdk or Microsoft.NET.Sdk.Razor SDK must reference ASP.NET Core to use ASP.NET Core APIs in the shared framework.

In you project file, add this...

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

Tags:

Asp.Net Core