Microsoft.VisualStudio.Project.ProjectNode.SetProjectProperty C# (CSharp) Method

SetProjectProperty() public method

Set value of project property
public SetProjectProperty ( string propertyName, string propertyValue ) : void
propertyName string Name of property
propertyValue string Value of property
return void
        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;
        }
ProjectNode