From df72bce5b0b6a0617eecbff661cbfe49e8f63440 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:04:30 +0300 Subject: [PATCH] Revert "CLI: Add nightly package source to the package source mappings" This reverts commit 8b6c8d555575e8c818a8119e3a6d0a52ba3f17c6. --- .../PackagePreviewSwitcher.cs | 8 +- .../PackageSourceManager.cs | 82 ------------------- 2 files changed, 1 insertion(+), 89 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs index b17b4250f4..9e65595182 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs @@ -132,7 +132,6 @@ public class PackagePreviewSwitcher : ITransientDependency var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder); _packageSourceManager.Remove(solutionFolder, "ABP Nightly"); - _packageSourceManager.RemovePackageSourceMapping(solutionFolder, "ABP Nightly"); await _nugetPackagesVersionUpdater.UpdateSolutionAsync( solutionPath, @@ -178,13 +177,10 @@ public class PackagePreviewSwitcher : ITransientDependency foreach (var project in projects) { var folder = Path.GetDirectoryName(project); - var solutionFolder = FindSolutionFolder(project) ?? folder; - _packageSourceManager.Add(solutionFolder, "ABP Nightly", + _packageSourceManager.Add(FindSolutionFolder(project) ?? folder, "ABP Nightly", "https://www.myget.org/F/abp-nightly/api/v3/index.json"); - _packageSourceManager.AddPackageSourceMapping(solutionFolder, "ABP Nightly", "Volo.*"); - await _nugetPackagesVersionUpdater.UpdateSolutionAsync( project, true); @@ -204,8 +200,6 @@ public class PackagePreviewSwitcher : ITransientDependency _packageSourceManager.Add(solutionFolder, "ABP Nightly", "https://www.myget.org/F/abp-nightly/api/v3/index.json"); - - _packageSourceManager.AddPackageSourceMapping(solutionFolder, "ABP Nightly", "Volo.*"); if (solutionPath != null) { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageSourceManager.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageSourceManager.cs index cf93c93fa1..90364781d3 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageSourceManager.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageSourceManager.cs @@ -108,88 +108,6 @@ public class PackageSourceManager : ITransientDependency } } - public void AddPackageSourceMapping(string solutionFolder, string sourceKey, string sourceValue) - { - var nugetConfigPath = GetNugetConfigPath(solutionFolder); - if (!File.Exists(nugetConfigPath)) - { - return; - } - - var fileContent = File.ReadAllText(nugetConfigPath); - if (fileContent.Contains($"")) - { - return; - } - - try - { - var doc = new XmlDocument() { PreserveWhitespace = true }; - - doc.Load(GenerateStreamFromString(fileContent)); - - var sourceNodes = doc.SelectNodes("/configuration/packageSourceMapping"); - - var newNode = doc.CreateElement("packageSource"); - - var keyAttr = doc.CreateAttribute("key"); - keyAttr.Value = sourceKey; - newNode.Attributes.Append(keyAttr); - - var packageNode = doc.CreateElement("package"); - - var patternAttr = doc.CreateAttribute("pattern"); - patternAttr.Value = sourceValue; - packageNode.Attributes.Append(patternAttr); - - newNode.AppendChild(packageNode); - - sourceNodes?[0]?.AppendChild(newNode); - - File.WriteAllText(nugetConfigPath, doc.OuterXml); - } - catch - { - Logger.LogWarning($"Adding \"{sourceValue}\" ({sourceKey}) to package source mapping FAILED."); - } - } - - public void RemovePackageSourceMapping(string solutionFolder, string sourceKey) - { - var nugetConfigPath = GetNugetConfigPath(solutionFolder); - if (!File.Exists(nugetConfigPath)) - { - return; - } - - var fileContent = File.ReadAllText(nugetConfigPath); - if (!fileContent.Contains($"")) - { - return; - } - - Logger.LogInformation($"Removing \"{sourceKey}\" from nuget package source mappings..."); - - try - { - var doc = new XmlDocument() { PreserveWhitespace = true }; - - doc.Load(GenerateStreamFromString(fileContent)); - - var nodes = doc.SelectNodes($"/configuration/packageSourceMapping/packageSource[@key='{sourceKey}']"); - if (nodes != null && nodes.Count > 0) - { - nodes[0]!.ParentNode?.RemoveChild(nodes[0]); - } - - File.WriteAllText(nugetConfigPath, doc.OuterXml); - } - catch - { - Logger.LogWarning($"Removing \"{sourceKey}\" from package source mappings FAILED."); - } - } - private static string GetNugetConfigPath(string solutionFolder) { return Path.Combine(solutionFolder, "NuGet.Config");