public static BuildOutput CaptureBuildOutput(Func <bool> build) { var result = new BuildOutput(); Application.LogCallback logCallback = (a, b, c) => { if (c == LogType.Log || c == LogType.Warning) { return; } result.LogEntries.Add(new BuildOutput.Entry(a, b, c.ToString())); }; Application.logMessageReceived += logCallback; try { result.IsSuccess = build(); } catch (Exception e) { Debug.LogException(e); result.IsSuccess = false; } finally { Application.logMessageReceived -= logCallback; Debug.Log("[[Writing TempBuildOutput.json]]"); File.WriteAllText("TempBuildOutput.json", JsonConvert.SerializeObject(result)); } return(result); }
private void BatchBuild() { if (!Program.BatchBuildList.Any()) { return; } if (IsBuilding) { Program.BatchBuildList.Clear(); return; } BuildOutput.ResetText(); BatchBuildSucceedList.Clear(); BatchBuildFailedList.Clear(); BatchBuildInvalidList.Clear(); BatchBuildSkippedList.Clear(); PreBuild = (s, e) => { BuildOutput.ResetText(); PrintBuildOverview(); }; PostBuild += WiiVC_Injector_PostBuild; PromptForSucceed = false; BatchBuildNext(); }
public void CanUseNuGetSdkResolver() { using (ProjectCollection projectCollection = new ProjectCollection()) { BuildOutput buildOutput = BuildOutput.Create(); projectCollection.RegisterLogger(buildOutput); using (PackageRepository.Create(TestRootPath) .Package("Foo.Bar", "1.2.3", out Package package) .FileText(Path.Combine("Sdk", "Sdk.props"), "<Project />") .FileText(Path.Combine("Sdk", "Sdk.targets"), "<Project />")) { ProjectCreator projectCreator = ProjectCreator .Create( sdk: $"{package.Id}/{package.Version}", projectCollection: projectCollection) .Save(GetTempFileName(".csproj")); try { Project unused = projectCreator.Project; } catch (Exception e) { throw new Exception(buildOutput.GetConsoleLog(), e); } } } }
public void MessagesByImportance(string value) { const string expectedMessage = "A7E9F67E46A64181B25DC136A786F480"; MessageImportance importance = (MessageImportance)Enum.Parse(typeof(MessageImportance), value); BuildOutput buildOutput = GetProjectLoggerWithEvents(eventSource => { eventSource.OnMessageRaised(expectedMessage, importance); }); string actualItem = buildOutput.Messages.ShouldHaveSingleItem(); actualItem.ShouldBe(expectedMessage); switch (importance) { case MessageImportance.High: buildOutput.Messages.High.ShouldHaveSingleItem().ShouldBe(actualItem); break; case MessageImportance.Normal: buildOutput.Messages.Normal.ShouldHaveSingleItem().ShouldBe(actualItem); break; case MessageImportance.Low: buildOutput.Messages.Low.ShouldHaveSingleItem().ShouldBe(actualItem); break; } }
public void StaticGraphBuildsSucceed(string projectExtension) { ProjectCreator sdkReference = ProjectCreator.Templates.SdkCsproj( Path.Combine(TestRootPath, "sdkstyle", "sdkstyle.csproj"), targetFramework: "net472") .Save(); ProjectCreator legacyReference = ProjectCreator.Templates.LegacyCsproj( Path.Combine(TestRootPath, "legacy", "legacy.csproj"), targetFrameworkVersion: "v4.7.2") .Save(); ProjectCreator noTargets = ProjectCreator.Templates.NoTargetsProject( path: Path.Combine(TestRootPath, "notargets", "notargets.csproj"), targetFramework: "net472", customAction: creator => { creator.ItemProjectReference(sdkReference, referenceOutputAssembly: false); creator.ItemProjectReference(legacyReference, referenceOutputAssembly: false); }).Save(); ProjectCreator project = ProjectCreator.Templates.SdkCsproj( Path.Combine(TestRootPath, "main", $"main{projectExtension}"), targetFramework: "net472", projectCreator: creator => { creator.ItemProjectReference(noTargets, referenceOutputAssembly: false); }) .Save() .TryBuild("Restore", out bool result, out BuildOutput restoreOutput); result.ShouldBeTrue(restoreOutput.GetConsoleLog()); using (BuildManager buildManager = new BuildManager()) using (ProjectCollection projectCollection = new ProjectCollection()) { try { BuildOutput buildOutput = BuildOutput.Create(); buildManager.BeginBuild( new BuildParameters(projectCollection) { Loggers = new[] { buildOutput }, IsolateProjects = true, }); GraphBuildResult graphResult = buildManager.BuildRequest( new GraphBuildRequestData( new[] { new ProjectGraphEntryPoint(project.FullPath) }, new[] { "Build" })); graphResult.OverallResult.ShouldBe(BuildResultCode.Success, buildOutput.GetConsoleLog()); } finally { buildManager.EndBuild(); } } }
public OutputPanel ClearAllDefaultOutputs() { ConsoleOutput.Clear(); BuildOutput.Clear(); DebugOutput.Clear(); return(this); }
public async Task CustomProject_DataSearch() { var bo = new BuildOutput(); var monitor = bo.GetProgressMonitor(); monitor.LogObject(new BuildSessionStartedEvent()); for (int i = 0; i < 100; i++) { monitor.Log.WriteLine($"Message {i + 1}"); } monitor.Log.WriteLine("Custom project built"); monitor.LogObject(new BuildSessionFinishedEvent()); var nodes = bo.GetRootNodes(true); var dataSource = new BuildOutputDataSource(nodes); var search = new BuildOutputDataSearch(nodes); int matches = 0; var visited = new HashSet <BuildOutputNode> (); for (var match = await search.FirstMatch("Message "); match != null; match = search.NextMatch()) { if (visited.Contains(match)) { break; } visited.Add(match); matches++; } Assert.That(matches, Is.EqualTo(100)); }
protected override void Execute(CodeActivityContext context) { console = context.GetExtension <ActivityConsole>(); if (console == null) { console = new ActivityConsole(); } if (!string.IsNullOrEmpty(CommandLineArguments.Get(context))) { console.WriteLine("!!!Warning - This activity currently ignores 'CommandLineArguments' argument. !!!"); } var project = new Project(Project.Get(context)); StringOutputLogger logger = new StringOutputLogger(); project.SetGlobalProperty("Configuration", Configuration.Get(context) ?? ""); project.SetGlobalProperty("Platform", Platform.Get(context) ?? ""); project.SetProperty("OutDir", OutDir.Get(context) ?? ""); bool buildResult = project.Build(Targets.Get(context).ToArray(), new ILogger[] { logger }); string buildOutput = string.Format( "MSBUILD - {0}\nConfiguration : {1}\nPlatform : {2}\nOutput Directory : {3}\n{4}", project.FullPath, project.GetProperty("Configuration").EvaluatedValue, project.GetProperty("Platform").EvaluatedValue, project.GetProperty("OutDir").EvaluatedValue, logger.GetOutput()); BuildOutput.Set(context, buildOutput); BuildSuccess.Set(context, buildResult); ProjectCollection.GlobalProjectCollection.UnloadProject(project); console.WriteLine(buildOutput); }
BuildOutput GenerateCustomBuild(int items) { var processor = new BuildOutputProcessor(null, false); for (int i = 0; i < items; i++) { var projectMsg = $"Project {i}"; processor.AddNode(BuildOutputNodeType.Project, projectMsg, projectMsg, true, DateTime.Now); for (int j = 0; j < items * 10; j++) { var targetMsg = $"Target {i}.{j}"; processor.AddNode(BuildOutputNodeType.Target, targetMsg, targetMsg, true, DateTime.Now); for (int k = 0; k < items * 100; k++) { var taskMsg = $"Task {i}.{j}.{k}"; processor.AddNode(BuildOutputNodeType.Task, taskMsg, taskMsg, true, DateTime.Now); var msg = $"Message {i}.{j}.{k}"; processor.AddNode(BuildOutputNodeType.Message, msg, msg, false, DateTime.Now); processor.EndCurrentNode(taskMsg, DateTime.Now); } processor.EndCurrentNode(targetMsg, DateTime.Now); } processor.EndCurrentNode(projectMsg, DateTime.Now); } var bo = new BuildOutput(); bo.AddProcessor(processor); return(bo); }
public void StaticGraphBuildsSucceed(string projectExtension) { using var collection = new ProjectCollection(); var sdkReference = ProjectCreator.Templates.SdkCsproj( GetTempFileWithExtension(".csproj"), projectCollection: collection).Save(); var legacyReference = ProjectCreator.Templates.LegacyCsproj( GetTempFileWithExtension(".csproj"), projectCollection: collection).Save(); var noTargets = ProjectCreator.Templates.NoTargetsProject( path: GetTempFileWithExtension(projectExtension), targetFramework: "net472", projectCollection: collection, customAction: creator => { creator.ItemProjectReference(sdkReference.Project, referenceOutputAssembly: false); creator.ItemProjectReference(legacyReference.Project, referenceOutputAssembly: false); }).Save(); var root = ProjectCreator.Templates.SdkCsproj( GetTempFileWithExtension(".csproj"), projectCollection: collection, targetFramework: "net472", projectCreator: creator => { creator.ItemProjectReference(noTargets.Project, referenceOutputAssembly: false); }).Save(); root.TryBuild("Restore", out var result, out var buildOutput1); result.ShouldBeTrue(buildOutput1.GetConsoleLog()); using var buildManager = new BuildManager(); try { var buildOutput = BuildOutput.Create(); buildManager.BeginBuild( new BuildParameters { Loggers = new[] { buildOutput }, IsolateProjects = true }); var graphResult = buildManager.BuildRequest( new GraphBuildRequestData( new[] { new ProjectGraphEntryPoint(root.FullPath) }, new[] { "Build" })); graphResult.OverallResult.ShouldBe(BuildResultCode.Success); buildOutput.Succeeded.ShouldBe(true); } finally { buildManager.EndBuild(); } }
public void Errors(string expectedMessage, string expectedCode) { BuildOutput buildOutput = GetProjectLoggerWithEvents(eventSource => { eventSource.OnErrorRaised(expectedMessage, expectedCode); }); BuildErrorEventArgs args = buildOutput.ErrorEvents.ShouldHaveSingleItem(); args.Message.ShouldBe(expectedMessage); args.Code.ShouldBe(expectedCode); }
public static void AssertTargetIsNotSkipped(this BuildOutput output, string target, int?occurrence = null) { if (occurrence != null) { Assert.IsFalse(output.IsTargetSkipped(target), $"The target {target} should have *not* been skipped. ({occurrence})"); } else { Assert.IsFalse(output.IsTargetSkipped(target), $"The target {target} should have *not* been skipped."); } }
public static void AssertTargetIsPartiallyBuilt(this BuildOutput output, string target, int?occurrence = null) { if (occurrence != null) { Assert.IsTrue(output.IsTargetPartiallyBuilt(target), $"The target {target} should have been partially built. ({occurrence})"); } else { Assert.IsTrue(output.IsTargetPartiallyBuilt(target), $"The target {target} should have been partially built."); } }
private BuildOutput GetProjectLoggerWithEvents(Action <MockEventSource> eventSourceActions) { MockEventSource eventSource = new MockEventSource(); BuildOutput buildOutput = BuildOutput.Create(); buildOutput.Initialize(eventSource); eventSourceActions(eventSource); return(buildOutput); }
public void ResultsByProject() { Dictionary <string, bool> projects = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase) { { Path.Combine("DA920698", "E40D", "4D8F", "89D8", "B85D870C4214"), true }, { Path.Combine("53C78698", "F360", "491F", "8025", "B323782DD912"), false }, { Path.Combine("F42234CB", "7504", "4F23", "ACD7", "D58F5BCDD3C6"), true }, }; BuildOutput buildOutput = GetProjectLoggerWithEvents(eventSource => { Parallel.ForEach(projects, project => { eventSource.OnProjectFinished(project.Key, project.Value); }); }); buildOutput.ProjectResults.ShouldBe(projects, ignoreOrder: true); }
public void ResultsByProject() { Dictionary <string, bool> projects = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase) { { @"DA920698\E40D\4D8F\89D8\B85D870C4214", true }, { @"53C78698\F360\491F\8025\B323782DD912", false }, { @"F42234CB\7504\4F23\ACD7\D58F5BCDD3C6", true }, }; BuildOutput buildOutput = GetProjectLoggerWithEvents(eventSource => { Parallel.ForEach(projects, project => { eventSource.OnProjectFinished(project.Key, project.Value); }); }); buildOutput.ProjectResults.ShouldBe(projects, ignoreOrder: true); }
void OnCombineClosed(object sender, EventArgs e) { Clear(); buildOutput.Dispose(); if (buildOutputViewContent != null) { buildOutputViewContent.Dispose(); buildOutputViewContent = null; } buildOutputDoc?.Close(); buildOutput = new BuildOutput(); }
public (IAnalyzerResults AnalyzerResults, BuildOutput Log) Build(string projectFilePath, bool designTime = false) { var projectAnalyzer = new AnalyzerManager().GetProject(projectFilePath); var logger = BuildOutput.Create(); projectAnalyzer.AddBuildLogger(logger); projectAnalyzer.AddBinaryLogger("build.binlog"); var analyzerResults = projectAnalyzer.Build( new EnvironmentOptions() { DesignTime = designTime } ); return(analyzerResults, logger); }
public void CustomProject_ToDataSource() { var bo = new BuildOutput(); var monitor = bo.GetProgressMonitor(); monitor.LogObject(new BuildSessionStartedEvent()); monitor.Log.Write("Custom project built"); monitor.LogObject(new BuildSessionFinishedEvent()); var nodes = bo.GetRootNodes(true); var dataSource = new BuildOutputDataSource(nodes); var child = dataSource.GetChild(dataSource.GetChild(null, 0), 0); Assert.That(dataSource.GetChildrenCount(null), Is.EqualTo(2)); Assert.That(child, Is.TypeOf(typeof(BuildOutputNode))); Assert.That((child as BuildOutputNode).Message, Is.EqualTo("Custom project built")); }
public static ProjectCreator TryBuild(this ProjectCreator sdkProject, string targetName, out TargetResult result, out BuildOutput output) { lock (BuildManager.DefaultBuildManager) { output = BuildOutput.Create(); var buildResult = BuildManager.DefaultBuildManager.Build( new BuildParameters { Loggers = output.AsEnumerable() }, new BuildRequestData( sdkProject.Project.CreateProjectInstance(), new[] { targetName })); result = buildResult.ResultsByTarget[targetName]; return(sdkProject); } }
public void ConsoleLog() { BuildOutput buildOutput = GetProjectLoggerWithEvents(eventSource => { eventSource.OnErrorRaised("FDC8FB4F8E084055974580DF7CD7531E", "6496288436BE4E7CAE014F163914063C", "7B07B020E38343A89B3FA844A40895E4", 1, 2, 0, 0); eventSource.OnWarningRaised("E00BBDAEEFAB45949AFEE1BF792B1691", "56206897E63F44159603D22BB7C08145", "C455F26F4D4543E78F109BCB00F02BE2", 1, 2, 0, 0); eventSource.OnMessageRaised("55B991507D52403295E92E4FFA8704F3", MessageImportance.High); eventSource.OnMessageRaised("FA7FCCBE43B741998BAB399E74F2997D"); eventSource.OnMessageRaised("67C0E0E52F2A45A981F3143BAF00A4A3", MessageImportance.Low); }); buildOutput.GetConsoleLog() #pragma warning disable SA1116 // Split parameters must start on line after declaration .ShouldBe(@"7B07B020E38343A89B3FA844A40895E4(1,2): error 6496288436BE4E7CAE014F163914063C: FDC8FB4F8E084055974580DF7CD7531E C455F26F4D4543E78F109BCB00F02BE2(1,2): warning 56206897E63F44159603D22BB7C08145: E00BBDAEEFAB45949AFEE1BF792B1691 55B991507D52403295E92E4FFA8704F3 FA7FCCBE43B741998BAB399E74F2997D ", #pragma warning restore SA1116 // Split parameters must start on line after declaration StringCompareShould.IgnoreLineEndings); }
protected override void Initialize(IPadWindow window) { window.Title = GettextCatalog.GetString("Errors"); DockItemToolbar toolbar = window.GetToolbar(DockPositionType.Top); toolbar.Accessible.Name = "ErrorPad.Toolbar"; toolbar.Accessible.SetLabel("Error Pad Toolbar"); toolbar.Accessible.SetRole("AXToolbar", "Pad toolbar"); toolbar.Accessible.Description = GettextCatalog.GetString("The Error pad toolbar"); errorBtn = MakeButton(Stock.Error, "toggleErrors", ShowErrors, out errorBtnLbl); errorBtn.Accessible.Name = "ErrorPad.ErrorButton"; errorBtn.Toggled += new EventHandler(FilterChanged); errorBtn.TooltipText = GettextCatalog.GetString("Show Errors"); errorBtn.Accessible.Description = GettextCatalog.GetString("Show Errors"); UpdateErrorsNum(); toolbar.Add(errorBtn); warnBtn = MakeButton(Stock.Warning, "toggleWarnings", ShowWarnings, out warnBtnLbl); warnBtn.Accessible.Name = "ErrorPad.WarningButton"; warnBtn.Toggled += new EventHandler(FilterChanged); warnBtn.TooltipText = GettextCatalog.GetString("Show Warnings"); warnBtn.Accessible.Description = GettextCatalog.GetString("Show Warnings"); UpdateWarningsNum(); toolbar.Add(warnBtn); msgBtn = MakeButton(Stock.Information, "toggleMessages", ShowMessages, out msgBtnLbl); msgBtn.Accessible.Name = "ErrorPad.MessageButton"; msgBtn.Toggled += new EventHandler(FilterChanged); msgBtn.TooltipText = GettextCatalog.GetString("Show Messages"); msgBtn.Accessible.Description = GettextCatalog.GetString("Show Messages"); UpdateMessagesNum(); toolbar.Add(msgBtn); var sep = new SeparatorToolItem(); sep.Accessible.SetShouldIgnore(true); toolbar.Add(sep); logBtn = MakeButton("md-message-log", "toggleBuildOutput", out logBtnLbl); logBtn.Accessible.Name = "ErrorPad.LogButton"; logBtn.TooltipText = GettextCatalog.GetString("Show build output"); logBtn.Accessible.Description = GettextCatalog.GetString("Show build output"); logBtnLbl.Text = GettextCatalog.GetString("Build Output"); logBtn.Accessible.SetTitle(logBtnLbl.Text); logBtn.Clicked += HandleLogBtnClicked; toolbar.Add(logBtn); buildOutput = new BuildOutput(); //Dummy widget to take all space between "Build Output" button and SearchEntry var spacer = new HBox(); spacer.Accessible.SetShouldIgnore(true); toolbar.Add(spacer, true); searchEntry = new SearchEntry(); searchEntry.Accessible.SetLabel(GettextCatalog.GetString("Search")); searchEntry.Accessible.Name = "ErrorPad.Search"; searchEntry.Accessible.Description = GettextCatalog.GetString("Search the error data"); searchEntry.Entry.Changed += searchPatternChanged; searchEntry.WidthRequest = 200; searchEntry.Visible = true; toolbar.Add(searchEntry); toolbar.ShowAll(); UpdatePadIcon(); IdeApp.ProjectOperations.StartBuild += OnBuildStarted; }
public static void CacheAssetBundleBuildOutput(BuildOutput output, BuildSettings settings) { // TODO: Cache data about this build result for future patching, incremental build, etc }
public Builder(Project project, BuildOutput console) { this.project = project; this.console = console; }
public override void Build(BuildOutput console) { }
public virtual void Build(BuildOutput console) { }
public void ProgressMonitor_Instantiation() { var bo = new BuildOutput(); Assert.AreEqual(bo.GetProgressMonitor(), bo.GetProgressMonitor()); }
public void OverallResult(bool succeeded) { BuildOutput buildOutput = GetProjectLoggerWithEvents(eventSource => { eventSource.OnBuildFinished(succeeded); }); buildOutput.Succeeded.ShouldBe(succeeded); }