public GatheredObject GatherDependencies(Curation.Data.Plugin plugin) { var root = new GatheredObject(plugin); foreach (var lma in plugin.LoadModuleAssemblies) { root.Children.Add(new GatheredObject(lma)); } return(root); }
private void UploadFile(IRDMPPlatformRepositoryServiceLocator repositoryLocator, ICheckNotifier checkNotifier, FileInfo toCommit, Version pluginVersion, Version rdmpDependencyVersion) { // delete EXACT old versions of the Plugin var oldVersion = repositoryLocator.CatalogueRepository.GetAllObjects <Curation.Data.Plugin>().SingleOrDefault(p => p.Name.Equals(toCommit.Name) && p.PluginVersion == pluginVersion); if (oldVersion != null) { throw new Exception("There is already a plugin called " + oldVersion.Name); } try { var plugin = new Curation.Data.Plugin(repositoryLocator.CatalogueRepository, toCommit, pluginVersion, rdmpDependencyVersion); //add the new binary new LoadModuleAssembly(repositoryLocator.CatalogueRepository, toCommit, plugin); } catch (Exception e) { checkNotifier.OnCheckPerformed(new CheckEventArgs("Failed processing plugin " + toCommit.Name, CheckResult.Fail, e)); throw; } }
public int Run(IRDMPPlatformRepositoryServiceLocator repositoryLocator, IDataLoadEventListener listener, ICheckNotifier checkNotifier, GracefulCancellationToken token) { var toCommit = new FileInfo(_packOpts.File); if (!toCommit.Exists) { throw new FileNotFoundException("Could not find file '" + toCommit + "'"); } if (toCommit.Extension.ToLowerInvariant() != PluginPackageSuffix) { throw new NotSupportedException("Plugins must be packaged as " + PluginPackageSuffix); } //the version of the plugin e.g. MyPlugin.nupkg version 1.0.0.0 Version pluginVersion; //the version of rdmp on which the package depends on (e.g. 3.0) Version rdmpDependencyVersion; //find the manifest that lists name, version etc using (var zf = ZipFile.OpenRead(toCommit.FullName)) { var manifests = zf.Entries.Where(e => e.FullName.EndsWith(PluginPackageManifest)).ToArray(); if (manifests.Length != 1) { throw new Exception("Found " + manifests.Length + " files in plguin with the extension " + PluginPackageManifest); } using (var s = manifests[0].Open()) { var doc = XDocument.Load(s); var ns = doc.Root.GetDefaultNamespace();// XNamespace.Get("http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"); var versionNode = doc.Root.Element(ns + "metadata").Element(ns + "version"); if (versionNode == null) { throw new Exception("Could not find version tag"); } pluginVersion = new Version(versionSuffix.Replace(versionNode.Value, "")); var rdmpDependencyNode = doc.Descendants(ns + "dependency").FirstOrDefault(e => e.Attribute("id").Value == "HIC.RDMP.Plugin"); if (rdmpDependencyNode == null) { throw new Exception("Expected a single <dependency> tag with id = HIC.RDMP.Plugin (in order to determine plugin compatibility). Ensure your nuspec file includes a dependency on this package."); } rdmpDependencyVersion = new Version(versionSuffix.Replace(rdmpDependencyNode.Attribute("version").Value, "")); } } var runningSoftwareVersion = new Version(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion); if (!rdmpDependencyVersion.IsCompatibleWith(runningSoftwareVersion, 2)) { throw new NotSupportedException(string.Format("Plugin version {0} is incompatible with current running version of RDMP ({1}).", pluginVersion, runningSoftwareVersion)); } // delete EXACT old versions of the Plugin var oldVersion = repositoryLocator.CatalogueRepository.GetAllObjects <Curation.Data.Plugin>().SingleOrDefault(p => p.Name.Equals(toCommit.Name) && p.PluginVersion == pluginVersion); if (oldVersion != null) { throw new Exception("There is already a plugin called " + oldVersion.Name); } try { var plugin = new Curation.Data.Plugin(repositoryLocator.CatalogueRepository, toCommit, pluginVersion, rdmpDependencyVersion); //add the new binary new LoadModuleAssembly(repositoryLocator.CatalogueRepository, toCommit, plugin); } catch (Exception e) { checkNotifier.OnCheckPerformed(new CheckEventArgs("Failed processing plugin " + toCommit.Name, CheckResult.Fail, e)); throw; } return(0); }