Error SQL72018: Database Options could not be imported

冷暖自知 提交于 2019-12-12 01:39:25

问题


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)

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

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!


回答1:


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



来源:https://stackoverflow.com/questions/39378166/error-sql72018-database-options-could-not-be-imported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!