/// <summary> /// Sets the value of an MSBuild project property. /// </summary> /// <param name="propertyName">The name of the property to change.</param> /// <param name="propertyValue">The value to assign the property.</param> /// <param name="condition">The condition to use on the property. Corresponds to the Condition attribute of the Property element.</param> /// <param name="position">A <see cref="PropertyPosition"/> value indicating the location to insert the property.</param> /// <param name="treatPropertyValueAsLiteral">true to treat the <paramref name="propertyValue"/> parameter as a literal value; otherwise, false.</param> public void SetProjectProperty(string propertyName, string propertyValue, string condition, PropertyPosition position, bool treatPropertyValueAsLiteral) { WixHelperMethods.VerifyStringArgument(propertyName, "propertyName"); if (propertyValue == null) { propertyValue = String.Empty; } // see if the value is the same as what's already in the project so we // know whether to actually mark the project file dirty or not string oldValue = this.GetProjectProperty(propertyName, true); if (!String.Equals(oldValue, propertyValue, StringComparison.Ordinal)) { // check out the project file if (this.ProjectMgr != null && !this.ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } this.BuildProject.SetProperty(propertyName, propertyValue, condition, position, treatPropertyValueAsLiteral); // refresh the cached values this.SetCurrentConfiguration(); this.SetProjectFileDirty(true); } }