Project p = new Project(); p.TargetFramework = new TargetFrameworkVersion("v4.6.1"); p.BuildTargets.Add("Build", new BuildTarget("MyBuildTask"));
In the above example, we create a new target called "MyTarget" that runs after the "Build" target. The target executes a command using the Exec task. The package library for BuildTarget is the Microsoft.Build.Framework Nuget package. This package contains the necessary classes and interfaces for working with MSBuild projects and targets, including the BuildTarget class.