Search code examples
c#solid-principlesasp.net-core-3.0asp.net-core-3.1packagereference

PackageReference Microsoft.AspNetCore.App change of manner from core 2.2 to core 3 & 3.1


In the past, in my project I create a blank solution and add

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.5" />

in class library, so I was able to refer this class library project to an others and use what I needed. For example in my solution I had Core folder and Web folder. My web application started from "asp.net core web application" that was in Web folder and has reference to "Core" folder class libraries like core, data, services and ... .

Now with ASP.NET Core 3 I have problem with this approach, it causes an error; how can I implement this approach?

For example you can see NopCommerce approach in nop 4.2, its similar to mine. Sorry for my bad English.


Solution

  • I find solution. main problem was in IWebHostEnvironment that it solved by framework reference instead of package reference.

    You can add

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

    in <ItemGroup> ... </ItemGroup> and enjoy it.