How it works...

In this recipe, we wrote a C# console application based on Roslyn Workspaces API to perform various operations on a projects in a solution: add, remove, edit, and display project properties. The rich Workspaces APIs provide you with a powerful object model for analyzing and editing projects and documents in a solution. Let's walk through the code and understand how we implemented these operations:

public static void Main(string[] args){ // Parse arguments to get solution. string slnPath = ParseArguments(args); if (slnPath == null) {  return; } // Create workspace. MSBuildWorkspace workspace = MSBuildWorkspace.Create(); // Open solution within the workspace. Console.WriteLine($"Loading solution '{slnPath}'..."); Solution solution ...

Get Roslyn Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.