【发布时间】:2019-07-31 13:09:59
【问题描述】:
我有一个 Azure Function v2 创建为 DotNet Core 库 (2.1),使用最新的 1.0.26 Microsoft.Net.Sdk.Functions NuGet 包。
我无法构建 Azure Functions,因为 GenerateFunctions 任务正在寻找 System.Runtime 的 4.2.1.0 版本。但是,没有该特定版本的 NuGet 包。
问题
谁在寻找 System.Runtime 4.2.1.0,我该如何解决?
这是失败的构建的诊断日志部分:
2>Target "_GenerateFunctionsPostBuild" in file "C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets":
2> Using "Move" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
2> Task "Move"
2> Task Parameter:SourceFiles=C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\NoSuchCompany.Demo.Service.AzureFunctions.pdb
2> Task Parameter:DestinationFiles=C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.pdb
2> Task Parameter:OverwriteReadOnlyFiles=True
2> Moving file from "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\NoSuchCompany.Demo.Service.AzureFunctions.pdb" to "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.pdb".
2> Done executing task "Move".
2> Using "GenerateFunctions" task from assembly "C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Functions.MSBuild.dll".
2> Task "GenerateFunctions"
2> Task Parameter:TargetPath=C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.dll
2> Task Parameter:OutputPath=C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\
2> Function generator path: 'C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\tools\net46\Microsoft.NET.Sdk.Functions.Generator.exe'
2> "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.dll " "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\ "
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : File name: 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : at System.Reflection.RuntimeAssembly.GetExportedTypes()
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : at MakeFunctionJson.FunctionJsonConverter.TryRun()
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : WRN: Assembly binding logging is turned OFF.
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Note: There is some performance penalty associated with assembly bind failure logging.
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Error generating functions metadata
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :
2> C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Metadata generation failed.
2> Done executing task "GenerateFunctions" -- FAILED.
2>Done building target "_GenerateFunctionsPostBuild" in project "Demo.Service.AzureFunctions.csproj" -- FAILED.
更新 1
如果我运行以下命令,我会得到完全相同的错误:
C:\Users\Chris.nuget\packages\microsoft.net.sdk.functions\1.0.26\tools\net46>Microsoft.NET.Sdk.Functions.Generator.exe "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.dll " "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\ "
我得到以下输出:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()
Error generating functions metadata
更新 2
我想知道为什么构建使用Microsoft.NET.Sdk.Functions.Generator 的网络框架版本,因为有一个netcore 版本。出于好奇,我用netcore版本试了一下:
C:\Users\Chris.nuget\packages\microsoft.net.sdk.functions\1.0.26\tools\netcoreapp2.1>dotnet Microsoft.NET.Sdk.Functions.Generator.dll "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.dll" "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1"
没有错误。我猜.net 4.6 版本有问题。你呢?
【问题讨论】:
标签: c# azure msbuild azure-functions