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.
var projectRootElement = ProjectRootElement.Create();
projectRootElement.AddUsingTask(typeof (MyTask));
projectRootElement
.AddTarget("Build")
.AddTask(typeof(MyTask).Name)
.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