Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/DacFXTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
&& int.TryParse(args[1], out int dbTypeInt)
&& bool.TryParse(args[0], out bool mergeDacpacs))
{
SchemaInfo[] schemas = null;

Check warning on line 33 in src/DacFXTool/Program.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 33 in src/DacFXTool/Program.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
if (args.Length == 4)
{
schemas = args[3].Split(',').Select(s => new SchemaInfo { Name = s }).ToArray();
Expand Down Expand Up @@ -149,6 +149,27 @@

return 0;
}

// unpack "dacpac path" "output path"
if (args.Length == 3
&& args[0] == "unpack")
{
if (!new FileInfo(args[1]).Exists)
{
await Console.Out.WriteLineAsync("Error:");
await Console.Out.WriteLineAsync($"DACPAC file '{args[1]}' not found");
return 1;
}

var unpacker = new DacPackageUnpacker();

unpacker.Unpack(args[1], args[2]);

await Console.Out.WriteLineAsync("Result:");
await Console.Out.WriteLineAsync("OK");

return 0;
}
}
else
{
Expand Down
19 changes: 19 additions & 0 deletions src/DacFXToolLib/DacPackageUnpacker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.SqlServer.Dac;
Comment thread
ErikEJ marked this conversation as resolved.
using System.IO;

namespace DacFXToolLib
{
public class DacPackageUnpacker
{
public void Unpack(string dacpacPath, string outputPath)
{
// Ensure output directory exists
Directory.CreateDirectory(outputPath);

using (var package = DacPackage.Load(dacpacPath))
{
DacServices.Unpack(package, outputPath);
}
}
}
}
Loading