private void ConvertDepsSection(string configuration, List <string> children) { var parser = new DepsParser(Directory.GetCurrentDirectory()); var deps = parser.Get(configuration); var childrenDeps = children.SelectMany(c => parser.Get(c).Deps).ToList(); deps.Deps = RelaxDeps(deps.Deps, childrenDeps); writer.WriteLine(" deps:"); if (deps.Force != null) { deps.Force = deps.Force.Select(x => x.Replace("%CURRENT_BRANCH%", "$CURRENT_BRANCH")).ToArray(); writer.WriteLine(" - force: " + string.Join(",", deps.Force)); } if (deps.Deps == null) { return; } foreach (var dep in deps.Deps) { writer.WriteLine(" - " + dep); } writer.WriteLine(); }
public void TestNoDepsFile() { using (var tmp = new TempDirectory()) { var dc = new DepsParser(tmp.Path).Get(); Assert.That(dc.Deps.Count == 0); } }
private static List <Dep> GetDeps(Dep root) { var deps = new DepsParser( Path.Combine(Helper.CurrentWorkspace, root.Name)) .Get(root.Configuration).Deps ?? new List <Dep>(); foreach (var dep in deps) { dep.UpdateConfigurationIfNull(); dep.Treeish = null; } return(deps); }
protected override int Execute() { var modulePath = Helper.GetModuleDirectory(Directory.GetCurrentDirectory()); var moduleName = Path.GetFileName(modulePath); project = Yaml.GetProjectFileName(project, moduleName); configuration = configuration ?? "full-build"; var buildData = Yaml.BuildParser(moduleName).Get(configuration).FirstOrDefault(t => !t.Target.IsFakeTarget()); var projectPath = Path.GetFullPath(project); var csproj = new ProjectFile(projectPath); var deps = new DepsParser(modulePath).Get(configuration); ConsoleWriter.WriteInfo("patching csproj"); var patchedDocument = csproj.CreateCsProjWithNugetReferences(deps.Deps, preRelease); var backupFileName = Path.Combine(Path.GetDirectoryName(projectPath) ?? "", "backup." + Path.GetFileName(projectPath)); if (File.Exists(backupFileName)) { File.Delete(backupFileName); } File.Move(projectPath, backupFileName); try { XmlDocumentHelper.Save(patchedDocument, projectPath, "\n"); var shellRunner = new ShellRunner(LogManager.GetLogger <ShellRunner>()); var cleaner = new Cleaner(shellRunner); var moduleBuilder = new ModuleBuilder(Log, buildSettings); moduleBuilder.Init(); ConsoleWriter.WriteInfo("start pack"); if (!moduleBuilder.DotnetPack(modulePath, projectPath, buildData?.Configuration ?? "Release")) { return(-1); } } finally { if (File.Exists(projectPath)) { File.Delete(projectPath); } File.Move(backupFileName, projectPath); } return(0); }