[英].NET Core 3.1 Transitive Reference Issue With Azure Function Class Library
I have a solution with 5 .NET Core 3.1 projects in Visual Studio 2019 16.4.3 with the following structure and references:我在 Visual Studio 2019 16.4.3 中有 5 个 .NET Core 3.1 项目的解决方案,其结构和参考如下:
MyProject.Core (Class Library) MyProject.Core(类库)
MyProject.Infrastructure (Class Library) MyProject.Infrastructure(类库)
MyProject.SharedKernel (Class Library) MyProject.SharedKernel(类库)
MyProject.Function (Azure Function v3 Class Library) MyProject.Function(Azure Function v3 类库)
MyProject.Web (ASP.NET Core 3.1) MyProject.Web (ASP.NET Core 3.1)
From MyProject.Web I am able to use the EnsureThat library with no issues because if references MyProject.SharedKernel which in turn has the reference to the EnsureThat NuGet package.从MyProject.Web 中,我可以毫无问题地使用 EnsureThat 库,因为如果引用MyProject.SharedKernel ,后者又引用了 EnsureThat NuGet 包。 For some reason, I am unable to do the same in the MyProject.Function project even though it has the exact same reference to MyProject.SharedKernel .
出于某种原因,我不能做,即使它具有完全相同的参考MyProject.SharedKernel的MyProject.Function项目相同。
Is there something about an azure function class library that prevents transitive references from working properly?是否存在阻止传递引用正常工作的 azure 函数类库? I would prefer not to have to also install the EnsureThat NuGet package in the MyProject.Function project directly.
我不想还直接在MyProject.Function项目中安装确保 NuGet 包。
It seems that references in .net core using VS 2019 are a little flaky.使用 VS 2019 的 .net core 中的引用似乎有点不稳定。 While having this issue Microsoft released EF Core 3.1.1.
在遇到此问题时,Microsoft 发布了 EF Core 3.1.1。 I decided to update the EF Core 3.1.0 package I was referencing to EF Core 3.1.1 using nuget.
我决定使用 nuget 更新我引用 EF Core 3.1.1 的 EF Core 3.1.0 包。 When I did this I started to get all kinds of errors around missing references.
当我这样做时,我开始遇到有关缺少引用的各种错误。 At this point, I believed something was wrong locally so I checked my code into Azure Dev Ops to see if our gated build would fail or not.
在这一点上,我认为本地出了点问题,所以我将代码检查到 Azure Dev Ops 中,看看我们的门控构建是否会失败。 IT DID NOT!
它没! At this point, I deleted all the code from my local machine and got the latest from Azure Dev Ops.
此时,我从本地机器上删除了所有代码,并从 Azure Dev Ops 获取了最新代码。 When I tried building it complained of a missing file "project.assets.json" and told me to do a "dotnet restore".
当我尝试构建它时抱怨缺少文件“project.assets.json”并告诉我进行“dotnet restore”。 I opened up the package manager and did just that.
我打开了包管理器并做到了。 Once it completed without issues all my references were fixed including my transitive reference issue with my azure function!
一旦它顺利完成,我的所有引用都被修复了,包括我的 azure 函数的传递引用问题!
Unfortunately, what you want is impossible.不幸的是,你想要的是不可能的。 This is no matter with VS 2019, the reason is this feature has not yet been implemented.
这与 VS 2019 无关,原因是此功能尚未实现。
Azure Function can not reference Class Library now. Azure Function 现在无法引用类库。 But you can reference the dll file of your class library, the means you can make an output in your SharedKernel Class library and get the output in your azure function.
但是你可以引用你的类库的dll文件,这意味着你可以在你的SharedKernel类库中输出并在你的azure函数中获得输出。
First, build the SharedKernel Class library, then reference to the dll of this.首先构建SharedKernel类库,然后引用this的dll。
In your azure function:在你的天蓝色函数中:
By the way, you can only use the output, using Ensure That
package is still impossible.顺便说一句,你只能使用输出,使用
Ensure That
包仍然是不可能的。 You need to install it in your azure function.您需要将其安装在您的 azure 函数中。
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.