Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Last active December 28, 2015 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayBazuzi/7519460 to your computer and use it in GitHub Desktop.
Save JayBazuzi/7519460 to your computer and use it in GitHub Desktop.
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