I want to modify property values of Both Debug and Release Configurations programatically in the csproj file. Do I have to define 4 dictionaries to do that?
Example:
Lets say I want to change the “WarningLevel” property of the Debug and Release configurations (values will remain the same for “x86” and “AnyCPU”) to WarningLevel = 4.
var globalPropertiesReleaseX86 = new Dictionary<string, string> { { "Configuration", "Release" }, { "Platform", "x86" } };
var globalPropertiesDebugX86 = new Dictionary<string, string> { { "Configuration", "Debug" }, { "Platform", "x86" } };
var globalPropertiesReleaseAnyCPU = new Dictionary<string, string> { { "Configuration", "Debug" }, { "Platform", "x86" } };
var globalPropertiesDebugAnyCpu = new Dictionary<string, string> { { "Configuration", "Debug" }, { "Platform", "x86" } };
Project projectReleaseX86 = new ProjectCollection(globalPropertiesReleaseX86).LoadProject(filePath);
projectReleaseX86.SetProperty("WarningLevel", "4");
...and so on????
I am sure there is a better approach. Any suggestions would be much appreciated.
Thanks in advance…
You can use ProjectRootElement: