/// <summary> /// Initializes a new instance of the <see cref="Nuget"/> class. /// </summary> /// <param name="data">The data.</param> public Nuget(NugetInfo <RefNugetInfo> data) { this.Path = data.Path; this.Name = data.Name; base.Items = data.Items; base.NugetVersion = data.NugetVersion; }
public static void DoPublish(SelectedProjectInfo selectedProject, NugetInfo projectNugetInfo) { // if (!File.Exists(@"..\.nuget\NuGet.exe")) // { // //TODO:提示用户没有..\.nuget\NuGet.exe这个文件 // return; // } GetDebugOrReleaseOutPutPath(selectedProject); }
private async Task DownloadOneNuget(ComposeSettings settings, NugetInfo n, string fileName) { var dl = new DownloadTool(_progressFn); var url = $"https://www.nuget.org/api/v2/package/{n.Name}/{n.Version}"; var dstFile = Path.Combine(settings.TmpDownloadPath, fileName); if (File.Exists(dstFile) == false) { await dl.DownloadFileAsync(url, dstFile); } }
/// <summary> /// Builds the nuget information. /// </summary> /// <param name="assemblyName">Name of the file.</param> /// <param name="path">The path.</param> /// <param name="listItems">The list items.</param> /// <returns>IList<NuspecInfo></NuspecInfo>.</returns> private NugetInfo <RefNugetInfo> BuildReferInfo(string assemblyName, string path, List <FileInfo> listItems) { var referenceAssemblys = this.BuildItemInfo(listItems, assemblyName); var asemblyInfo = new NugetInfo <RefNugetInfo> { Name = assemblyName, Path = path, Items = referenceAssemblys }; return(asemblyInfo); }
public static string GetNugetVersion(string start = null, bool pre = false) { NugetInfo v = APIHelper.CallAPI <NugetInfo>($"https://api-v2v3search-0.nuget.org/query?q=WalkingTec.Mvvm.Mvc&prerelease={pre.ToString().ToLower()}").Result; if (string.IsNullOrEmpty(start)) { return(v.data[0]?.version); } else { return(v.data[0].versions.Select(x => x.version).Where(x => x.StartsWith(start)).Last()); } }
/// <summary> /// Reads the nuget version. /// </summary> /// <param name="nugetInfo">The nuspec information.</param> public static void BuildNugetVersion <U>(this NugetInfo <U> nugetInfo) { var xmlDoc = new XmlDocument(); xmlDoc.Load(nugetInfo.Path); var xmlNodeList = xmlDoc.GetElementsByTagName("version"); foreach (XmlNode node in xmlNodeList) { var version = node.FirstChild.Value; if (version != null) { nugetInfo.NugetVersion = version; } } }
private List <(string src, string dst)> GetFilesToCopy(NugetInfo nugetInfo) { var filesToCopy = new List <(string src, string dst)>(); var dir = $"{nugetInfo.Name}.{nugetInfo.Version}"; var extractionDir = Path.Combine(_composeSettings.TmpExtractionPath, dir); foreach (var copyPath in nugetInfo.CopyPaths) { var s = copyPath.Src.StartsWith("/") ? copyPath.Src.Substring(1) : copyPath.Src; var d = copyPath.Dst.StartsWith("/") ? copyPath.Dst.Substring(1) : copyPath.Dst; var src1 = Path.Combine(extractionDir, s); var dst1 = Path.Combine(_composeSettings.CefSharpEnvPath, d); Io.CreateDirIfNotExist(dst1); var files = GetFiles(src1); var copyList = CreateCopyList(src1, dst1, files); filesToCopy.AddRange(copyList); } return(filesToCopy); }
public NugetInfo LoadNugetInfo(SelectedProjectInfo selectedProject) { NugetInfo nugetInfo = new NugetInfo(); var nugetInfoXmlPath = string.Concat(selectedProject.ProjectDirPath, "\\", NugetInfoXmlDefinition.FileName); if (!File.Exists(nugetInfoXmlPath)) { nugetInfoXmlPath = string.Concat(selectedProject.SolutionDirPath, "\\", NugetInfoXmlDefinition.FileName); } if (!File.Exists(nugetInfoXmlPath)) { return(nugetInfo); } try { nugetInfo.IsLoadXml = true; var nugetInfoXmlDoc = new XmlDocument(); nugetInfoXmlDoc.Load(nugetInfoXmlPath); var nugetInfoNode = nugetInfoXmlDoc.SelectSingleNode(NugetInfoXmlDefinition.RootNodeName); if (nugetInfoNode != null) { var connStringNode = nugetInfoNode.SelectSingleNode(NugetInfoXmlDefinition.AuthKeyNodeName); if (connStringNode != null) { nugetInfo.AuthKey = connStringNode.InnerText; } var templatesNodes = nugetInfoNode.SelectSingleNode(NugetInfoXmlDefinition.NugetSourceUrlNodeName); if (templatesNodes != null) { nugetInfo.NugetSourceUrl = templatesNodes.InnerText; } } } catch (Exception) { // ignored } return(nugetInfo); }
/// <summary> /// Increases the nuget version. /// </summary> /// <param name="nugetInfo">The nuspec information.</param> /// <param name="newVersion">The new version.</param> public static void IncreaseNugetVersion(this NugetInfo <RefNugetInfo> nugetInfo, string newVersion) { var xmlDoc = new XmlDocument(); xmlDoc.Load(nugetInfo.Path); var xmlNodeList = xmlDoc.GetElementsByTagName("version"); foreach (XmlNode node in xmlNodeList) { var curVersion = node.FirstChild.Value; // var increasingVersion = VersionHelper.GetIncreasionVersion(curVersion, 1, 3); if (!string.IsNullOrEmpty(curVersion)) { nugetInfo.NugetVersion = newVersion; node.FirstChild.Value = newVersion; } } // Save change xmlDoc.Save(nugetInfo.Path); }
/// <summary> /// 获取 Nuget 包信息列表 /// </summary> /// <returns>Nuget 包信息列表</returns> public IEnumerable <NugetInfo> GetNugetInfos() { if (!IsGoodFormat()) { throw new InvalidOperationException("无法在格式异常的配置文件中读取 Nuget 信息。"); } var nugetInfoList = new List <NugetInfo>(); var root = _xDocument.Root; var xElements = root.Elements(); foreach (var element in xElements) { var packageInfo = new NugetInfo( element.Attribute(PackagesConfig.IdAttribute).Value, element.Attribute(PackagesConfig.VersionAttribute).Value, element.Attribute(PackagesConfig.TargetFrameworkAttribute).Value); nugetInfoList.Add(packageInfo); } return(nugetInfoList); }
public static string GetNugetVersion(string start = null, bool pre = false) { var Cache = GlobalServices.GetRequiredService <IDistributedCache>() as IDistributedCache; if (Cache.TryGetValue("nugetversion", out NugetInfo rv) == false || rv == null) { NugetInfo v = APIHelper.CallAPI <NugetInfo>($"https://api-v2v3search-0.nuget.org/query?q=WalkingTec.Mvvm.Mvc&prerelease={pre.ToString().ToLower()}").Result; var data = v; Cache.Add("nugetversion", data, new DistributedCacheEntryOptions() { SlidingExpiration = new TimeSpan(0, 0, 36000) }); rv = data; } if (string.IsNullOrEmpty(start)) { return(rv.data[0]?.version); } else { return(rv.data[0].versions.Select(x => x.version).Where(x => x.StartsWith(start)).Last()); } }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> public static void Main(string[] args) { Logger.Debug("NugetToolConsole <- Start"); // Build project info before this sprint var gitPath = "D:\\SMEE_Project\\NADAE_Sprint_4\\Implementation"; var oldBranch = "refs/heads/NADAE-M2_S004_1218"; var listOldProjectInfoModels = BuildAllProjectInfoModel(gitPath, oldBranch); //// Temp save to excel file //var nugetInfos = new List<object[]>(); //foreach (var nugetProjectChanged in listOldProjectInfoModels) //{ // nugetInfos.Add(new object[] { nugetProjectChanged.ProjectName, nugetProjectChanged.NugetVersion }); //} //// Save excel file //ExcelHelper.SaveProjectInfo("D:\\Study project\\NugetVerion.xlsx", nugetInfos); // Build list project info changed var startDat = "06/14/2018"; var endDay = "07/29/2018"; var newBranch = "refs/heads/NADAE-M2_S005_2418_Dev"; var newGitPath = "D:\\SMEE_Project\\NADAE_Sprint_5\\Implementation"; var listChangedProjectInfoModels = BuildChangedProjectInfoModel(newGitPath, newBranch, startDat, endDay); //// Temp save to excel file //var newNugetInfos = new List<object[]>(); //foreach (var nugetProjectChanged in listChangedProjectInfoModels) //{ // newNugetInfos.Add(new object[] { nugetProjectChanged.ProjectName, nugetProjectChanged.NugetVersion }); //} //// Save excel file //ExcelHelper.SaveProjectInfo("D:\\Study project\\NugetVerion1.xlsx", newNugetInfos); // Buildm latest version for project var maxVersion = "1.15.0"; var nugetVersionList = new List <NugetInfo>(); foreach (var changedProjectInfoModel in listChangedProjectInfoModels) { var nugetInfo = new NugetInfo() { NugetName = changedProjectInfoModel.ProjectName }; var oldProjectInfo = listOldProjectInfoModels.FirstOrDefault( p => string.Equals(p.ProjectName, changedProjectInfoModel.ProjectName)); if (oldProjectInfo == null) { nugetInfo.NugetVersion = changedProjectInfoModel.NugetVersion; nugetInfo.OldNugetVersion = changedProjectInfoModel.NugetVersion; nugetInfo.NeedUpgrate = !string.Equals(changedProjectInfoModel.NugetVersion, maxVersion); } else { if (string.Equals(changedProjectInfoModel.NugetVersion, oldProjectInfo.NugetVersion) && string.Equals(changedProjectInfoModel.NugetVersion, maxVersion)) { nugetInfo.NugetVersion = maxVersion; nugetInfo.OldNugetVersion = maxVersion; nugetInfo.NeedUpgrate = false; } else if (string.Equals(changedProjectInfoModel.NugetVersion, oldProjectInfo.NugetVersion) && !string.Equals(changedProjectInfoModel.NugetVersion, maxVersion)) { nugetInfo.NugetVersion = changedProjectInfoModel.NugetVersion; nugetInfo.OldNugetVersion = oldProjectInfo.NugetVersion; nugetInfo.NeedUpgrate = true; } else if (!string.Equals(changedProjectInfoModel.NugetVersion, oldProjectInfo.NugetVersion)) { nugetInfo.OldNugetVersion = VersionHelper.GetLowerVersion( changedProjectInfoModel.NugetVersion, oldProjectInfo.NugetVersion); nugetInfo.NugetVersion = VersionHelper.GetHigherVersion(changedProjectInfoModel.NugetVersion, oldProjectInfo.NugetVersion); nugetInfo.NeedUpgrate = VersionHelper.IsNeedToChangeVersion(changedProjectInfoModel.NugetVersion, oldProjectInfo.NugetVersion, maxVersion); } } nugetVersionList.Add(nugetInfo); } var latestBuild = 100; var listNugetProjectNeedToChangeds = nugetVersionList.Where(n => n.NeedUpgrate && n.NugetName.StartsWith("SMEE.")).ToList(); foreach (var nugetProjectNeedToChanged in listNugetProjectNeedToChangeds) { nugetProjectNeedToChanged.NugetVersionNeedToUpgrate = VersionHelper.BuildLatestNugetVersion(nugetProjectNeedToChanged.NugetVersion); nugetProjectNeedToChanged.AssemblyVersionNeedToUpgrate = $"{nugetProjectNeedToChanged.NugetVersionNeedToUpgrate}.{latestBuild + 1}"; } var nugetVersionInfos = new List <object[]>(); foreach (var nugetVersionInfo in listNugetProjectNeedToChangeds) { nugetVersionInfos.Add(new object[] { nugetVersionInfo.NugetName, nugetVersionInfo.OldNugetVersion, nugetVersionInfo.NugetVersion, nugetVersionInfo.NeedUpgrate, nugetVersionInfo.NugetVersionNeedToUpgrate, nugetVersionInfo.AssemblyVersionNeedToUpgrate }); } // Save excel file ExcelHelper.SaveProjectInfo("D:\\Study project\\NugetVerion.xlsx", nugetVersionInfos); Logger.Debug("NugetToolConsole -> End"); }
protected NugetInfo(NugetInfo nugetInfo) : this(nugetInfo.Name, nugetInfo.Version, nugetInfo.TargetFramework) { NugetDllInfo = nugetInfo.NugetDllInfo; }
/// <summary> /// Initializes a new instance of the <see cref="Project" /> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="data">The data.</param> public RefNuget(Nuget parent, NugetInfo <RefNugetInfo> data) : base(data) { this.Parent = parent; }
public PackagesInfo(NugetInfo nugetInfo) { NugetInfo = nugetInfo; }
/// <summary> /// 构造一条 Nuget 包信息(拓展) /// </summary> /// <param name="nugetInfo">Nuget 包信息类</param> /// <param name="configPath">配置文件路径</param> public NugetInfoEx(NugetInfo nugetInfo, string configPath) : base(nugetInfo) { ConfigPath = configPath; }
public static string GetNugetVersion() { NugetInfo v = APIHelper.CallAPI <NugetInfo>("https://api-v2v3search-0.nuget.org/query?q=WalkingTec.Mvvm.Mvc&prerelease=false").Result; return(v.data[0]?.version); }
/// <summary> /// Increases the version. /// </summary> /// <param name="selectedItems">The selected items.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public override bool HandleIncreaseVersion(IList <Nuget> selectedItems) { Logger.Debug("HandleIncreaseVersion..."); if (string.IsNullOrEmpty(this.NugetVersion)) { return(false); } // Build data to increase version var selectingItem = selectedItems.Select(n => n as NugetInfo <RefNugetInfo>).ToList(); var processingProjects = new List <NugetInfo <RefNugetInfo> >(); // Filter before execute increase foreach (var prjData in selectingItem) { var prjItem = selectedItems.FirstOrDefault(n => n.Name.Equals(prjData.Name)); // Binding model var checkingItems = prjItem?.Items.Where(n => n.IsChecked == true).ToList(); // Get checked child node // Data model var needExecutePrj = prjData.Items.Where(n => n.Name.Equals(checkingItems?.FirstOrDefault(i => i.Name.Equals(n.Name))?.Name)).ToList(); // Create new project data and list project items var nugetPrjData = new NugetInfo <RefNugetInfo>() { Name = prjData.Name, Path = prjData.Path, NugetVersion = prjData.NugetVersion, Items = needExecutePrj, }; processingProjects.Add(nugetPrjData); } var versionInfo = new VersionInfo(this.NugetVersion); var results = this.referenceNugetController.IncreaseVersion(processingProjects, versionInfo); // Update result on GUI foreach (var resultItem in results) { if (resultItem.HasError) { continue; } // Get source items var sourceBindingProjects = selectedItems.FirstOrDefault(itm => itm.Name.Equals(resultItem.SourceProjectName)); var sourceDataProjects = selectingItem.FirstOrDefault(itm => itm.Name.Equals(resultItem.SourceProjectName));; // Update on GUI var refPrjBindingItem = sourceBindingProjects?.Items?.FirstOrDefault(n => resultItem.Data.Name.Equals(n.Name)); var refItem = refPrjBindingItem as RefNuget; if (refItem != null) { refItem.RefVersion = this.NugetVersion; } // Update for data item var refPrjDataItem = sourceDataProjects?.Items?.FirstOrDefault(n => resultItem.Data.Name.Equals(n.Name)); if (refPrjDataItem != null) { refPrjDataItem.RefVersion = this.NugetVersion; } } Logger.Debug($"HandleIncreaseVersion...DONE - Update version success for [{results.Count(n => n.HasError == false)}] projects"); return(results.All(rs => rs.HasError)); }
public async Task CopyOne(NugetInfo nugetProcessResult) { var list = GetFilesToCopy(nugetProcessResult); await Io.CopyFilesAsync(list, _progressFn); }
/// <summary> /// Initializes a new instance of the <see cref="RefNuget"/> class. /// </summary> /// <param name="data">The data.</param> public RefNuget(NugetInfo <RefNugetInfo> data) : base(data) { }