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); }