Skip to content
Open
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
6 changes: 3 additions & 3 deletions spkl/SparkleXrm.Tasks.Tests/TestPackager..cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void Pack()
ctx.MergeOption = MergeOption.NoTracking;
task.UnPack(ctx, config);

task.Pack(ctx, config, false);
task.Pack(ctx, config, false, false);


}
Expand Down Expand Up @@ -162,7 +162,7 @@ public void Pack_Upload()

// Get current solution version
var version = task.GetSolution("spkltestsolution").Version;
task.Pack(ctx, config, true);
task.Pack(ctx, config, true, true);
var versionAfterUpload = task.GetSolution("spkltestsolution").Version;
Assert.AreNotEqual(version, versionAfterUpload, "Version incremented");
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public void Pack_Upload_ReportError()
try
{
var solutionZipTempPath = Path.GetTempFileName();
task.Pack(ctx, config, true);
task.Pack(ctx, config, true, true);
}
catch (Exception ex)
{
Expand Down
33 changes: 22 additions & 11 deletions spkl/SparkleXrm.Tasks/Tasks/SolutionPackagerTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SolutionPackagerTask : BaseTask
public string ConectionString { get; set; }
private string _folder;
public string command;
private string solutionZipTempPath;

public SolutionPackagerTask(IOrganizationService service, ITrace trace) : base(service, trace)
{
Expand Down Expand Up @@ -51,12 +52,17 @@ protected override void ExecuteInternal(string folder, OrganizationServiceContex
break;

case "pack":
Pack(ctx, config, false);
Pack(ctx, config, false, false);
break;

case "import":
var solutionZipTempPath = Path.GetTempFileName();
Pack(ctx, config, true);
solutionZipTempPath = Path.GetTempFileName();
Pack(ctx, config, true, true);
break;

case "importskippublish":
solutionZipTempPath = Path.GetTempFileName();
Pack(ctx, config, true, false);
break;

case "export":
Expand Down Expand Up @@ -137,7 +143,7 @@ public void UnPackFromSolutionZip(ConfigFile config)
}
}

public void Pack(OrganizationServiceContext ctx, ConfigFile config, bool import)
public void Pack(OrganizationServiceContext ctx, ConfigFile config, bool import, bool publishSolution)
{
var configs = config.GetSolutionConfig(this.Profile);
foreach (var solutionPackagerConfig in configs)
Expand All @@ -152,7 +158,7 @@ public void Pack(OrganizationServiceContext ctx, ConfigFile config, bool import)
if (import)
{
// Import solution into Dynamics
ImportSolution(solutionLocation);
ImportSolution(solutionLocation, publishSolution);
}
}
}
Expand Down Expand Up @@ -268,7 +274,7 @@ private void ExportUnmanagedSolution(SolutionPackageConfig config, string filePa
}
}

private void ImportSolution(string solutionPath)
private void ImportSolution(string solutionPath, bool publishSolution)
{
_trace.WriteLine("Importing solution '{0}'...", solutionPath);
var solutionBytes = File.ReadAllBytes(solutionPath);
Expand Down Expand Up @@ -330,11 +336,16 @@ private void ImportSolution(string solutionPath)
{
throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.IMPORT_ERROR, importError);
}
_trace.WriteLine("\nSolution Import Completed. Now publishing....");
// Publish
var publishRequest = new PublishAllXmlRequest();
var publishResponse = (PublishAllXmlResponse)_service.Execute(publishRequest);
_trace.WriteLine("Solution Publish Completed");
_trace.WriteLine("\nSolution Import Completed.");

if (publishSolution)
{
// Publish
_trace.WriteLine("Now publishing....");
var publishRequest = new PublishAllXmlRequest();
var publishResponse = (PublishAllXmlResponse)_service.Execute(publishRequest);
_trace.WriteLine("Solution Publish Completed");
}
}

private string GetRandomFolder()
Expand Down