Skip to content

Instantly share code, notes, and snippets.

@mishrsud
Created October 22, 2017 11:47
Show Gist options
  • Save mishrsud/066409b9b5dcce2ff721adffc7995527 to your computer and use it in GitHub Desktop.
Save mishrsud/066409b9b5dcce2ff721adffc7995527 to your computer and use it in GitHub Desktop.
Modify Csproj Programmatically
// Add Refernce to Microsoft.Build.BuildEngine
// SO: https://stackoverflow.com/a/8492560/190476
using Microsoft.Build.BuildEngine;
namespace UpdateVsProjects
{
class Program
{
static void Main(string[] args)
{
string fullProjPath =
@"C:\SourceCode\Github-Public\CSharpFeatures\ExceptionHandlingDemo\ExceptionHandlingDemo\ExceptionHandlingDemo.csproj";
Engine eng = new Engine();
Project proj = new Project(eng);
proj.Load(fullProjPath);
proj.SetProperty("PlatformTarget", "x64", "'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'");
proj.SetProperty("PlatformTarget", "x64", "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'");
proj.Save(fullProjPath);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment