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?