You can use additem method of Microsoft.Build.Evaluation.Project to achieve it. Here is a sample demo for your reference.
DTE2 dte = this.ServiceProvider.GetService(typeof(DTE)) as DTE2;
EnvDTE.Project currentProject = dte.Solution.Projects.Item(1);
string projectPath = currentProject.FullName;
var project = new Microsoft.Build.Evaluation.Project(projectPath);
var proItem = project.GetItems("SDKReference").FirstOrDefault();
project.AddItem("SDKReference", "WindowsTeam, Version=10.0.14393.0", new[]
{
new KeyValuePair<string, string>("Name", "Windows Team Extensions for the UWP")
});
project.Save();
Update:
DTE2 dte = this.ServiceProvider.GetService(typeof(DTE)) as DTE2;
EnvDTE.Project currentProject = dte.Solution.Projects.Item(1);
string projectPath = currentProject.FullName;
Microsoft.Build.Evaluation.ProjectCollection projectCollection = new Microsoft.Build.Evaluation.ProjectCollection();
var project = projectCollection.LoadProject(projectPath); projectCollection.UnloadProject(project);
project.AddItem("SDKReference", "WindowsTeam, Version=10.0.14393.0", new[]
{
new KeyValuePair<string, string>("Name", "Windows Team Extensions for the UWP")
});
project.Save();
projectCollection.LoadProject(projectPath);