我直接从门户创建了一个新的C#函数(版本~1,http触发器模板),并添加了nuget依赖项,如下所示:
{
"frameworks": {
"net46":{
"dependencies": {
"Google.Apis" : "1.34.0"
}
}
}
}这是相关的project.json.lock文件:
{
"version": 2,
"targets": {
".NETFramework,Version=v4.6": {
"Google.Apis/1.34.0": {
"type": "package",
"dependencies": {
"Google.Apis.Core": "1.34.0",
"Newtonsoft.Json": "10.0.2",
"System.Net.Http": "4.3.1"
},
"compile": {
"lib/net45/Google.Apis.PlatformServices.dll": {},
"lib/net45/Google.Apis.dll": {}
},
"runtime": {
"lib/net45/Google.Apis.PlatformServices.dll": {},
"lib/net45/Google.Apis.dll": {}
}
},
"Google.Apis.Core/1.34.0": {
"type": "package",
"dependencies": {
"Newtonsoft.Json": "10.0.2",
"System.Net.Http": "4.3.1"
},
"compile": {
"lib/net45/Google.Apis.Core.dll": {}
},
"runtime": {
"lib/net45/Google.Apis.Core.dll": {}
}
},
"Newtonsoft.Json/10.0.2": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.Net.Http/4.3.1": {
"type": "package",
"dependencies": {
"System.Security.Cryptography.X509Certificates": "4.3.0"
},
"frameworkAssemblies": [
"System",
"System.Core",
"mscorlib"
],
"compile": {
"ref/net46/System.Net.Http.dll": {}
},
"runtime": {
"lib/net46/System.Net.Http.dll": {}
},
"runtimeTargets": {
"runtimes/win/lib/net46/System.Net.Http.dll": {
"assetType": "runtime",
"rid": "win"
}
}
},
"System.Security.Cryptography.Algorithms/4.3.0": {
"type": "package",
"dependencies": {
"System.Security.Cryptography.Primitives": "4.3.0"
},
"frameworkAssemblies": [
"System.Core",
"mscorlib"
],
"compile": {
"ref/net46/System.Security.Cryptography.Algorithms.dll": {}
},
"runtime": {
"lib/net46/System.Security.Cryptography.Algorithms.dll": {}
},
"runtimeTargets": {
"runtimes/win/lib/net46/System.Security.Cryptography.Algorithms.dll": {
"assetType": "runtime",
"rid": "win"
}
}
},
"System.Security.Cryptography.Encoding/4.3.0": {
"type": "package",
"frameworkAssemblies": [
"System",
"mscorlib"
],
"compile": {
"ref/net46/System.Security.Cryptography.Encoding.dll": {}
},
"runtime": {
"lib/net46/System.Security.Cryptography.Encoding.dll": {}
},
"runtimeTargets": {
"runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll": {
"assetType": "runtime",
"rid": "unix"
},
"runtimes/win/lib/net46/System.Security.Cryptography.Encoding.dll": {
"assetType": "runtime",
"rid": "win"
}
}
},
"System.Security.Cryptography.Primitives/4.3.0": {
"type": "package",
"frameworkAssemblies": [
"mscorlib"
],
"compile": {
"ref/net46/System.Security.Cryptography.Primitives.dll": {}
},
"runtime": {
"lib/net46/System.Security.Cryptography.Primitives.dll": {}
}
},
"System.Security.Cryptography.X509Certificates/4.3.0": {
"type": "package",
"dependencies": {
"System.Security.Cryptography.Algorithms": "4.3.0",
"System.Security.Cryptography.Encoding": "4.3.0"
},
"frameworkAssemblies": [
"System",
"System.Core",
"mscorlib"
],
"compile": {
"ref/net46/System.Security.Cryptography.X509Certificates.dll": {}
},
"runtime": {
"lib/net46/System.Security.Cryptography.X509Certificates.dll": {}
},
"runtimeTargets": {
"runtimes/win/lib/net46/System.Security.Cryptography.X509Certificates.dll": {
"assetType": "runtime",
"rid": "win"
}
}
}
}
},
"libraries": {
"Google.Apis/1.34.0": {
"sha512": "V8Ng2gtvdgTeQvF5TtrFeFsg/YnQoas/I/b0Vg/NhKjpSo/v+i+71j7Al5kYZAADGYi0yVVWuBgHjHa4sE0o8g==",
"type": "package",
"path": "google.apis/1.34.0",
"files": [
"google.apis.1.34.0.nupkg.sha512",
"google.apis.nuspec",
"lib/net45/Google.Apis.PlatformServices.dll",
"lib/net45/Google.Apis.dll",
"lib/net45/Google.Apis.pdb",
"lib/net45/Google.Apis.xml",
"lib/netstandard1.3/Google.Apis.dll",
"lib/netstandard1.3/Google.Apis.pdb",
"lib/netstandard1.3/Google.Apis.xml"
]
},
"Google.Apis.Core/1.34.0": {
"sha512": "a8KvNrdkRKqyVSsUtxc0LcuVN78bsaRNyw4eCA1BBpRVIShsZODrNV8Lv/E/T2h4rRGdgRXB2wJ7ZSs1CLCjdw==",
"type": "package",
"path": "google.apis.core/1.34.0",
"files": [
"google.apis.core.1.34.0.nupkg.sha512",
"google.apis.core.nuspec",
"lib/net45/Google.Apis.Core.dll",
"lib/net45/Google.Apis.Core.pdb",
"lib/net45/Google.Apis.Core.xml",
"lib/netstandard1.3/Google.Apis.Core.dll",
"lib/netstandard1.3/Google.Apis.Core.pdb",
"lib/netstandard1.3/Google.Apis.Core.xml"
]
},
"Newtonsoft.Json/10.0.2": {
"sha512": "iwElSU2IXmwGvytJsezyDML2ZWDkG2JzTYzlU/BNlmzMdlmRvbnwITsGGY74gwVEpDli1UdOLkMT7/3jxWvXzA==",
"type": "package",
"path": "newtonsoft.json/10.0.2",
"files": [
"LICENSE.md",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netstandard1.0/Newtonsoft.Json.dll",
"lib/netstandard1.0/Newtonsoft.Json.xml",
"lib/netstandard1.3/Newtonsoft.Json.dll",
"lib/netstandard1.3/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+win8+wpa81+wp8/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+win8+wpa81+wp8/Newtonsoft.Json.xml",
"lib/portable-net45+win8+wpa81+wp8/Newtonsoft.Json.dll",
"lib/portable-net45+win8+wpa81+wp8/Newtonsoft.Json.xml",
"newtonsoft.json.10.0.2.nupkg.sha512",
"newtonsoft.json.nuspec",
"tools/install.ps1"
]
},
"System.Net.Http/4.3.1": {
"sha512": "UrTyRczM3ZvNk6oetBuwlu67MFKKRva+r7bw4JDVZ6Y2IukyZ24td5ppsieu/4yZlogVAIuZul9GIQ3hoiz0yA==",
"type": "package",
"path": "system.net.http/4.3.1",
"files": [
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/Xamarinmac20/_._",
"lib/monoandroid10/_._",
"lib/monotouch10/_._",
"lib/net45/_._",
"lib/net46/System.Net.Http.dll",
"lib/portable-net45+win8+wpa81/_._",
"lib/win8/_._",
"lib/wpa81/_._",
"lib/xamarinios10/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/Xamarinmac20/_._",
"ref/monoandroid10/_._",
"ref/monotouch10/_._",
"ref/net45/_._",
"ref/net46/System.Net.Http.dll",
"ref/net46/System.Net.Http.xml",
"ref/net46/de/System.Net.Http.xml",
"ref/net46/es/System.Net.Http.xml",
"ref/net46/fr/System.Net.Http.xml",
"ref/net46/it/System.Net.Http.xml",
"ref/net46/ja/System.Net.Http.xml",
"ref/net46/ko/System.Net.Http.xml",
"ref/net46/ru/System.Net.Http.xml",
"ref/net46/zh-hans/System.Net.Http.xml",
"ref/net46/zh-hant/System.Net.Http.xml",
"ref/netcore50/System.Net.Http.dll",
"ref/netcore50/System.Net.Http.xml",
"ref/netcore50/de/System.Net.Http.xml",
"ref/netcore50/es/System.Net.Http.xml",
"ref/netcore50/fr/System.Net.Http.xml",
"ref/netcore50/it/System.Net.Http.xml",
"ref/netcore50/ja/System.Net.Http.xml",
"ref/netcore50/ko/System.Net.Http.xml",
"ref/netcore50/ru/System.Net.Http.xml",
"ref/netcore50/zh-hans/System.Net.Http.xml",
"ref/netcore50/zh-hant/System.Net.Http.xml",
"ref/netstandard1.1/System.Net.Http.dll",
"ref/netstandard1.1/System.Net.Http.xml",
"ref/netstandard1.1/de/System.Net.Http.xml",
"ref/netstandard1.1/es/System.Net.Http.xml",
"ref/netstandard1.1/fr/System.Net.Http.xml",
"ref/netstandard1.1/it/System.Net.Http.xml",
"ref/netstandard1.1/ja/System.Net.Http.xml",
"ref/netstandard1.1/ko/System.Net.Http.xml",
"ref/netstandard1.1/ru/System.Net.Http.xml",
"ref/netstandard1.1/zh-hans/System.Net.Http.xml",
"ref/netstandard1.1/zh-hant/System.Net.Http.xml",
"ref/netstandard1.3/System.Net.Http.dll",
"ref/netstandard1.3/System.Net.Http.xml",
"ref/netstandard1.3/de/System.Net.Http.xml",
"ref/netstandard1.3/es/System.Net.Http.xml",
"ref/netstandard1.3/fr/System.Net.Http.xml",
"ref/netstandard1.3/it/System.Net.Http.xml",
"ref/netstandard1.3/ja/System.Net.Http.xml",
"ref/netstandard1.3/ko/System.Net.Http.xml",
"ref/netstandard1.3/ru/System.Net.Http.xml",
"ref/netstandard1.3/zh-hans/System.Net.Http.xml",
"ref/netstandard1.3/zh-hant/System.Net.Http.xml",
"ref/portable-net45+win8+wpa81/_._",
"ref/win8/_._",
"ref/wpa81/_._",
"ref/xamarinios10/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"runtimes/unix/lib/netstandard1.6/System.Net.Http.dll",
"runtimes/win/lib/net46/System.Net.Http.dll",
"runtimes/win/lib/netcore50/System.Net.Http.dll",
"runtimes/win/lib/netstandard1.3/System.Net.Http.dll",
"system.net.http.4.3.1.nupkg.sha512",
"system.net.http.nuspec"
]
},
"System.Security.Cryptography.Algorithms/4.3.0": {
"sha512": "W1kd2Y8mYSCgc3ULTAZ0hOP2dSdG5YauTb1089T0/kRcN2MpSAW1izOFROrJgxSlMn3ArsgHXagigyi+ibhevg==",
"type": "package",
"path": "system.security.cryptography.algorithms/4.3.0",
"files": [
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net46/System.Security.Cryptography.Algorithms.dll",
"lib/net461/System.Security.Cryptography.Algorithms.dll",
"lib/net463/System.Security.Cryptography.Algorithms.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net46/System.Security.Cryptography.Algorithms.dll",
"ref/net461/System.Security.Cryptography.Algorithms.dll",
"ref/net463/System.Security.Cryptography.Algorithms.dll",
"ref/netstandard1.3/System.Security.Cryptography.Algorithms.dll",
"ref/netstandard1.4/System.Security.Cryptography.Algorithms.dll",
"ref/netstandard1.6/System.Security.Cryptography.Algorithms.dll",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"runtimes/osx/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll",
"runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll",
"runtimes/win/lib/net46/System.Security.Cryptography.Algorithms.dll",
"runtimes/win/lib/net461/System.Security.Cryptography.Algorithms.dll",
"runtimes/win/lib/net463/System.Security.Cryptography.Algorithms.dll",
"runtimes/win/lib/netcore50/System.Security.Cryptography.Algorithms.dll",
"runtimes/win/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll",
"system.security.cryptography.algorithms.4.3.0.nupkg.sha512",
"system.security.cryptography.algorithms.nuspec"
]
},
"System.Security.Cryptography.Encoding/4.3.0": {
"sha512": "1DEWjZZly9ae9C79vFwqaO5kaOlI5q+3/55ohmq/7dpDyDfc8lYe7YVxJUZ5MF/NtbkRjwFRo14yM4OEo9EmDw==",
"type": "package",
"path": "system.security.cryptography.encoding/4.3.0",
"files": [
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net46/System.Security.Cryptography.Encoding.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net46/System.Security.Cryptography.Encoding.dll",
"ref/netstandard1.3/System.Security.Cryptography.Encoding.dll",
"ref/netstandard1.3/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/de/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/es/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/fr/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/it/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/ja/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/ko/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/ru/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/zh-hans/System.Security.Cryptography.Encoding.xml",
"ref/netstandard1.3/zh-hant/System.Security.Cryptography.Encoding.xml",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll",
"runtimes/win/lib/net46/System.Security.Cryptography.Encoding.dll",
"runtimes/win/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll",
"system.security.cryptography.encoding.4.3.0.nupkg.sha512",
"system.security.cryptography.encoding.nuspec"
]
},
"System.Security.Cryptography.Primitives/4.3.0": {
"sha512": "7bDIyVFNL/xKeFHjhobUAQqSpJq9YTOpbEs6mR233Et01STBMXNAc/V+BM6dwYGc95gVh/Zf+iVXWzj3mE8DWg==",
"type": "package",
"path": "system.security.cryptography.primitives/4.3.0",
"files": [
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net46/System.Security.Cryptography.Primitives.dll",
"lib/netstandard1.3/System.Security.Cryptography.Primitives.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net46/System.Security.Cryptography.Primitives.dll",
"ref/netstandard1.3/System.Security.Cryptography.Primitives.dll",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"system.security.cryptography.primitives.4.3.0.nupkg.sha512",
"system.security.cryptography.primitives.nuspec"
]
},
"System.Security.Cryptography.X509Certificates/4.3.0": {
"sha512": "t2Tmu6Y2NtJ2um0RtcuhP7ZdNNxXEgUm2JeoA/0NvlMjAhKCnM1NX07TDl3244mVp3QU6LPEhT3HTtH1uF7IYw==",
"type": "package",
"path": "system.security.cryptography.x509certificates/4.3.0",
"files": [
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net46/System.Security.Cryptography.X509Certificates.dll",
"lib/net461/System.Security.Cryptography.X509Certificates.dll",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net46/System.Security.Cryptography.X509Certificates.dll",
"ref/net461/System.Security.Cryptography.X509Certificates.dll",
"ref/netstandard1.3/System.Security.Cryptography.X509Certificates.dll",
"ref/netstandard1.3/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/de/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/es/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/fr/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/it/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/ja/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/ko/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/ru/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/zh-hans/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.3/zh-hant/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/System.Security.Cryptography.X509Certificates.dll",
"ref/netstandard1.4/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/de/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/es/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/fr/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/it/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/ja/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/ko/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/ru/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/zh-hans/System.Security.Cryptography.X509Certificates.xml",
"ref/netstandard1.4/zh-hant/System.Security.Cryptography.X509Certificates.xml",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll",
"runtimes/win/lib/net46/System.Security.Cryptography.X509Certificates.dll",
"runtimes/win/lib/net461/System.Security.Cryptography.X509Certificates.dll",
"runtimes/win/lib/netcore50/System.Security.Cryptography.X509Certificates.dll",
"runtimes/win/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll",
"system.security.cryptography.x509certificates.4.3.0.nupkg.sha512",
"system.security.cryptography.x509certificates.nuspec"
]
}
},
"projectFileDependencyGroups": {
"": [],
".NETFramework,Version=v4.6": [
"Google.Apis >= 1.34.0"
]
},
"tools": {},
"projectFileToolGroups": {},
"packageFolders": {
"D:\\home\\data\\Functions\\packages\\nuget": {}
}
}现在运行时,给定模板上的函数将得到一个编译错误:
2018-06-08T17:29:55.711错误函数编译错误2018-06-08T17:29:55.711错误run.csx(8,19):error CS1929:'HttpRequestMessage‘不包含“GetQueryNameValuePairs”的定义,而最佳扩展方法重载HttpRequestMessage需要类型为'HttpRequestMessage’2018-06-08T17:29:55.711 Error run.csx(15,30):Error CS1929:'HttpContent‘不包含“ReadAsAsync”和最佳扩展方法重载HttpContentExtensions.ReadAsAsync的定义(HttpContent)需要类型为'HttpContent‘2018-06-08T17:29:55.711错误run.csx(20,11):错误CS1929:'HttpRequestMessage’不包含“CreateResponse”的定义和最佳扩展方法重载run.csx'HttpRequestMessageExtensions.CreateResponse(HttpRequestMessage,)‘需要类型为'HttpRequestMessage’2018-06-08T17:29:55.711错误run.csx(21,11):错误CS1929:'HttpRequestMessage‘不包含'CreateResponse’的定义,最佳扩展方法重载HttpRequestMessage HttpStatusCode,string)‘需要一个类型为'HttpRequestMessage’2018-06-08T17:29:55.742错误异常类型的接收器,同时执行函数: Functions.ganalytics。Microsoft.Azure.WebJobs.Script:脚本编译失败。2018-06-08T17:29:55.742错误函数已完成(Failure,Id=bfbba2a8-6946-4935-8495-f21973d408cb,Duration=44ms)
据我所知,这是一个与System.Net.Http依赖版本有关的问题,Google.Api包以某种方式覆盖了该版本。(link)我想问的是:有办法解决这个问题吗?
提前谢谢你。
发布于 2018-06-09 10:49:23
若要恢复此引用的重定向,请转到kudu中的D:\home\data\Functions\packages\nuget文件夹,删除system.net.http包。然后重新启动整个函数应用程序,以引用原始依赖项。
解释:
函数主机从GAC(全局程序集缓存)引用System.Net.Http.dll程序集。在本地,文件路径是C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll,而在Azure上,文件路径位于D:\...。它不能重定向到某个软件包,我们以后安装使用nuget,否则我们将得到错误。
https://stackoverflow.com/questions/50765855
复制相似问题