public void Pack_Upload_ReportError() { // Assemble CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["integration_testing"].ConnectionString); var userId = crmSvc.GetMyCrmUserId(); var trace = new TraceLogger(); Guid id = Guid.NewGuid(); var tempFolder = Path.Combine(Path.GetTempPath(), id.ToString()); Directory.CreateDirectory(tempFolder); try { var config = new ConfigFile { solutions = new List <SolutionPackageConfig> { new SolutionPackageConfig { solution_uniquename = "spkltestsolution", packagepath = "packager", increment_on_import = true } }, filePath = tempFolder }; // Create packaging task var task = new SolutionPackagerTask(crmSvc, trace); using (var ctx = new OrganizationServiceContext(crmSvc)) { ctx.MergeOption = MergeOption.NoTracking; task.UnPack(ctx, config); // Delete the Account relationship File.Delete(Path.Combine(config.filePath, @"packager\Other\Relationships\Account.xml")); bool correctError = false; try { var solutionZipTempPath = Path.GetTempFileName(); task.Pack(ctx, config, true); } catch (Exception ex) { // this is expected correctError = ex.Message.Contains("The element 'EntityRelationship' has incomplete content."); } Assert.IsTrue(correctError, "Error reported"); } } finally { try { Directory.Delete(tempFolder, true); } catch { } } }
public void Pack_Upload() { // Assemble CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["integration_testing"].ConnectionString); var userId = crmSvc.GetMyCrmUserId(); var trace = new TraceLogger(); Guid id = Guid.NewGuid(); var tempFolder = Path.Combine(Path.GetTempPath(), id.ToString()); Directory.CreateDirectory(tempFolder); try { var config = new ConfigFile { solutions = new List <SolutionPackageConfig> { new SolutionPackageConfig { solution_uniquename = "spkltestsolution", packagepath = "packager", increment_on_import = true } }, filePath = tempFolder }; // Create packaging task var task = new SolutionPackagerTask(crmSvc, trace); using (var ctx = new OrganizationServiceContext(crmSvc)) { ctx.MergeOption = MergeOption.NoTracking; task.UnPack(ctx, config); // Get current solution version var version = task.GetSolution("spkltestsolution").Version; task.Pack(ctx, config, true); var versionAfterUpload = task.GetSolution("spkltestsolution").Version; Assert.AreNotEqual(version, versionAfterUpload, "Version incremented"); } } finally { Directory.Delete(tempFolder, true); } }
public void UnpackSolution() { // Assemble CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["integration_testing"].ConnectionString); var userId = crmSvc.GetMyCrmUserId(); var trace = new TraceLogger(); Guid id = Guid.NewGuid(); var tempFolder = Path.Combine(Path.GetTempPath(), id.ToString()); Directory.CreateDirectory(tempFolder); try { var config = new ConfigFile { solutions = new List <SolutionPackageConfig> { new SolutionPackageConfig { solution_uniquename = "spkltestsolution", packagepath = "packager" } }, filePath = tempFolder }; CreateSolution(crmSvc); // Create packaging task var task = new SolutionPackagerTask(crmSvc, trace); using (var ctx = new OrganizationServiceContext(crmSvc)) { ctx.MergeOption = MergeOption.NoTracking; task.UnPack(ctx, config); } // Check that the account entity.xml is present in the output folder bool exists = File.Exists(Path.Combine(tempFolder, @"packager\Entities\Account\Entity.xml")); Assert.IsTrue(exists, "Account entity exists"); } finally { Directory.Delete(tempFolder, true); } }
private static void RunTask(CommandLineArgs arguments, IOrganizationService service, ITrace trace) { if (arguments.Path == null) { arguments.Path = Directory.GetCurrentDirectory(); } else { // Strip trailing \ arguments.Path = arguments.Path.TrimEnd('\\'); arguments.Path = Path.Combine(Directory.GetCurrentDirectory(), arguments.Path); } BaseTask task = null; string command = arguments.Task.ToLower(); switch (command) { case "plugins": trace.WriteLine("Deploying Plugins"); task = new DeployPluginsTask(service, trace); break; case "workflow": trace.WriteLine("Deploying Custom Workflow Activities"); task = new DeployWorkflowActivitiesTask(service, trace); break; case "webresources": trace.WriteLine("Deploying WebResources"); task = new DeployWebResourcesTask(service, trace); break; case "instrument": trace.WriteLine("Downloading Plugin/Workflow Activity Metadata"); task = new DownloadPluginMetadataTask(service, trace); break; case "download-webresources": trace.WriteLine("Downloading Webresources"); task = new DownloadWebresourceFileTask(service, trace) { Overwrite = arguments.Overwrite }; break; case "get-webresources": trace.WriteLine("Downloading Webresources"); task = new DownloadWebresourceConfigTask(service, trace); task.Prefix = arguments.Prefix; break; case "earlybound": trace.WriteLine("Generating early bound types"); var earlyBound = new EarlyBoundClassGeneratorTask(service, trace); task = earlyBound; earlyBound.ConectionString = arguments.Connection; break; case "unpack": trace.WriteLine("Unpacking solution"); var packager = new SolutionPackagerTask(service, trace); packager.command = command; task = packager; break; case "unpacksolution": trace.WriteLine("Unpacking solution Zip"); var unpackfromsolution = new SolutionPackagerTask(service, trace); unpackfromsolution.command = command; task = unpackfromsolution; break; case "pack": trace.WriteLine("Packing Solution"); var pack = new SolutionPackagerTask(service, trace); pack.command = command; task = pack; break; case "import": trace.WriteLine("Packing & Import Solution"); var import = new SolutionPackagerTask(service, trace); import.command = command; task = import; break; case "compare": trace.WriteLine("Comparing Solution"); var compare = new SolutionPackagerTask(service, trace); compare.command = command; task = compare; break; } if (task != null) { if (arguments.Profile != null) { task.Profile = arguments.Profile; } task.Execute(arguments.Path); } else { throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.NO_TASK_SUPPLIED, String.Format("Task '{0}' not recognised. Please consult help!", arguments.Task.ToLower())); } }