【问题标题】:Deploy SSIS with Powershell - Missing DMF使用 Powershell 部署 SSIS - 缺少 DMF
【发布时间】:2021-01-25 19:03:08
【问题描述】:

我正在尝试编写一个 PowerShell 脚本来部署和 SSIS 项目。这是我的代码。

# Variables
$SSISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
$TargetServerName = "FBISQL003DV"
$TargetFolderName = "DEV"
$ProjectFilePath = "C:\Users\Brian.Ciampa\source\Workspaces\TFICM2\TFCIM\DEV\CIM\SSIS\BC_TEST\bin\Development\BC_TEST.ispac"
$ProjectName = "BC_TEST"

# Load the IntegrationServices assembly.  This is located at C:\windows\assembly.
$loadStatus = [System.Reflection.Assembly]::Load("Microsoft.SQLServer.Management.IntegrationServices, "+
    "Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL")

# Create a connection to the server
$sqlConnectionString = `
    "Data Source=" + $TargetServerName + ";Initial Catalog=master;Integrated Security=SSPI;"
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString

# Create the Integration Services object
$integrationServices = New-Object $SSISNamespace".IntegrationServices" $sqlConnection

# Get the Integration Services catalog
$catalog = $integrationServices.Catalogs["SSISDB"]

# Create the target folder
$folder = New-Object $SSISNamespace".CatalogFolder" ($catalog, $TargetFolderName,
    "Folder description")
$folder.Create()

Write-Host "Deploying " $ProjectName " project ..."

# Read the project file and deploy it
[byte[]] $projectFile = [System.IO.File]::ReadAllBytes($ProjectFilePath)
$folder.DeployProject($ProjectName, $projectFile)

Write-Host "Done."

但是,我不断收到此消息:

New-Object : Could not load file or assembly 'Microsoft.SqlServer.Dmf.Common, Version=13.0.0.0, Culture=neutral, 
PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
At C:\Users\Brian.Ciampa\desktop\SSIS_Deploy.ps1:20 char:24
+ ... nServices = New-Object $SSISNamespace".IntegrationServices" $sqlConne ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-Object], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand

Microsoft.SqlServer.Dmf.dll 和 Microsoft.SqlServer.Dmf.Common.dll 文件位于该文件夹中。我需要做什么?

谢谢! 布赖恩

【问题讨论】:

    标签: powershell ssis


    【解决方案1】:

    尝试使用 Add-Type 加载 dll,如下所示:

    Add-Type -AssemblyName "Microsoft.SqlServer.Dmf.Common, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
    

    它将在当前目录中检查 dll,除非它之前已经成功加载。

    如果还是找不到,说明文件夹中Microsoft.SqlServer.Dmf.Common.dll的版本不是IntegrationServices程序集需要的dll。

    要检查当前文件夹中dll的签名,可以运行:

    ([System.Reflection.Assembly]::LoadFile((Get-Item ".\Microsoft.SqlServer.Dmf.Common.dll").FullName)).FullName
    

    帮助定位匹配 dll 的注释。

    12.0 = SQL Server 2014
    13.0 = SQL Server 2016
    14.0 = SQL Server 2017
    

    备选方案:

    在下面的例子中,我将首先加载 IntegrationServices“版本 14.0.0...”,这样 dll 就不需要从文件中手动加载或添加到 GAC。

    C:\>attrib /s gacutil.exe
    A            C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\gacutil.exe
    A            C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\gacutil.exe
    A            C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64\gacutil.exe
    A            C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe
    A            C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\gacutil.exe
    A            C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe
    
    C:\>cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64"
    
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>gacutil /l | find "IntegrationServices,"
      Microsoft.SqlServer.Management.IntegrationServices, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
      Microsoft.SqlServer.Management.IntegrationServices, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
      Microsoft.SqlServer.Management.IntegrationServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
      Microsoft.SqlServer.Management.IntegrationServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
    
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>gacutil /l | find "Dmf.Common,"
      Microsoft.SqlServer.Dmf.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
    
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>gacutil /l | find "Dmf,"
      Microsoft.SqlServer.Dmf, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
      Microsoft.SqlServer.Dmf, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
    
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>
    

    【讨论】:

    • 没用。我收到此消息: Add-Type : 无法添加类型。找不到程序集“Microsoft.SqlServer.Dmf.Common, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91”。
    • 该特定 dll 文件不能用于填充指定 IntegrationServices 程序集所需的依赖项。使用我在上面附加的签名命令来帮助找到匹配的版本。一个或另一个需要调整。
    • 好的,谢谢。我指向的 dll 版本为 15。那么,我需要 13 版本吗?
    • 是的,但也考虑在帖子中添加替代选项。这只会解决无法加载文件或程序集的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 2014-06-10
    • 1970-01-01
    • 1970-01-01
    • 2013-09-05
    相关资源
    最近更新 更多