protected override void ProcessRecord() { base.ProcessRecord(); WriteVerbose("Plugin Registration intiated"); if (UseSplitAssembly) { if (!File.Exists(ProjectFilePath)) { throw new Exception("Project File Path is required if you want to split assembly."); } if (RegistrationType == RegistrationTypeEnum.Delsert) { throw new Exception("Registration type 'Remove Plugin Types and Steps which are not in mapping and Upsert' will not work when 'Split Assembly' is enabled."); } if (!File.Exists(MappingFile)) { throw new Exception("Mapping Json Path is required if you want to split assembly."); } } var assemblyInfo = AssemblyInfo.GetAssemblyInfo(AssemblyPath); WriteVerbose($"Assembly Name: {assemblyInfo.AssemblyName}"); WriteVerbose($"Assembly Version: {assemblyInfo.Version}"); using (var context = new CIContext(OrganizationService)) { var pluginRegistrationHelper = new PluginRegistrationHelper(OrganizationService, context, WriteVerbose, WriteWarning); WriteVerbose("PluginRegistrationHelper intiated"); Assembly pluginAssembly = null; Guid pluginAssemblyId = Guid.Empty; if (File.Exists(MappingFile)) { pluginAssembly = pluginRegistrationHelper.ReadMappingFile(MappingFile); pluginAssemblyId = pluginAssembly.Id ?? Guid.Empty; } else { pluginAssemblyId = pluginRegistrationHelper.UpsertPluginAssembly(pluginAssembly, assemblyInfo, SolutionName, RegistrationType); WriteVerbose($"UpsertPluginAssembly {pluginAssemblyId} completed"); WriteVerbose("Plugin Registration completed"); return; } if (pluginAssembly == null) { WriteVerbose("Plugin Registration completed"); return; } if (pluginAssembly.PluginTypes == null) { WriteVerbose("No mapping found for types."); WriteVerbose("Plugin Registration completed"); return; } if (RegistrationType == RegistrationTypeEnum.Delsert) { WriteVerbose($"RemoveComponentsNotInMapping {assemblyInfo.AssemblyName} started"); pluginRegistrationHelper.RemoveComponentsNotInMapping(pluginAssembly); WriteVerbose($"RemoveComponentsNotInMapping {assemblyInfo.AssemblyName} completed"); RegistrationType = RegistrationTypeEnum.Upsert; } if (UseSplitAssembly) { foreach (var type in pluginAssembly.PluginTypes) { UploadSplitAssembly(assemblyInfo, pluginRegistrationHelper, type); } } else { WriteVerbose($"UpsertPluginAssembly {pluginAssemblyId} started"); pluginAssemblyId = pluginRegistrationHelper.UpsertPluginAssembly(pluginAssembly, assemblyInfo, SolutionName, RegistrationType); WriteVerbose($"UpsertPluginAssembly {pluginAssemblyId} completed"); foreach (var type in pluginAssembly.PluginTypes) { pluginRegistrationHelper.UpsertPluginTypeAndSteps(pluginAssemblyId, type, SolutionName, RegistrationType); } } } WriteVerbose("Plugin Registration completed"); }