Azure Functions 中的自定义 DLL 能否依赖 project.json 中的 Nuget 包?
Can custom DLLs in Azure Functions depend on Nuget packages in project.json?
我有一个自定义 DLL,它依赖于 project.json 中的包。我收到以下错误:
2017-05-25T21:04:18.152 Exception while executing function:
Functions.TimerTriggerCSharp1. mscorlib: Exception has been thrown by
the target of an invocation. f-TimerTriggerCSharp1__631134587: Could
not load file or assembly 'MyAssemblyName, Version=MyAssemblyVersion,
Culture=neutral, PublicKeyToken=MyAssemblyToken' or one of its
dependencies. The system cannot find the file specified.
我已将程序集添加到 bin/ 文件夹中并使用完整路径引用它。该程序集依赖于我在 project.json.
中定义的其他 Nuget 包
知道我为什么会收到错误消息吗?
一般guidance/recommendation是用你的程序集部署你的临时依赖。
对于 NuGet 依赖项,运行时会为您解决该问题,但运行时会尝试满足这些依赖项,但请确保您将程序集引用从使用完整路径更改为使用简单文件名仅(没有路径),例如:
#r "MyAssembly.dll"
运行时将自动从 bin 文件夹加载程序集作为私有依赖项,这会将依赖项的范围限定为该函数并尝试使用该函数的引用包来实现瞬态依赖项。
我有一个自定义 DLL,它依赖于 project.json 中的包。我收到以下错误:
2017-05-25T21:04:18.152 Exception while executing function:
Functions.TimerTriggerCSharp1. mscorlib: Exception has been thrown by the target of an invocation. f-TimerTriggerCSharp1__631134587: Could not load file or assembly 'MyAssemblyName, Version=MyAssemblyVersion, Culture=neutral, PublicKeyToken=MyAssemblyToken' or one of its dependencies. The system cannot find the file specified.
我已将程序集添加到 bin/ 文件夹中并使用完整路径引用它。该程序集依赖于我在 project.json.
中定义的其他 Nuget 包知道我为什么会收到错误消息吗?
一般guidance/recommendation是用你的程序集部署你的临时依赖。
对于 NuGet 依赖项,运行时会为您解决该问题,但运行时会尝试满足这些依赖项,但请确保您将程序集引用从使用完整路径更改为使用简单文件名仅(没有路径),例如:
#r "MyAssembly.dll"
运行时将自动从 bin 文件夹加载程序集作为私有依赖项,这会将依赖项的范围限定为该函数并尝试使用该函数的引用包来实现瞬态依赖项。