public static ProjectJsonDependencyInfo MergeToLatest(IEnumerable <ProjectJsonDependencyInfo> projectJsons, string oldprerelease = null, string newprerelease = null) { var merged = new ProjectJsonDependencyInfo(); merged.dependencies = new Dictionary <string, string>(); foreach (var pjson in projectJsons) { if (pjson.dependencies != null) { foreach (var depend in pjson.dependencies) { var depVer = ComplexVersion.Parse(depend.Value); if (newprerelease != null && depVer.Prerelease == oldprerelease) { depVer.Prerelease = newprerelease; } //if the dependency is not present in the merged dependencies OR the version in the current pjson is a greater than the one in merged //if string.Compare returns > 0 then depend.Value is greater than the one in merged, this should mean a later version if (!merged.dependencies.ContainsKey(depend.Key) || (ComplexVersion.Parse(merged.dependencies[depend.Key]) < depVer)) { merged.dependencies[depend.Key] = depVer.ToString(); } } } } return(merged); }
public static ProjectJsonDependencyInfo FromFile(string path) { ProjectJsonDependencyInfo dependInfo = null; //if a project.json file exists next to the test binary load it if (File.Exists(path)) { var data = JObject.Parse(File.ReadAllText(path)); (data["dependencies"] as JObject)?.Property("test-runtime")?.Remove(); dependInfo = data.ToObject <ProjectJsonDependencyInfo>(); } return(dependInfo); }
public override bool Execute() { if (Debug) { MessageBox.Show($"PID:{Process.GetCurrentProcess().Id} Attach debugger now.", "Debug GenerateStressSuiteTask", MessageBoxButton.OK); } Dictionary <string, HashSet <string> > assmVersions = new Dictionary <string, HashSet <string> >(); var projectJsons = Directory.EnumerateFiles(InPath, "project.json", SearchOption.AllDirectories).Select(p => ProjectJsonDependencyInfo.FromFile(p)); var merged = ProjectJsonDependencyInfo.MergeToLatest(projectJsons, OldPrerelease, NewPrerelease); merged.ToFile(OutPath); return(true); }
public static ProjectJsonDependencyInfo FromFile(string path) { ProjectJsonDependencyInfo dependInfo = new ProjectJsonDependencyInfo(); //if a project.json file exists next to the test binary load it if (File.Exists(path)) { var serializer = JsonSerializer.CreateDefault(); using (var srdr = new StreamReader(File.OpenRead(path))) { var jrdr = new JsonTextReader(srdr); var obj = serializer.Deserialize<JObject>(jrdr); foreach(var prop in FindAllDependencyProperties(obj)) { dependInfo.dependencies[prop.Key] = prop.Value; } } } return dependInfo; }
public static ProjectJsonDependencyInfo FromFile(string path) { ProjectJsonDependencyInfo dependInfo = new ProjectJsonDependencyInfo(); //if a project.json file exists next to the test binary load it if (File.Exists(path)) { var serializer = JsonSerializer.CreateDefault(); using (var srdr = new StreamReader(File.OpenRead(path))) { var jrdr = new JsonTextReader(srdr); var obj = serializer.Deserialize <JObject>(jrdr); foreach (var prop in FindAllDependencyProperties(obj)) { dependInfo.dependencies[prop.Key] = prop.Value; } } } return(dependInfo); }
public static ProjectJsonDependencyInfo MergeToLatest(IEnumerable<ProjectJsonDependencyInfo> projectJsons, string oldprerelease = null, string newprerelease = null) { var merged = new ProjectJsonDependencyInfo(); merged.dependencies = new Dictionary<string, string>(); foreach (var pjson in projectJsons) { if (pjson.dependencies != null) { foreach (var depend in pjson.dependencies) { var depVer = ComplexVersion.Parse(depend.Value); if(newprerelease != null && depVer.Prerelease == oldprerelease) { depVer.Prerelease = newprerelease; } //if the dependency is not present in the merged dependencies OR the version in the current pjson is a greater than the one in merged //if string.Compare returns > 0 then depend.Value is greater than the one in merged, this should mean a later version if (!merged.dependencies.ContainsKey(depend.Key) || (ComplexVersion.Parse(merged.dependencies[depend.Key]) < depVer)) { merged.dependencies[depend.Key] = depVer.ToString(); } } } } return merged; }
private static ProjectJsonDependencyInfo LoadPackageRefs(string assemblyPath) { var projJsonPath = Path.Combine(Path.GetDirectoryName(assemblyPath), "project.json"); return(ProjectJsonDependencyInfo.FromFile(projJsonPath)); }