Skip to content

Commit

Permalink
stop passing sqlcmd default values when launching dacpactool (#702)
Browse files Browse the repository at this point in the history
fixes #701
  • Loading branch information
ErikEJ authored Jan 31, 2025
1 parent a7871a2 commit e0c845b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/DacpacTool/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,8 @@ public static void AddSqlCmdVariables(this TSqlModel model, string[] variables)

var customData = Activator.CreateInstance(Type.GetType("Microsoft.Data.Tools.Schema.SchemaModel.CustomSchemaData, Microsoft.Data.Tools.Schema.Sql"), "SqlCmdVariables", "SqlCmdVariable");

foreach (var variable in variables)
foreach (var variableName in variables)
{
var varWithValue = variable.Split('=', 2);
var variableName = varWithValue[0];

Console.WriteLine($"Adding SqlCmd variable {variableName}");

var setMetadataMethod = customData.GetType().GetMethod("SetMetadata", BindingFlags.Public | BindingFlags.Instance);
Expand Down
2 changes: 1 addition & 1 deletion src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
<InputFileArguments>-i &quot;$(IntermediateOutputPath)$(MSBuildProjectName).InputFiles.txt&quot;</InputFileArguments>
<BuildPropertyArguments>@(BuildPropertyNames->'-bp %(Identity)=%(PropertyValue)', ' ')</BuildPropertyArguments>
<DeployPropertyArguments>@(DeployPropertyNames->'-dp %(Identity)=%(PropertyValue)', ' ')</DeployPropertyArguments>
<SqlCmdVariableArguments>@(SqlCmdVariable->'-sc %(Identity)=&quot;%(DefaultValue)&quot;', ' ')</SqlCmdVariableArguments>
<SqlCmdVariableArguments>@(SqlCmdVariable->'-sc %(Identity)', ' ')</SqlCmdVariableArguments>
<PreDeploymentScriptArgument>@(PreDeploy->'--predeploy &quot;%(Identity)&quot;', ' ')</PreDeploymentScriptArgument>
<PostDeploymentScriptArgument>@(PostDeploy->'--postdeploy &quot;%(Identity)&quot;', ' ')</PostDeploymentScriptArgument>
<RefactorLogScriptArgument>@(RefactorLog->'--refactorlog &quot;%(Identity)&quot;', ' ')</RefactorLogScriptArgument>
Expand Down
4 changes: 2 additions & 2 deletions test/DacpacTool.Tests/PackageBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ public void AddSqlCmdvariable()
public void AddSqlCmdvariableWithDefaultValue()
{
// Arrange
var first = "DbReader=dbReaderValue";
var second = "DbWriter=dbWriterValue";
var first = "DbReader";
var second = "DbWriter";
var tempFile = new FileInfo(Path.GetTempFileName());
var packageBuilder = new PackageBuilder(new TestConsole());
packageBuilder.SetMetadata("MyPackage", "1.0.0.0");
Expand Down

0 comments on commit e0c845b

Please sign in to comment.