我的目标是一个基本库,该库将由多个其他服务API使用。在.NET 6中,您的Web应用程序使用 sdk =“ Microsoft.net.sdk.web”
需要'输入点'(即静态MAIN方法或program.cs)。基本库不需要输入点,因此我将 sdk =“ Microsoft.net.sdk”设置。
接下来,我需要访问“ microsoft.aspnetcore.routing”(6.0.x)。 Nuget仅具有2.xx版本6.xx版本,似乎仅作为Microsoft.aspnetcore.app.ref软件包的一部分可用。但是,它在Nuget上指出,这不是用于直接包装参考。
我无法更改我的SDK,因为我的库需要一个入口点,并且无法获得与.NET 6的路由版本。
我如何在基本库中访问路由?
My goal is a base library that will be used by multiple other service APIs. In .NET 6, your web apps that use SDK="Microsoft.NET.SDK.Web"
require an 'entry point' (i.e. static main method, or Program.cs). A base library doesn't need an entry point, so I instead set the SDK="Microsoft.NET.SDK"
.
Next, I need access to "Microsoft.AspNetCore.Routing" (6.0.x). NuGet only has up to version 2.x.x. Version 6.x.x seems to only be available as part of the Microsoft.AspNetCore.App.Ref package. However, it states on nuget that this is not for direct package references.
I can't change my SDK because my library needs an entry point, and I can't get a version of Routing that matches .NET 6.
How do I get access to Routing in a base library?
发布评论
评论(1)
我在这里找到答案:
您可以添加一个框架参考,就像一个一样软件包参考除外,您可以指定Web框架。
I found the answer here:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-6.0&tabs=visual-studio
You can add a framework reference, which is like a package reference except you can specify the web framework.