Ejemplo n.º 1
0
 private string GetBuildPropertyValue(MSBuild.ProjectProperty buildProperty, bool finalValue)
 {
     if (buildProperty == null)
     {
         return(null);
     }
     else if (finalValue)
     {
         return(buildProperty.EvaluatedValue);
     }
     else
     {
         // If the property definition contains the property itself, we want to return the final result
         // Ideally, we would like to expand only the value for the property but MSBuild does not allow that
         // That solves the case where OutputPath is define as $(OutputPath)\ if it's not ending with a backslash
         string propertyNameEscaped = "$(" + this.propertyName + ")";
         var    value = buildProperty.UnevaluatedValue;
         if (value.Contains("$([MSBuild]::") && buildProperty.Predecessor != null)
         {
             value = buildProperty.Predecessor.UnevaluatedValue;
         }
         if (value.Contains(propertyNameEscaped))
         {
             return(value);
         }
         else
         {
             return(this.Unescape(value));
         }
     }
 }
Ejemplo n.º 2
0
        private string GetValue(bool finalValue, IList <ProjectConfig> configs, bool booleanValue)
        {
            MSBuild.Project buildProject = this.PerUser ? this.project.UserBuildProject : this.project.BuildProject;
            if (buildProject == null)
            {
                return(null);
            }

            string value;

            if (this.PerConfig)
            {
                if (configs == null || configs.Count == 0)
                {
                    configs = new ProjectConfig[] { this.project.CurrentConfig };
                }

                value = this.GetPerConfigValue(buildProject, finalValue, configs, booleanValue);
            }
            else
            {
                MSBuild.ProjectProperty buildProperty = buildProject.GetProperty(this.propertyName);
                value = this.GetBuildPropertyValue(buildProperty, finalValue);
                if (booleanValue && String.IsNullOrEmpty(value))
                {
                    value = Boolean.FalseString;
                }
            }

            return(value);
        }
Ejemplo n.º 3
0
        private string GetPerConfigValue(MSBuild.Project buildProject, bool finalValue, IList <ProjectConfig> configs, bool nullIsFalse)
        {
            string unifiedValue = null;

            for (int i = 0; i < configs.Count; i++)
            {
                ProjectConfig config     = configs[i];
                bool          resetCache = (i == 0);

                // we should be using the buildProject parameter here, but this isn't implemented in MPF
                MSBuild.ProjectProperty buildProperty = config.GetMsBuildProperty(this.propertyName, resetCache);
                string value = this.GetBuildPropertyValue(buildProperty, finalValue);

                if (value != null)
                {
                    value = value.Trim();
                }

                if (nullIsFalse && String.IsNullOrEmpty(value))
                {
                    value = Boolean.FalseString;
                }

                if (i == 0)
                {
                    unifiedValue = value;
                }
                else if (unifiedValue != value)
                {
                    unifiedValue = null; // indicates indeterminate value
                    break;
                }
            }

            return(unifiedValue);
        }