Skip to content

Commit 6f81d05

Browse files
committed
Adds #204 - unpack from zip
1 parent 97cfe30 commit 6f81d05

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

spkl/SparkleXrm.Tasks/Tasks/SolutionPackagerTask.cs

+24-7
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ protected override void ExecuteInternal(string folder, OrganizationServiceContex
4545
case "unpack":
4646
UnPack(ctx, config);
4747
break;
48+
case "unpacksolution":
49+
UnPackFromSolutionZip(config);
50+
break;
4851
case "pack":
49-
5052
Pack(ctx, config, false);
5153
break;
5254
case "import":
@@ -74,6 +76,17 @@ public void UnPack(OrganizationServiceContext ctx, ConfigFile config)
7476
}
7577
}
7678

79+
public void UnPackFromSolutionZip(ConfigFile config)
80+
{
81+
var configs = config.GetSolutionConfig(this.Profile);
82+
foreach (var solutionPackagerConfig in configs)
83+
{
84+
var solutionZip = Path.Combine(config.filePath, solutionPackagerConfig.solutionpath);
85+
var movetoFolder = Path.Combine(config.filePath, solutionPackagerConfig.packagepath);
86+
UnpackSolutionZip(solutionPackagerConfig, movetoFolder, solutionZip);
87+
}
88+
}
89+
7790
public void Pack(OrganizationServiceContext ctx, ConfigFile config, bool import)
7891
{
7992
var configs = config.GetSolutionConfig(this.Profile);
@@ -84,7 +97,7 @@ public void Pack(OrganizationServiceContext ctx, ConfigFile config, bool import)
8497

8598
var version = GetSolutionVersion(packageFolder);
8699

87-
// Create the solution zip in the root or the location specified in the spkl.jsomn
100+
// Create the solution zip in the root or the location specified in the spkl.json
88101
if (solutionPackagerConfig.solutionpath != null)
89102
{
90103
solutionZipPath = String.Format(solutionPackagerConfig.solutionpath,
@@ -223,7 +236,7 @@ private string GetRandomFolder()
223236

224237
private string UnPackSolution(SolutionPackageConfig solutionPackagerConfig, string targetFolder)
225238
{
226-
239+
227240
// Extract solution
228241
var request = new ExportSolutionRequest
229242
{
@@ -247,7 +260,14 @@ private string UnPackSolution(SolutionPackageConfig solutionPackagerConfig, stri
247260
// Save solution
248261
var solutionZipPath = Path.GetTempFileName();
249262
File.WriteAllBytes(solutionZipPath, response.ExportSolutionFile);
250-
263+
264+
UnpackSolutionZip(solutionPackagerConfig, targetFolder, solutionZipPath);
265+
266+
return targetFolder;
267+
}
268+
269+
private void UnpackSolutionZip(SolutionPackageConfig solutionPackagerConfig, string targetFolder, string solutionZipPath)
270+
{
251271
var binPath = GetPackagerFolder();
252272
var binFolder = new FileInfo(binPath).DirectoryName;
253273

@@ -262,11 +282,8 @@ private string UnPackSolution(SolutionPackageConfig solutionPackagerConfig, stri
262282
);
263283

264284
RunPackager(binPath, binFolder, parameters);
265-
266-
return targetFolder;
267285
}
268286

269-
270287

271288
private string PackSolution(string rootPath, SolutionPackageConfig solutionPackagerConfig, string solutionZipPath)
272289
{

spkl/spkl/Program.cs

+6
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ private static void RunTask(CommandLineArgs arguments, IOrganizationService serv
339339
packager.command = command;
340340
task = packager;
341341
break;
342+
case "unpacksolution":
343+
trace.WriteLine("Unpacking solution Zip");
344+
var unpackfromsolution = new SolutionPackagerTask(service, trace);
345+
unpackfromsolution.command = command;
346+
task = unpackfromsolution;
347+
break;
342348
case "pack":
343349
trace.WriteLine("Packing Solution");
344350
var pack = new SolutionPackagerTask(service, trace);

0 commit comments

Comments
 (0)