Skip to content

Commit

Permalink
fixes rr-wfm#675
Browse files Browse the repository at this point in the history
parts of rr-wfm#674 (maybe all?)
  • Loading branch information
ErikEJ committed Dec 29, 2024
1 parent e5b2557 commit 618aa95
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "sqltoolsservice"]
path = sqltoolsservice
url = https://github.com/microsoft/sqltoolsservice.git
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning">
<Version>3.6.146</Version>
<Version>3.7.112</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion sqltoolsservice
Submodule sqltoolsservice deleted from 54fe38
23 changes: 11 additions & 12 deletions src/DacpacTool/DacpacTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,26 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>

<PropertyGroup>
<SqlToolsPath>../../sqltoolsservice/src</SqlToolsPath>
<ManagedBatchParserPath>$(SqlToolsPath)/Microsoft.SqlTools.ManagedBatchParser</ManagedBatchParserPath>
</PropertyGroup>
<ItemGroup>
<Content Include="Microsoft.SqlTools.ManagedBatchParser.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SqlServer.DacFx" Version="162.4.92" />
<PackageReference Include="Microsoft.SqlServer.DacFx" Version="162.5.57" />
<PackageReference Include="NuGet.Versioning" Version="6.12.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

<!-- References to Microsoft.SqlTools.ManagedBatchParser -->
<ItemGroup>
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="171.30.0" />
<ProjectReference Include="$(SqlToolsPath)/Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
<Compile Include="$(ManagedBatchParserPath)/Localization/*.cs" Link="BatchParser/%(Filename)%(Extension)" />
<EmbeddedResource Include="$(ManagedBatchParserPath)/Localization/sr.resx" LogicalName="Microsoft.SqlTools.ManagedBatchParser.Localization.SR.resources" Link="BatchParser/%(Filename)%(Extension)" />
<None Include="$(ManagedBatchParserPath)/Localization/sr.strings" Link="BatchParser/%(Filename)%(Extension)" />
<Compile Include="$(ManagedBatchParserPath)/BatchParser/**/*.cs" Link="BatchParser/%(Filename)%(Extension)" />
<Compile Include="$(ManagedBatchParserPath)/ReliableConnection/**/*.cs" Link="BatchParser/%(Filename)%(Extension)" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="172.52.0" />
<Reference Include="Microsoft.SqlTools.ManagedBatchParser">
<HintPath>Microsoft.SqlTools.ManagedBatchParser.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>

</Project>
Binary file not shown.
16 changes: 11 additions & 5 deletions src/DacpacTool/PackageDeployer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Data.SqlClient;
Expand Down Expand Up @@ -172,8 +173,7 @@ private void RunDeploymentScriptFromReferences(FileInfo dacpacPackage, string ta
_console.WriteLine($"Running {scriptPrefix}-deployment script for referenced package '{referencedPackage.Name}' version '{referencedPackage.Version}'");
_currentSource = $"{referencedPackage.Name}/{scriptPrefix}deploy.sql";

var scriptExecutionArgs = new ScriptExecutionArgs(script, connection, 0, executionEngineConditions, this);
AddSqlCmdVariables(scriptExecutionArgs, targetDatabaseName);
var scriptExecutionArgs = new ScriptExecutionArgs(script, connection, 0, executionEngineConditions, this, 1, AddSqlCmdVariables(targetDatabaseName));

engine.BatchParserExecutionError += (sender, args) => _console.WriteLine(args.Format(_currentSource));
engine.ScriptExecutionFinished += (sender, args) => _console.WriteLine($"Executed {scriptPrefix}-deployment script for referenced package " +
Expand All @@ -182,13 +182,19 @@ private void RunDeploymentScriptFromReferences(FileInfo dacpacPackage, string ta
}
}

private void AddSqlCmdVariables(ScriptExecutionArgs args, string targetDatabaseName)
private Dictionary<string, string> AddSqlCmdVariables(string targetDatabaseName)
{
args.Variables.Add("DatabaseName", targetDatabaseName);
var result = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase)
{
{ "DatabaseName", targetDatabaseName }
};

foreach (var variable in DeployOptions.SqlCommandVariableValues)
{
args.Variables.Add(variable.Key, variable.Value);
result.Add(variable.Key, variable.Value);
}

return result;
}

private void HandleDacServicesMessage(object sender, DacMessageEventArgs args)
Expand Down
17 changes: 17 additions & 0 deletions test/DacpacTool.Tests/DacpacTool.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@
<TestTfmsInParallel>false</TestTfmsInParallel>
</PropertyGroup>

<ItemGroup>
<Compile Remove="PackageAnalyzerTests.cs" />
</ItemGroup>

<ItemGroup>
<None Remove="StaticCodeAnalysis.SuppressMessages.xml" />
<None Remove="Suppression\proc1.sql" />
<None Remove="Suppression\proc2.sql" />
</ItemGroup>

<ItemGroup>
<Content Include="PackageAnalyzerTests.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Suppression\proc1.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -28,6 +35,10 @@
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="..\..\src\DacpacTool\Microsoft.SqlTools.ManagedBatchParser.dll" Link="Microsoft.SqlTools.ManagedBatchParser.dll" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
Expand All @@ -45,6 +56,12 @@
<ProjectReference Include="..\..\src\DacpacTool\DacpacTool.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.SqlTools.ManagedBatchParser">
<HintPath>..\..\src\DacpacTool\binaries\Microsoft.SqlTools.ManagedBatchParser.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="SqlServer.Dac.dll">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
Expand Down

0 comments on commit 618aa95

Please sign in to comment.