Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Create an MSBuild project and run it, within a unit test, using some convenient extension methods.
var projectRootElement = ProjectRootElement.Create();
projectRootElement
.AddTarget("Build")
.AddTask<MyTask>()
.SetParameter("Foo", "hi");
var highImportanceStringLogger = new HighImportanceStringLogger();
var success = new ProjectInstance(projectRootElement).Build(new[] { highImportanceStringLogger });
Assert.IsTrue(success);
const string expected = @"Inputs:
Foo = hi
";
Assert.AreEqual(expected, highImportanceStringLogger.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment