public List <DepConfig> GetPackagesFromPackagesDotConfig(string projectPath) { var packages = new List <DepConfig>(); var projectDir = FileHelper.GetParentDirectory(projectPath); var packageJsonFilePath = Path.Join(projectDir, "packages.config"); if (File.Exists(packageJsonFilePath)) { XDocument document = XDocument.Load(packageJsonFilePath, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var packageElements = document.Root.Elements("package"); if (packageElements?.Any() == true) { foreach (var package in packageElements) { var depConfig = new DepConfig(package); packages.Add(depConfig); } } } return(packages); }
private void miEditConfig_Click(object sender, EventArgs e) { frmEditConfigItems editor = new frmEditConfigItems(); editor.Configuration = this.config.Copy(); if (editor.ShowDialog() == DialogResult.OK) { this.config = editor.Configuration; this.SaveConfig(); this.LoadConfig(); this.InitializeForm(); } }
private void LoadConfig() { try { //Get config string path = GetConfigPath(); DepConfig cfg = null; XmlSerializer cherios = new XmlSerializer(typeof(DepConfig)); if (File.Exists(path)) { using (var fs = File.OpenRead(path)) { cfg = cherios.Deserialize(fs) as DepConfig; } } else if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } if (cfg == null) { //Create default config cfg = new DepConfig(); cfg.Items = new List<DepConfigItem>() { new DepConfigItem() { ContainerKind = DependencyUpdater.Container.Component, Name = "Shared Component 1", PackageExpression = @"^SharedComponent\.[0-9]+\.[0-9]+\.[0-9]+$", RelativePackagePathToBinaries = @"lib\net40-full", FileGlobs = new List<string>() { "*.dll", "*.xml", "*.pdb" }, Path = @"C:\Code\A component\bin\Debug" }, new DepConfigItem() { ContainerKind = DependencyUpdater.Container.Project, Name = "My Special Project", Path = @"C:\Code\MySpecialProject\packages" } }; using (var fs = File.Open(GetConfigPath(), FileMode.Create)) { cherios.Serialize(fs, cfg); } } this.config = cfg; } catch (Exception ex) { HandleError(ex); } }