Powershell Microsoft.SqlServer.Dac问题
我正在尝试使用Octopus部署一个MVC项目和一个数据库。当部署数据库的步骤被点击时,我得到以下错误:Powershell Microsoft.SqlServer.Dac问题,powershell,nuget,teamcity,octopus-deploy,dacpac,Powershell,Nuget,Teamcity,Octopus Deploy,Dacpac,我正在尝试使用Octopus部署一个MVC项目和一个数据库。当部署数据库的步骤被点击时,我得到以下错误: Types : {Microsoft.SqlServer.Dac.BacPackage, Microsoft.SqlServer.Dac.NestedDeploymentPropertyAttribute, Microsoft.SqlServer.Dac.DacExportOptions,
Types : {Microsoft.SqlServer.Dac.BacPackage,
Microsoft.SqlServer.Dac.NestedDeploymentPropertyAttribute,
Microsoft.SqlServer.Dac.DacExportOptions,
Microsoft.SqlServer.Dac.DacImportOptions...}
LoaderExceptions : {System.IO.FileNotFoundException: Could not load file or
assembly 'Microsoft.SqlServer.TransactSql.ScriptDom,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its
dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.TransactSql.ScriptDom,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry
value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to
1.
Note: There is some performance penalty associated with
assembly bind failure logging.
To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
, System.IO.FileNotFoundException: Could not load file or
assembly 'Microsoft.SqlServer.TransactSql.ScriptDom,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its
dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.TransactSql.ScriptDom,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry
value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to
1.
Note: There is some performance penalty associated with
assembly bind failure logging.
To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
}
Message : Unable to load one or more of the requested types Retrieve
the LoaderExceptions property for more information.
Data : {}
InnerException :
TargetSite : System.RuntimeType[]
GetTypes(System.Reflection.RuntimeModule)
StackTrace : at
System.Reflection.RuntimeModule.GetTypes(RuntimeModule
module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
at
Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
at
System.Management.Automation.CommandProcessorBase.Complete()
HelpLink :
Source : mscorlib
HResult : -2146232830
Deploy.ps1文件如下所示:
try{
# Add the DLL
# For 64-bit machines
Write-Host "Add Microsoft.SqlServer.Dac.dll"
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.Dac.dll")
Write-Host "Add Microsoft.SqlServer.TransactSql.ScriptDom.dll"
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.TransactSql.ScriptDom.dll")
# Create the connection string
$services = New-Object Microsoft.SqlServer.Dac.DacServices ("Data Source=$dbSource;User Id=$dbAdminUser;Password=$dbAdminPassword")
Write-Host "Load the dacpac " + ((Get-Item -Path ".\" -Verbose).FullName + "\Resources\Database.publish.xml")
#Load the dacpac
$dacpac = ((Get-Item -Path ".\" -Verbose).FullName + "\Resources\Database.dacpac")
$dacpacoptions = ((Get-Item -Path ".\" -Verbose).FullName + "\Resources\Database.publish.xml")
Write-Host "Add variables"
#Add the variables to the options
Write-Host $dacpac
Write-Host $dacpacoptions
Write-Host "setting dp"
#Load dacpac from file & deploy to database
$dp = [Microsoft.SqlServer.Dac.DacPackage]::Load($dacpac)
Write-Host "dacProfile set"
#Read a publish profile XML to get the deployment options
$dacProfile = [Microsoft.SqlServer.Dac.DacProfile]::Load($dacpacoptions)
Write-Host "Add dbName"
$dacProfile.DeployOptions.SqlCommandVariableValues["dbName"] = $dbName
Write-Host "Add dbUser"
$dacProfile.DeployOptions.SqlCommandVariableValues["dbUsername"] = $dbUser
Write-Host "Add dbPassword"
$dacProfile.DeployOptions.SqlCommandVariableValues["dbPassword"] = $dbPassword
Write-Host "About to deploy the dacpac"
# Deploy the dacpac
$services.Deploy($dp, $dbName, $TRUE, $dacProfile.DeployOptions)
# Configure IIS
.\DeployScripts\IISConfiguration.ps1
}
catch [Exception]
{
$_.Exception|format-list -force
Exit -1
}
我正在使用适用于Microsoft.SqlServer.Dac v1.0.1的NuGet软件包,以及适用于Microsoft.SqlServer.Transact-SQL.ScriptDom v13.0.1601.5的NuGet软件包。据我所知,这两个NuGet软件包目前都是这些DLL的最新版本。dacpac面向SQL Server 2014。我不确定这里还有什么有用的信息。我部署到的服务器没有SqlPackage.exe,因此我无法使用它。非常感谢您的任何帮助。谢谢。从日志中看,它似乎无法在正在搜索的位置找到程序集“Microsoft.SqlServer.Transact-SQL.ScriptDom”是的,它说它正在搜索版本12.0.0,但我有版本13.0.1Add-Type-path((获取项-路径“\”-Verbose)。全名+“\bin\Microsoft.SqlServer.Transact-SQL.ScriptDom.dll”)。。这是在看正确的目录吗。。可能您可以尝试通过提供一个显式路径来加载它,例如C:\Program Files(x86)\Microsoft SQL Server\120\SDK\Assembly