Reputation: 778
I'm using ASP.NET Core 5
I want to access IWebHostEnvironment
in classlib but when I try to install Microsoft.AspNetCore.App
in nuget I get this warning:
A PackageReference to Microsoft.AspNetCore.App is not necessary when targeting .NET Core 3.0 or higher
how do I do to access IWebHostEnvironment
in .NET 5 classlib ?
Upvotes: 12
Views: 5284
Reputation: 21656
Double click the Classlibrary project to open the <ClassLibraryName>.csproj
file, then, add the following code:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Then, you can use IWebHostEnvironment in the Classlibrary, the result as below:
Upvotes: 24