File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,9 +170,8 @@ function Install-DbaSqlWatch {
170170 }
171171
172172 Write-ProgressHelper - StepNumber ($stepCounter ++ ) - Message " Publishing SqlWatch dacpac to $database on $instance " - TotalSteps $totalSteps
173- $DacProfile = New-DbaDacProfile - SqlInstance $server - Database $Database - Path $localCachedCopy - PublishOptions $PublishOptions | Select-Object - ExpandProperty FileName
174- $PublishResults = Publish-DbaDacPackage - SqlInstance $server - Database $Database - Path $DacPacPath - PublishXml $DacProfile
175- Remove-Item - Path $DacProfile
173+ $DacProfile = New-DbaDacProfile - SqlInstance $server - Database $Database - Path $localCachedCopy - PublishOptions $PublishOptions - EnableException | Select-Object - ExpandProperty FileName
174+ $PublishResults = Publish-DbaDacPackage - SqlInstance $server - Database $Database - Path $DacPacPath - PublishXml $DacProfile - EnableException
176175
177176 # parse results
178177 $parens = Select-String - InputObject $PublishResults.Result - Pattern " \(([^\)]+)\)" - AllMatches
@@ -190,6 +189,8 @@ function Install-DbaSqlWatch {
190189 }
191190 } catch {
192191 Stop-Function - Message " DACPAC failed to publish to $database on $instance ." - ErrorRecord $_ - Target $instance - Continue
192+ } finally {
193+ Remove-Item - Path $DacProfile - ErrorAction SilentlyContinue
193194 }
194195
195196 Write-Message - Level Verbose - Message " Finished installing/updating SqlWatch in $database on $instance ."
You can’t perform that action at this time.
0 commit comments