Я получаю сообщение об ошибке при попытке построить проект Azure Functions v2.Странно то, что это не всегда происходит.Я пробовал различные комбинации Visual Studio 2017 (15.9.3) и Visual Studio 2019 (Preview 1.1), а также сборку в DevOps Azure на агенте Hosted 2017 вместе с изменением Functions SDK между 1.0.22 и 1.0.23 и 1.0.24.
- Это ВСЕГДА терпит неудачу с этой ошибкой на DevOps Azure с v1.0.24.
- Это ВСЕГДА завершается успешно на VS 2019 с v1.0.24
- ВСЕГДА терпит неудачу с v1.0.22 как на VS 2017, так и на 2019
- Другие комбинации являются ударом или промахом независимо от того, терпят ли они неудачу.
Кажется, что-то похоже на этовопрос, на который не получен ответ: .NET Core и функции Azure - ошибка сборки System.Runtime 4.2.0.0
Вот ошибка:
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
FunctionsCore C:\Users\myusername\.nuget\packages\microsoft.net.sdk.functions\1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets 39
Вот мой файл .csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<AssemblyName>MyProject.FunctionsCore</AssemblyName>
<RootNamespace>MyProject.FunctionsCore</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
А вот некоторые сведения о слиянии:
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/myusername/.nuget/packages/microsoft.net.sdk.functions/1.0.24/tools/net46/
LOG: Initial PrivatePath = NULL
Calling assembly : Cacs.MyProject.FunctionsCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Users/myusername/.nuget/packages/microsoft.net.sdk.functions/1.0.24/tools/net46/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/myusername/.nuget/packages/microsoft.net.sdk.functions/1.0.24/tools/net46/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/myusername/.nuget/packages/microsoft.net.sdk.functions/1.0.24/tools/net46/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Users/myusername/.nuget/packages/microsoft.net.sdk.functions/1.0.24/tools/net46/System.Runtime/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Users/myusername/source/repos/MyProject/MyProject/FunctionsCore/bin/Debug/netcoreapp2.1/bin/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/myusername/source/repos/MyProject/MyProject/FunctionsCore/bin/Debug/netcoreapp2.1/bin/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/myusername/source/repos/MyProject/MyProject/FunctionsCore/bin/Debug/netcoreapp2.1/bin/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Users/myusername/source/repos/MyProject/MyProject/FunctionsCore/bin/Debug/netcoreapp2.1/bin/System.Runtime/System.Runtime.EXE.