public NuGetProject(List <string> packagesList, string packagesPath, ProjectFile projectFile, ILog log) { this.log = log; this.packagesList = packagesList; this.projectFile = projectFile; installedPackages = new HashSet <PackageIdentity>(); var sourceProvider = new PackageSourceProvider(Settings.LoadDefaultSettings(null)); var sourceRepositoryProvider = new CommandLineSourceRepositoryProvider(sourceProvider); repositories = sourceProvider.LoadPackageSources().Select(sourceRepositoryProvider.CreateRepository) .ToList(); logger = new Console(); var projectFilePath = projectFile.FilePath; var msbuildDirectory = Path.GetDirectoryName(ModuleBuilderHelper.FindMsBuild(null, "Cement NuGet Package Installer")); projectContext = new ConsoleProjectContext(logger); projectSystem = new MSBuildProjectSystem( msbuildDirectory, projectFilePath, projectContext); var projectFolder = Path.GetDirectoryName(projectFilePath); project = new MSBuildNuGetProject(projectSystem, packagesPath, projectFolder); }
public void Init() { if (!Platform.IsUnix()) { VsDevHelper.ReplaceVariablesToVs(); ModuleBuilderHelper.FindMsBuildsWindows(); ModuleBuilderHelper.KillMsBuild(log); } }
private static string FindTool(Tool buildTool, string moduleName) { if (buildTool.Name != "msbuild") { return(buildTool.Name); } if (Helper.OsIsUnix()) { return("msbuild"); } return(ModuleBuilderHelper.FindMsBuild(buildTool.Version, moduleName)); }
private bool BuildSingleModule(Dep dep) { var moduleYaml = Path.Combine(Helper.CurrentWorkspace, dep.Name, Helper.YamlSpecFile); var cmdFile = Path.Combine(Helper.CurrentWorkspace, ModuleBuilderHelper.GetBuildScriptName(dep)); if (!Build(dep, moduleYaml, cmdFile)) { return(false); } CheckHasInstall(dep); return(true); }
private static MsBuildLikeTool FindTool(Tool buildTool, string moduleName) { if (buildTool.Name != "msbuild") { return(new MsBuildLikeTool(buildTool.Name)); } if (Platform.IsUnix()) { return(new MsBuildLikeTool("msbuild")); } var tool = ModuleBuilderHelper.FindMsBuild(buildTool.Version, moduleName); return(tool); }
private static void PrintBuildFailResult(Dep dep, string buildName, ShellRunner runner) { ConsoleWriter.WriteBuildError( $"Failed to build {dep.Name}{(dep.Configuration == null ? "" : "/" + dep.Configuration)} {buildName}"); foreach (var line in runner.Output.Split('\n')) { ModuleBuilderHelper.WriteLine(line); } ConsoleWriter.WriteLine(); ConsoleWriter.WriteInfo("Errors summary:"); foreach (var line in runner.Output.Split('\n')) { ModuleBuilderHelper.WriteIfErrorToStandartStream(line); } }
private bool RunBuildScript(Dep dep, BuildScriptWithBuildData script) { var sw = Stopwatch.StartNew(); var command = script.Script; var runner = PrepareShellRunner(); int exitCode = -1; for (int timesTry = 0; timesTry < 2 && exitCode != 0; timesTry++) { ModuleBuilderHelper.KillMsBuild(log); if (timesTry != 0) { command = script.ScriptIfFail; } log.DebugFormat("Build command: '{0}'", command); if (buildSettings.ShowOutput) { ConsoleWriter.WriteInfo($"BUILDING {command}"); } exitCode = runner.RunInDirectory(Path.Combine(Helper.CurrentWorkspace, dep.Name), command, TimeSpan.FromMinutes(60)); } sw.Stop(); TotalMsbuildTime += sw.Elapsed; var elapsedTime = Helper.ConvertTime(sw.ElapsedMilliseconds); var warnCount = runner.Output.Split('\n').Count(ModuleBuilderHelper.IsWarning); var obsoleteUsages = runner.Output.Split('\n').Where(ModuleBuilderHelper.IsObsoleteWarning).ToList(); var buildName = script.BuildData == null ? "" : script.BuildData.Name; if (exitCode != 0) { PrintBuildFailResult(dep, buildName, runner); return(false); } PrintBuildResult(dep, buildName, warnCount, elapsedTime, obsoleteUsages); return(true); }