-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for refactor log script files #47
Changes from 3 commits
104b42a
f00f79c
4d7ee7f
56a0b5d
0830207
506139c
5a7dadf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using System.CommandLine.Invocation; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Microsoft.SqlServer.Dac; | ||
using Microsoft.SqlServer.Dac.Model; | ||
|
||
namespace MSBuild.Sdk.SqlProj.DacpacTool | ||
|
@@ -16,11 +17,12 @@ static async Task<int> Main(string[] args) | |
new Option<string>(new string[] { "--name", "-n" }, "Name of the package"), | ||
new Option<string>(new string[] { "--version", "-v" }, "Version of the package"), | ||
new Option<FileInfo>(new string[] { "--output", "-o" }, "Filename of the output package"), | ||
new Option<SqlServerVersion>(new string[] { "--sqlServerVersion", "-sv" }, () => SqlServerVersion.Sql150, description: "Target version of the model"), | ||
new Option<SqlServerVersion>(new string[] { "--sqlServerVersion", "-sv" }, () => SqlServerVersion.Sql150, description: "Target version of the model"), | ||
new Option<FileInfo[]>(new string[] { "--input", "-i" }, "Input file name(s)"), | ||
new Option<FileInfo[]>(new string[] { "--reference", "-r" }, "Reference(s) to include"), | ||
new Option<FileInfo>(new string[] { "--predeploy" }, "Filename of optional pre-deployment script"), | ||
new Option<FileInfo>(new string[] { "--postdeploy" }, "Filename of optional post-deployment script"), | ||
new Option<FileInfo>(new string[] { "--refactorlog" }, "Filename of optional refactor log script"), | ||
new Option<string[]>(new string[] { "--property", "-p" }, "Properties to be set on the model"), | ||
new Option<string[]>(new string[] { "--sqlcmdvar", "-sc" }, "SqlCmdVariable(s) to include"), | ||
}; | ||
|
@@ -94,7 +96,7 @@ private static int BuildDacpac(BuildOptions options) | |
} | ||
|
||
// Save the package to disk | ||
packageBuilder.SaveToDisk(options.Output); | ||
packageBuilder.SaveToDisk(options.Output, new PackageOptions() { RefactorLogPath = options.RefactorLog?.FullName }); | ||
|
||
// Add predeployment and postdeployment scripts (must happen after SaveToDisk) | ||
packageBuilder.AddPreDeploymentScript(options.PreDeploy, options.Output); | ||
|
@@ -129,7 +131,8 @@ private static int DeployDacpac(DeployOptions options) | |
} | ||
|
||
deployer.UseTargetServer(options.TargetServerName); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
if (!string.IsNullOrWhiteSpace(options.TargetUser)) | ||
{ | ||
deployer.UseSqlAuthentication(options.TargetUser, options.TargetPassword); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
<!-- | ||
Set LanguageTargets to Microsoft.Common.targets for any project that the SDK won't (.proj, .noproj, etc) | ||
https://github.com/dotnet/sdk/blob/50ddfbb91be94d068514e8f4b0ce1052156364a0/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L28 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert removed line breaks (?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, could not see it was whitespace removals... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
We can't default LanguageTargets it is set in the SDK and immediately imported. So we can only default | ||
it if we know the SDK won't. Projects probably won't load in Visual Studio but will build from the | ||
command-line just fine. | ||
|
@@ -21,7 +20,6 @@ | |
<Import Project="$(CustomBeforeNoTargets)" Condition="'$(CustomBeforeNoTargets)' != '' and Exists('$(CustomBeforeNoTargets)')" /> | ||
|
||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition=" '$(CommonTargetsPath)' == '' " /> | ||
|
||
<ItemGroup> | ||
<!-- Override primary output path to be a .dacpac --> | ||
<_IntermediateAssembly Include="@(IntermediateAssembly)" /> | ||
|
@@ -76,7 +74,6 @@ | |
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets" | ||
Condition="'$(DebuggerFlavor)' == '' And Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets')" /> | ||
|
||
|
||
<!-- | ||
The GetTargetPathWithTargetPlatformMoniker target uses a BeforeTargets so the only way to disable it is to override it with an empty target. | ||
--> | ||
|
@@ -125,7 +122,6 @@ | |
|
||
<DacpacFile>%(_ResolvedPackageReference.PhysicalLocation)/tools/%(Identity).dacpac</DacpacFile> | ||
</_ResolvedPackageReference> | ||
|
||
<!-- Build a list of package references that include a dacpac file matching the package identity in their tools folder --> | ||
<DacpacReference Include="@(_ResolvedPackageReference)" Condition="Exists(%(DacpacFile))" /> | ||
</ItemGroup> | ||
|
@@ -156,7 +152,8 @@ | |
<SqlCmdVariableArguments>@(SqlCmdVariable->'-sc %(Identity)', ' ')</SqlCmdVariableArguments> | ||
<PreDeploymentScriptArgument>@(PreDeploy->'--predeploy %(Identity)', ' ')</PreDeploymentScriptArgument> | ||
<PostDeploymentScriptArgument>@(PostDeploy->'--postdeploy %(Identity)', ' ')</PostDeploymentScriptArgument> | ||
<DacpacToolCommand>dotnet $(DacpacToolExe) build $(OutputPathArgument) $(MetadataArguments) $(SqlServerVersionArgument) $(InputFileArguments) $(ReferenceArguments) $(SqlCmdVariableArguments) $(PropertyArguments) $(PreDeploymentScriptArgument) $(PostDeploymentScriptArgument)</DacpacToolCommand> | ||
<RefactorLogScriptArgument>@(RefactorLog->'--refactorlog %(Identity)', ' ')</RefactorLogScriptArgument> | ||
<DacpacToolCommand>dotnet $(DacpacToolExe) build $(OutputPathArgument) $(MetadataArguments) $(SqlServerVersionArgument) $(InputFileArguments) $(ReferenceArguments) $(SqlCmdVariableArguments) $(PropertyArguments) $(PreDeploymentScriptArgument) $(PostDeploymentScriptArgument) $(RefactorLogScriptArgument)</DacpacToolCommand> | ||
</PropertyGroup> | ||
<!-- Run it, except during design-time builds --> | ||
<Message Importance="Low" Text="Running command: $(DacpacToolCommand)" /> | ||
|
@@ -188,5 +185,4 @@ | |
<Message Importance="Low" Text="Running command: $(DacpacToolCommand)" /> | ||
<Exec Command="$(DacpacToolCommand)" /> | ||
</Target> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
jmezach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Operations Version="1.0" xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02"> | ||
<Operation Name="Rename Refactor" Key="28824ed4-6ce7-42ae-9814-c7409c6e1a8a" ChangeDateTime="09/01/2020 18:56:35"> | ||
<Property Name="ElementName" Value="[dbo].[Product].[price]" /> | ||
<Property Name="ElementType" Value="SqlSimpleColumn" /> | ||
<Property Name="ParentElementName" Value="[dbo].[Product]" /> | ||
<Property Name="ParentElementType" Value="SqlTable" /> | ||
<Property Name="NewName" Value="Price" /> | ||
</Operation> | ||
<Operation Name="Rename Refactor" Key="04c343fa-e6d3-4923-ab01-28a60ddd553f" ChangeDateTime="09/01/2020 18:56:38"> | ||
<Property Name="ElementName" Value="[dbo].[Product].[description]" /> | ||
<Property Name="ElementType" Value="SqlSimpleColumn" /> | ||
<Property Name="ParentElementName" Value="[dbo].[Product]" /> | ||
<Property Name="ParentElementType" Value="SqlTable" /> | ||
<Property Name="NewName" Value="Description" /> | ||
</Operation> | ||
<Operation Name="Rename Refactor" Key="119b3933-c2e4-476c-877b-40c376bf2bde" ChangeDateTime="09/01/2020 18:56:42"> | ||
<Property Name="ElementName" Value="[dbo].[Product].[name]" /> | ||
<Property Name="ElementType" Value="SqlSimpleColumn" /> | ||
<Property Name="ParentElementName" Value="[dbo].[Product]" /> | ||
<Property Name="ParentElementType" Value="SqlTable" /> | ||
<Property Name="NewName" Value="Name" /> | ||
</Operation> | ||
</Operations> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done