public MSBuildItem [] GetItems(ProjectPaths project, string name) { if (executionResult == null) { throw new InvalidOperationException($"Must build something first"); } var build = BinaryLog.ReadBuild(executionResult.BinLogPath); var rv = new List <MSBuildItem> (); // Items inside ItemGroups var items = build.FindChildrenRecursive <Item> (v => (v.Parent as Folder)?.Name == name); foreach (var item in items) { rv.Add(CreateItem(item)); } // Items as output from tasks var resolvedProjectPath = PathUtils.ResolveSymbolicLinks(project.ProjectCSProjPath); var outputItems = build.FindChildrenRecursive <Item> (v => { var parent = v.Parent as NamedNode; if (parent?.Name != name || !(parent is Parameter)) { return(false); } parent = parent.Parent as NamedNode; if (parent?.Name != "OutputItems" || !(parent is Folder)) { return(false); } // There can be output from multiple projects, make sure we filter to the // project we're interested in. var target = parent.GetNearestParent <Target> (); var projectPath = PathUtils.ResolveSymbolicLinks(target.Project.ProjectFile); return(projectPath == resolvedProjectPath); }); foreach (var item in outputItems) { rv.Add(CreateItem(item)); } return(rv.ToArray()); }
public void RunTarget(ProjectPaths paths, string target, ExecutionMode?executionMode = null, int expectedErrorCount = 0, Dictionary <string, string> properties = null) { var rv = Engine.RunTarget(ApplePlatform, executionMode ?? Mode, paths.ProjectCSProjPath, target, properties); if (expectedErrorCount != Engine.ErrorEvents.Count) { foreach (var e in Engine.ErrorEvents) { Console.WriteLine(e.Message); } Assert.AreEqual(expectedErrorCount, Engine.ErrorEvents.Count, "ExitCode/ExpectedErrorCount"); } if (expectedErrorCount > 0) { Assert.AreEqual(1, rv.ExitCode, "ExitCode (failure)"); } else { Assert.AreEqual(0, rv.ExitCode, "ExitCode (success)"); } }
public void RunTarget(ProjectPaths paths, string target, int expectedErrorCount) { RunTarget(paths, target, null, expectedErrorCount); }
public MSBuildProject(ProjectPaths paths, TestBase testBase) { ProjectPaths = paths; this.testBase = testBase; }