Working with builds

Visual Studio Extensibility Cookbook

Here’s a collection of small code samples on different ways to work with builds.

Build solution

To build the entire solution, call the BuildAsync() method.

bool buildStarted = await VS.Build.BuildSolutionAsync(BuildAction.Build);

Build project

You can build any project by passing it to the method.

Project project = await VS.Solutions.GetActiveProjectAsync();
await project.BuildAsync(BuildAction.Rebuild);

Set build property

Shows how to set a build property on the project.

Project project = await VS.Solutions.GetActiveProjectAsync();
bool succeeded = await project.TrySetAttributeAsync("propertyName", "value");

Get build property

Shows how to get a build property of any project or project item.

Project item = await VS.Solutions.GetActiveProjectAsync();
string value = await item.GetAttributeAsync("propertyName");
Last updated: