I'm trying to create an extension method to register some routes in an external library using C# .NET 6.
I can'f find a way to do it because i cannot reference Microsoft.AspNetCore.App.Ref where the WebApplication class is defined.
Has anyone encountered this problem and found a solution?
If I undertand your problem correctly:
.csproj file starts with<Project Sdk="Microsoft.NET.Sdk">
WebApplication likepublic static class SomeModule
{
public static void DoSomething(this WebApplication webApplication)
{
// stuff
}
}
As you can't reference Microsoft.AspNetCore.App.Ref you can try with adding a framework reference to your project as per Use the ASP.NET Core shared framework article.
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<!--Rest of your project stuff-->
</Project>
and this way you're good to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With