错误 SQL72018:无法导入数据库选项 [英] Error SQL72018: Database Options could not be imported

查看:55
本文介绍了错误 SQL72018:无法导入数据库选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Octopus 部署一个 MVC 项目和一个数据库.当部署数据库的步骤被点击时,我收到以下错误:

I am deploying an MVC Project along with a database using Octopus. When the step for deploying the database is hit I'm getting the following error:

An error occurred during deployment plan generation. Deployment cannot continue.

 Error SQL72018: Database Options could not be imported but one or more of these objects exist in your source.
    at Microsoft.SqlServer.Dac.DacServices.CreateController(SqlDeployment deploymentEngine, ErrorManager errorManager)
    at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass3.<>c__DisplayClass5.<CreatePlanInitializationOperation>b__1()
    at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action)
    at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass3.<CreatePlanInitializationOperation>b__0(Object operation, CancellationToken token)
    at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
    at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
    at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
    at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
    at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
    at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
    at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
    at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext)
    at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
    at CallSite.Target(Closure , CallSite , Object , Object , Object , Boolean , Object )
 Errors occurred while modeling the target database.  Deployment can not continue.
    at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.ThrowIfErrors(String message, ErrorManager errors, Object category)
    at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.OnLoad(ErrorManager errors, DeploymentEngineContext context)
    at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.PrepareModels()
    at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.InitializePlanGeneratator()
    at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.CreateController(Action`1 msgHandler)
    at Microsoft.SqlServer.Dac.DacServices.CreateController(SqlDeployment deploymentEngine, ErrorManager errorManager)

这是 Deploy.ps1 文件

Here's the Deploy.ps1 file

# Add the DLL
# For 64-bit machines
Write-Host "Add Types"
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.Dac.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")

#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 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

SQL 项目针对 SQL Server 2012.我不确定这里还有哪些其他信息会有所帮助,所以如果您需要更多信息,请告诉我.感谢所有帮助.感谢您的时间!

The SQL Project is aimed at SQL Server 2012. I'm not sure what other information would be helpful here, so let me know if you need more information. All help is appreciated. Thank you for your time!

推荐答案

您不再需要安装 SQLPackage 他们已经发布了包含它的 NuGet 包.看看这里 https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild

You no longer need to install SQLPackage they have released a NuGet package that contains it. Have a look here https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild

这篇关于错误 SQL72018:无法导入数据库选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆