1

I am working to automate the scripting of an SSDT project so that it can be deployed later with alternative values for variables being passed in.

My publish profile looks like this.

<?xml version="1.0" encoding="utf-8"?>
  <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <IncludeCompositeObjects>True</IncludeCompositeObjects>
     <TargetConnectionString>Data Source=.;Integrated Security=True;Pooling=False</TargetConnectionString>
     <TargetDatabaseName>BLANK</TargetDatabaseName>
     <UpdateDatabase>False</UpdateDatabase>
     <ScriptDatabaseOptions>True</ScriptDatabaseOptions>
     <BlockOnPossibleDataLoss>True</BlockOnPossibleDataLoss>
     <CreateNewDatabase>True</CreateNewDatabase>
     <IgnoreObjectPlacementOnPartitionScheme>False</IgnoreObjectPlacementOnPartitionScheme>
     <ProfileVersionNumber>1</ProfileVersionNumber>
     <CommentOutSetVarDeclarations>True</CommentOutSetVarDeclarations>
   </PropertyGroup>
 </Project>

In my test script I am then calling the following from powershell

$Directory = 'C:\GitProjects\CI\DevPOC\Database\ETL POC\AdventureWorksDW\'
$Publish = 'AdventureWorksDW.publish.xml'

Set-Location $Directory
& $env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Build
& $env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Publish /p:SqlPublishProfilePath`="$Directory\$Publish"

I then get a number of errors which all relate to the variable values, examples below.

Deploy error SQL72014: SQL Execution error: A fatal error occurred. The variable DatabaseName could not be found.  [C:\GitProjects\CI\POC\Database\ETL POC\AdventureWorksDW\AdventureWorksDW.sqlproj]

If however I set CommentOutSetVarDeclarations to false the script is generated without error. When performing the same task through SSDT no errors are raised.

Has anyone experienced similar behaviour?

4

1 回答 1

2

因此,在与 Microsoft 支持反复讨论之后,我找到了解决此问题的方法。似乎发布配置文件中设置的参数UpdateDatabase没有被拾取并以这种方式使用。不是 100% 确定这是否被确认为错误,但通过使用以下命令可以正常工作。

& $env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Publish /p:SqlPublishProfilePath`="$Directory\$Publish" /p:UpdateDatabase=False
于 2013-04-03T15:43:00.540 回答