在脚本任务中使用nuget包

PVB*_*PVB 6 c# ssis etl script-task

我正在尝试使Microsoft.Azure.Services.AppAuthentication及其依赖项与 SSIS 脚本任务一起使用。如何解决程序集引用错误?

在此输入图像描述


static ScriptMain()
{
    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}

static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{

    if (args.Name.Contains("Microsoft.Azure.Services.AppAuthentication"))
    {
        return System.Reflection.Assembly.LoadFile(@"C:\Azure\packages\Microsoft.Azure.Services.AppAuthentication.1.6.2\lib\net472\Microsoft.Azure.Services.AppAuthentication.dll");
    }

    if (args.Name.Contains("Microsoft.IdentityModel.Clients.ActiveDirectory"))
    {
        return System.Reflection.Assembly.LoadFile(@"C:\Azure\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.5.2.9\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll");
    }   
}
Run Code Online (Sandbox Code Playgroud)

Yah*_*ufi 7

SSIS 脚本任务/组件不支持 Nuget 包。您需要从GitHub 存储库手动下载程序集。

接下来,您应该将这些程序集添加到全局缓存程序集 (GAC):


您可以参考以下文章获取更多指导: