sql server - Can I use the DeployReport option when deploying a dacpac through Release Management -


i'd able setup winrm dacpac deployment task in ms release management create report of schema compare , not deploy database. have environment approval , abandon deployment if unexpected changes reported. if changes expected, next environment deploy database.

is there way using available winrm db deployment task? if so, how?

'publish' hardcoded in task script, wound creating powershell script this. modified relevant code task (https://github.com/microsoft/vsts-tasks/tree/master/tasks/sqldacpacdeploymentonmachinegroup) , imported utility file used task (https://github.com/microsoft/vsts-rm-extensions/blob/master/taskmodules/powershell/taskmodulesqlutility/sqlpackageontargetmachines.ps1). changed hardcoded value , added output file parameter. read in report file , display in release log powershell task. abest's comment idea, looks don't have task available @ our site.

param (     [string]$dacpacfile = $(throw "dacpacfile mandatory, please provide value."),      [string]$publishprofile = $(throw "publishprofile mandatory, please provide value."),     [string]$targetdbserver = $(throw "targetdbserver mandatory, please provide value."),     [string]$targetdbname = $(throw "targetdbname mandatory, please provide value."),     [string]$outputpath = $(throw "outputpath mandatory, please provide value.")  )    import-module "$psscriptroot\sqlpackageontargetmachines.ps1"   function get-sqlpackagecmdargsdeployreport {     param (     [string]$dacpacpath,     [string]$publishprofile,     [string]$server,     [string]$dbname     )      try     {         # validate dacpac file         if ([system.io.path]::getextension($dacpacpath) -ne ".dacpac")         {             throw "invalid dacpac file [ $dacpacpath ] provided"         }     }     catch [system.exception]     {         write-verbose ("could not verify dacpac : " + $_.exception.message) -verbose     }      $sqlpkgcmdargs = [string]::format(' /sourcefile:"{0}" /action:deployreport', $dacpacpath)      try         {             # validate output file             if ([system.io.path]::getextension($outputpath) -ne ".xml")             {                 throw "invalid output file [ $outputpath ] provided, should xml file really"             }             $sqlpkgcmdargs = [string]::format('{0} /outputpath:"{1}"', $sqlpkgcmdargs, $outputpath)             }         catch [system.exception]         {             write-verbose ("could not verify ouput path : " + $_.exception.message) -verbose         }      if( ![string]::isnullorwhitespace($publishprofile) )     {          try         {             # validate publish profile             if ([system.io.path]::getextension($publishprofile) -ne ".xml")             {                 throw "invalid publish profile [ $publishprofile ] provided"             }             $sqlpkgcmdargs = [string]::format('{0} /profile:"{1}"', $sqlpkgcmdargs, $publishprofile)             }         catch [system.exception]         {             write-verbose ("could not verify profile : " + $_.exception.message) -verbose         }      }      if( ![string]::isnullorwhitespace($dbname) )     {        $sqlpkgcmdargs = [string]::format('{0} /targetservername:"{1}" /targetdatabasename:"{2}"', $sqlpkgcmdargs, $server, $dbname)     }     #write-verbose "sqlpackage.exe arguments : $sqlpkgcmdargs" -verbose     return $sqlpkgcmdargs }  function format-xml ([xml]$xml, $indent=2)  {      $stringwriter = new-object system.io.stringwriter      $xmlwriter = new-object system.xml.xmltextwriter $stringwriter      $xmlwriter.formatting = “indented”      $xmlwriter.indentation = $indent      $xml.writecontentto($xmlwriter)      $xmlwriter.flush()      $stringwriter.flush()      write-output $stringwriter.tostring()  }  $sqlpackage = get-sqlpackageontargetmachine   #write-verbose "so path sql package $sqlpackage ?" -verbose  $sqlpackagearguments = get-sqlpackagecmdargsdeployreport $dacpacfile $publishprofile $targetdbserver $targetdbname write-verbose("running executecommand -filename ""$sqlpackage""  -arguments $sqlpackagearguments") -verbose  executecommand -filename "$sqlpackage"  -arguments $sqlpackagearguments   [xml]$report = get-content $outputpath   format-xml $report -indent 4 | write-verbose -verbose 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -