gpt4 book ai didi

azure - Azure 函数升级错误

转载 作者:行者123 更新时间:2023-12-02 08:04:23 25 4
gpt4 key购买 nike

我们在尝试升级 Azure 函数项目时收到此错误。这是我们得到的日志文件

恢复包

C:\Users\User\Source\Repos\xxx_FileService\xxx.AzureFunctions\xxx.AzureFunctions\SE.AzureFunctions.csproj...
Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.7 requires Newtonsoft.Json (= 9.0.1) but version Newtonsoft.Json 10.0.3 was resolved.
Detected package downgrade: Microsoft.Azure.WebJobs from 2.1.0-beta4 to 2.1.0-beta1. Reference the package directly from the project to select a different version.
xxx.AzureFunctions -> Microsoft.NET.Sdk.Functions 1.0.7 -> Microsoft.Azure.WebJobs (= 2.1.0-beta4)
xxx.AzureFunctions -> Microsoft.Azure.WebJobs (>= 2.1.0-beta1)
Detected package downgrade: Microsoft.Azure.WebJobs.Extensions from 2.1.0-beta4 to 2.1.0-beta1. Reference the package directly from the project to select a different version.
xxx.AzureFunctions -> Microsoft.NET.Sdk.Functions 1.0.7 -> Microsoft.Azure.WebJobs.Extensions (= 2.1.0-beta4)
xxx.AzureFunctions -> Microsoft.Azure.WebJobs.Extensions (>= 2.1.0-beta1)
Detected package downgrade: Microsoft.Azure.WebJobs.Extensions.Http from 1.0.0-beta4 to 1.0.0-beta1. Reference the package directly from the project to select a different version.
xxx.AzureFunctions -> Microsoft.NET.Sdk.Functions 1.0.7 -> Microsoft.Azure.WebJobs.Extensions.Http (= 1.0.0-beta4)
xxx.AzureFunctions -> Microsoft.Azure.WebJobs.Extensions.Http (>= 1.0.0-beta1)
Package restore failed. Rolling back package changes for 'SE.AzureFunctions'.
Time Elapsed: 00:00:00.3832626
========== Finished =========

CS.PROJ 中的包引用

<Project Sdk="Microsoft.NET.Sdk">   <PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AssemblyName>SE.AzureFunctions</AssemblyName>
<RootNamespace>SE.AzureFunctions</RootNamespace> </PropertyGroup> <ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs" Version="2.1.0-beta1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="2.1.0-beta1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.1.0-beta1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.0-alpha6" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004" /> </ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" /> </ItemGroup> <ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </ItemGroup> </Project>

最佳答案

我将尽力向您提供您遇到挑战的背景,并为您提出解决方案。

问题背景:

您遇到此错误的原因有两个:

  1. Microsoft 降级了以下软件包(因为我确信您收到的错误消息可能已经提示了您):

    a. Microsoft.Azure.WebJobs 从 2.1.0-beta42.1.0-beta1

    b. Microsoft.Azure.WebJobs.Extensions.Http 从 1.0.0-beta4 到 1.0.0-beta1

  2. .NET Core 2.0.0 Preview 2 中 - 降级警告已变为错误。这意味着它们被配置为将警告 NU1605 视为错误。这并没有在他们的release notes中公开。 ,但是如果您查看从 .Net Core 2.0.0 Preview 2 模板化的任何项目的属性页(就像我怀疑您的项目一样),您会注意到在 Build 项目属性下表中,警告 NU1605 现在被视为错误(请参阅将警告视为错误部分)。现在让我们固定住它,因为我们需要深入研究下面建议的解决方案中的项目属性页面。

建议的解决方案(请注意,这是一种解决方法!):

是的,您已经猜到了,您需要将项目配置为NU1605警告视为错误。为此,请按照下列步骤操作:

  1. 打开项目的属性页面,
  2. 转到构建属性表
  3. 向下滚动到将警告视为错误部分,然后清除特定警告单选框部分中的 NU1605 值。 (参见下面的屏幕截图)

clear NU1605 warning as an error

  • 保存并重建您的项目(当您保存项目属性页更改时,Nuget 实际上可能会尝试自动恢复包 --- 如果它不这样做或者恢复“失败”,则只需重建项目即可应该没问题)
  • 结论

    我确信 Microsoft 有其原因将降级警告 NU1605 强制执行为错误,因此不要将禁用此警告作为错误的建议视为错误全面认可这一策略;相反,将此建议视为解决我们在选择使用预发布测试版代码时必然会遇到的问题的解决方法。

    我的希望是,在最终候选版本发布时,大多数此类依赖性问题都已得到解决,并且不需要此类变通办法,但与此同时,为了保持您的 alpha/beta/实验性开发展望 future ,这项工作应该可以解决。

    希望这对您有所帮助并祝您编码愉快(哦,是的,新年快乐!)

    关于azure - Azure 函数升级错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47773836/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com