找出它为什么不起作用的最佳方法是在 Visual Studio 中打开诊断日志,然后进行构建。
然后,在你构建之后,你可以搜索单词“extensions.json”
这将是这样开始的:
2> Task "GenerateFunctionsExtensionsMetadata"
2> Task Parameter:SourcePath=F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin
2> Task Parameter:OutputPath=F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin
2> Extensions generator working directory: 'C:\Users\jsgou\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.8\tools\net46\..\netstandard2.0\generator'
2> Extensions generator path: 'dotnet'
2> Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.Console.dll "F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin" "F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin\extensions.json"
然后,您可能会发现它无法正常工作的实际错误:
2> HBTI.ServiceTech.AzureFunctions.dll
2> Resolving assembly: 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
2> Assembly 'System.Runtime' loaded.
2> Resolving assembly: 'Microsoft.Azure.Functions.Extensions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f655f4c90a0eae19'
2> Assembly 'Microsoft.Azure.Functions.Extensions' loaded from 'F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin\Microsoft.Azure.Functions.Extensions.dll'.
2> Resolving assembly: 'Microsoft.Azure.WebJobs.Host, Version=3.0.18.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
2> Assembly 'Microsoft.Azure.WebJobs.Host' loaded from 'F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin\Microsoft.Azure.WebJobs.Host.dll'.
2> Resolving assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
2> Resolving assembly: 'Microsoft.AspNetCore.Mvc.Core, Culture=neutral, PublicKeyToken=null'
2> Cannot load 'Microsoft.AspNetCore.Mvc.Core'. Aborting assembly resolution.
2> Unable to find fallback for assembly 'Microsoft.AspNetCore.Mvc.Core'. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Core, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
2> File name: 'Microsoft.AspNetCore.Mvc.Core, Culture=neutral, PublicKeyToken=null'
2> at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
2> at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
2> at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, StackCrawlMark& stackMark, IntPtr pPrivHostBinder)
2> at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, StackCrawlMark& stackMark)
2> at System.Reflection.Assembly.Load(String assemblyString)
2> at ExtensionsMetadataGenerator.Console.Program.AssemblyLoader.<>c__DisplayClass1_0.<Initialize>b__0(Object sender, ResolveEventArgs args) in d:\a\1\s\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\Program.cs:line 78
2>
2>
2> Could not evaluate 'HBTI.ServiceTech.AzureFunctions.dll' for extension metadata. If this assembly contains a Functions extension, ensure that all dependent assemblies exist in 'F:\git\clients\hbti\Portal\hbti-web-master\HBTI.ServiceTech.AzureFunctions\bin\Debug\netcoreapp3.1\bin'. If this assembly does not contain any Functions extensions, this message can be ignored. Exception message: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
在这种情况下,我的解决方案是简单地制作我自己的 extensions.json 并将其放入 bin 文件夹中: