我直接从门户网站(版本~1,http触发器模板)创建了一个新的C#函数,并添加了一个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):错误CS1929:'HttpRequestMessage'不包含'GetQueryNameValuePairs'的定义和最佳扩展方法重载'HttpRequestMessageExtensions.GetQueryNameValuePairs(HttpRequestMessage)'需要'HttpRequestMessage'类型的接收器 2018-06-08T17:29:55.711 [错误] run.csx(15,30):错误CS1929:'HttpContent'不包含'ReadAsAsync'的定义和最佳扩展方法重载'HttpContentExtensions.ReadAsAsync(HttpContent)'需要'HttpContent'类型的接收器 2018-06-08T17:29:55.711 [错误] run.csx(20,11):错误CS1929:'HttpRequestMessage'不包含'CreateResponse'的定义和最佳扩展方法重载'HttpRequestMessageExtensions.CreateResponse(HttpRequestMessage,HttpStatusCode) ,string)'需要'HttpRequestMessage'类型的接收器 2018-06-08T17:29:55.711 [错误] run.csx(21,11):错误CS1929:'HttpRequestMessage'不包含'CreateResponse'的定义和最佳扩展方法重载'HttpRequestMessageExtensions.CreateResponse(HttpRequestMessage,HttpStatusCode) ,string)'需要'HttpRequestMessage'类型的接收器 2018-06-08T17:29:55.742 [错误]执行函数时出现异常:Functions.ganalytics。 Microsoft.Azure.WebJobs.Script:脚本编译失败。 2018-06-08T17:29:55.742 [错误]功能完成(失败,Id = bfbba2a8-6946-4935-8495-f21973d408cb,持续时间= 44ms)
我知道这是一个与System.Net.Http相关性版本相关的问题,某种方式是从Google.Api包中覆盖的。 (link) 我要问的是:是否有解决方法来解决这个错误?
提前谢谢。
答案 0 :(得分:2)
要恢复此引用的重定向,请转到kudu中的D:\home\data\Functions\packages\nuget
文件夹,删除system.net.http
包。然后重启整个功能app以引用原始依赖。
说明:
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安装的某个程序包,否则我们将收到错误。