示例#1
0
        /// <summary>
        /// Sets a project property.
        /// </summary>
        /// <param name="propertyName">Name of the property to set.</param>
        /// <param name="value">Value of the property.</param>
        public virtual void SetProperty(string propertyName, string value)
        {
            ProjectProperty property = new ProjectProperty(this.ProjectMgr, propertyName);

            string oldValue = this.GetProperty(propertyName);

            if (!String.Equals(value, oldValue, StringComparison.Ordinal))
            {
                property.SetValue(value, this.projectConfigs);
                this.IsDirty = true;
            }
        }
示例#2
0
        /// <summary>
        /// Sets a project property.
        /// </summary>
        /// <param name="propertyName">Name of the property to set.</param>
        /// <param name="value">Value of the property.</param>
        public override void SetProperty(string propertyName, string value)
        {
            if (propertyName == WixProjectFileConstants.DefineConstants)
            {
                ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants);
                foreach (ProjectConfig config in this.ProjectConfigs)
                {
                    string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config });
                    if (existingConstantsString == null)
                    {
                        existingConstantsString = String.Empty;
                    }

                    List <string> existingConstants = new List <string>(existingConstantsString.Split(';'));
                    string        constantsString   = value.Trim();
                    List <string> constants         = new List <string>(constantsString.Split(';'));

                    if (WixHelperMethods.RemoveAllMatch(constants, DebugDefine) > 0 || existingConstants.Contains(DebugDefine))
                    {
                        constants.Insert(0, DebugDefine);
                    }

                    constantsString = String.Join(";", constants.ToArray());
                    if (constantsString != existingConstantsString)
                    {
                        property.SetValue(constantsString, new ProjectConfig[] { config });
                        this.IsDirty = true;
                    }
                }
            }
            else if (propertyName == WixProjectFileConstants.DefineDebugConstant)
            {
                ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants);
                foreach (ProjectConfig config in this.ProjectConfigs)
                {
                    string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config });
                    if (existingConstantsString == null)
                    {
                        existingConstantsString = String.Empty;
                    }

                    List <string> constants = new List <string>(existingConstantsString.Split(';'));

                    WixHelperMethods.RemoveAllMatch(constants, DebugDefine);
                    if (value == Boolean.TrueString)
                    {
                        constants.Insert(0, DebugDefine);
                    }

                    string constantsString = String.Join(";", constants.ToArray());
                    if (constantsString != existingConstantsString)
                    {
                        property.SetValue(constantsString, new ProjectConfig[] { config });
                        this.IsDirty = true;
                    }
                }
            }
            else if (propertyName == WixProjectFileConstants.WarningLevel)
            {
                WixWarningLevel warningLevel = (WixWarningLevel)Int32.Parse(value, CultureInfo.InvariantCulture);
                if (warningLevel == WixWarningLevel.None)
                {
                    base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.TrueString);
                    base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString);
                }
                else if (warningLevel == WixWarningLevel.Normal)
                {
                    base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString);
                    base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString);
                }
                else if (warningLevel == WixWarningLevel.Pedantic)
                {
                    base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString);
                    base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.TrueString);
                }
            }
            else
            {
                base.SetProperty(propertyName, value);
            }
        }
        /// <summary>
        /// Sets a project property.
        /// </summary>
        /// <param name="propertyName">Name of the property to set.</param>
        /// <param name="value">Value of the property.</param>
        public virtual void SetProperty(string propertyName, string value)
        {
            ProjectProperty property = new ProjectProperty(this.ProjectMgr, propertyName);

            string oldValue = this.GetProperty(propertyName);
            if (!String.Equals(value, oldValue, StringComparison.Ordinal))
            {
                property.SetValue(value, this.projectConfigs);
                this.IsDirty = true;
            }
        }
        /// <summary>
        /// Sets a project property.
        /// </summary>
        /// <param name="propertyName">Name of the property to set.</param>
        /// <param name="value">Value of the property.</param>
        public override void SetProperty(string propertyName, string value)
        {
            if (propertyName == WixProjectFileConstants.DefineConstants)
            {
                ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants);
                foreach (ProjectConfig config in this.ProjectConfigs)
                {
                    string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config });
                    if (existingConstantsString == null)
                    {
                        existingConstantsString = String.Empty;
                    }

                    List<string> existingConstants = new List<string>(existingConstantsString.Split(';'));
                    string constantsString = value.Trim();
                    List<string> constants = new List<string>(constantsString.Split(';'));

                    if (WixHelperMethods.RemoveAllMatch(constants, DebugDefine) > 0 || existingConstants.Contains(DebugDefine))
                    {
                        constants.Insert(0, DebugDefine);
                    }

                    constantsString = String.Join(";", constants.ToArray());
                    if (constantsString != existingConstantsString)
                    {
                        property.SetValue(constantsString, new ProjectConfig[] { config });
                        this.IsDirty = true;
                    }
                }
            }
            else if (propertyName == WixProjectFileConstants.DefineDebugConstant)
            {
                ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants);
                foreach (ProjectConfig config in this.ProjectConfigs)
                {
                    string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config });
                    if (existingConstantsString == null)
                    {
                        existingConstantsString = String.Empty;
                    }

                    List<string> constants = new List<string>(existingConstantsString.Split(';'));

                    WixHelperMethods.RemoveAllMatch(constants, DebugDefine);
                    if (value == Boolean.TrueString)
                    {
                        constants.Insert(0, DebugDefine);
                    }

                    string constantsString = String.Join(";", constants.ToArray());
                    if (constantsString != existingConstantsString)
                    {
                        property.SetValue(constantsString, new ProjectConfig[] { config });
                        this.IsDirty = true;
                    }
                }
            }
            else if (propertyName == WixProjectFileConstants.WarningLevel)
            {
                WixWarningLevel warningLevel = (WixWarningLevel)Int32.Parse(value, CultureInfo.InvariantCulture);
                if (warningLevel == WixWarningLevel.None)
                {
                    base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.TrueString);
                    base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString);
                }
                else if (warningLevel == WixWarningLevel.Normal)
                {
                    base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString);
                    base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString);
                }
                else if (warningLevel == WixWarningLevel.Pedantic)
                {
                    base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString);
                    base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.TrueString);
                }
            }
            else
            {
                base.SetProperty(propertyName, value);
            }
        }