Writing an application based on the Workspaces API to edit projects in a solution and display project properties
In this section, we will write a C# console application based on Roslyn Workspaces APIs to load a C# solution into a workspace and then perform the following operations:
- Display project properties such as project file path, output file path, project language, assembly name, reference count, document count, and so on.
- Add a new project to the solution.
- Remove an existing project from the solution.
- Edit project to add a project reference.
Getting started
You will need to have the Visual Studio 2017 Community Edition installed on your machine to execute this recipe. You can install a free Community Edition from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15.
How to do it...
- Open Visual Studio and create a new C# console application targeting the .NET Framework 4.6 or higher, say
ConsoleApp
. - Install the
Microsoft.CodeAnalysis.CSharp.Workspaces
NuGet...