public virtual void SetProjectProperty(string propertyName, string propertyValue)
{
if (propertyName == null)
throw new ArgumentNullException("propertyName", "Cannot set a null project property");
string oldValue = null;
ProjectPropertyInstance oldProp = GetMsBuildProperty(propertyName, true);
if (oldProp != null)
oldValue = oldProp.EvaluatedValue;
if (propertyValue == null)
{
// if property already null, do nothing
if (oldValue == null)
return;
// otherwise, set it to empty
propertyValue = String.Empty;
}
// Only do the work if this is different to what we had before
if (String.Compare(oldValue, propertyValue, StringComparison.Ordinal) != 0)
{
// Check out the project file.
if (!this.ProjectMgr.QueryEditProjectFile(false))
{
throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
}
this.buildProject.SetProperty(propertyName, propertyValue);
RaiseProjectPropertyChanged(propertyName, oldValue, propertyValue);
// property cache will need to be updated
this.currentConfig = null;
this.SetProjectFileDirty(true);
}
return;
}