internal ProjectPropertyGroupTaskInstance (ProjectPropertyGroupElement xml)
		{
			condition = xml.Condition;
			condition_location = xml.ConditionLocation;
			//this.FullPath = fullPath;
			location = xml.Location;
			
			Properties = xml.Properties.Select (prop => new ProjectPropertyGroupTaskPropertyInstance (prop)).ToArray ();
		}
Ejemplo n.º 2
0
        protected static void AddOrSetProperty(ProjectPropertyGroupElement group, string name, string value) {
            bool anySet = false;
            foreach (var prop in group.Properties.Where(p => p.Name == name)) {
                prop.Value = value;
                anySet = true;
            }

            if (!anySet) {
                group.AddProperty(name, value);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a new property group for a new configuration or platform.
        /// </summary>
        /// <param name="config">Configuration name of the full configuration being added.</param>
        /// <param name="platform">Platform name of the full configuration being added.</param>
        /// <param name="cloneCondition">Condition of property group to clone, if it exists.</param>
        private void AddNewConfigPropertyGroup(string config, string platform, string cloneCondition)
        {
            MSBuildConstruction.ProjectPropertyGroupElement newPropertyGroup = null;

            if (!String.IsNullOrEmpty(cloneCondition))
            {
                foreach (MSBuildConstruction.ProjectPropertyGroupElement propertyGroup in this.ProjectMgr.BuildProject.Xml.PropertyGroups)
                {
                    if (String.Equals(propertyGroup.Condition.Trim(), cloneCondition.Trim(), StringComparison.OrdinalIgnoreCase))
                    {
                        newPropertyGroup = this.ProjectMgr.ClonePropertyGroup(propertyGroup);
                        foreach (MSBuildConstruction.ProjectPropertyElement property in newPropertyGroup.Properties)
                        {
                            if (property.Name.Equals(WixProjectFileConstants.OutputPath) ||
                                property.Name.Equals(WixProjectFileConstants.IntermediateOutputPath))
                            {
                                property.Parent.RemoveChild(property);
                            }
                        }
                        break;
                    }
                }
            }

            if (newPropertyGroup == null)
            {
                newPropertyGroup = this.ProjectMgr.BuildProject.Xml.AddPropertyGroup();
                IList <KeyValuePair <KeyValuePair <string, string>, string> > propVals = this.NewConfigProperties;
                foreach (KeyValuePair <KeyValuePair <string, string>, string> data in propVals)
                {
                    KeyValuePair <string, string> propData = data.Key;
                    string value = data.Value;
                    MSBuildConstruction.ProjectPropertyElement newProperty = newPropertyGroup.AddProperty(propData.Key, value);
                    if (!String.IsNullOrEmpty(propData.Value))
                    {
                        newProperty.Condition = propData.Value;
                    }
                }
            }

            string outputBasePath = this.ProjectMgr.OutputBaseRelativePath;
            string outputPath     = Path.Combine(outputBasePath, WixConfigProvider.ConfigPath);

            newPropertyGroup.AddProperty(WixProjectFileConstants.OutputPath, outputPath);

            string intermediateBasePath = WixConfigProvider.IntermediateBaseRelativePath;
            string intermediatePath     = Path.Combine(intermediateBasePath, WixConfigProvider.ConfigPath);

            newPropertyGroup.AddProperty(WixProjectFileConstants.IntermediateOutputPath, intermediatePath);

            string newCondition = String.Format(CultureInfo.InvariantCulture, WixProjectConfig.ConfigAndPlatformConditionString, config, platform);

            newPropertyGroup.Condition = newCondition;
        }
        internal SimpleProjectProfile([NotNull] AlternateProject project, [NotNull] string name,
            [NotNull] ProjectPropertyGroupElement groupElement)
        {
            _groupElement = groupElement;
            Project = project;
            Name = name;

            string[] platform = name.Split(new[] {'|'}, 2, StringSplitOptions.RemoveEmptyEntries);
            _isDebug = platform[0].ToLowerInvariant() == "debug";
            _platform = (Platform)Enum.Parse(typeof(Platform), platform[1], true);

            groupElement.SetProperty(PlatformTargetProperty, platform[1]);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Emulates the behavior of SetProperty(name, value, condition) on the old MSBuild object model.
        /// This finds a property group with the specified condition (or creates one if necessary) then sets the property in there.
        /// </summary>
        private void SetPropertyUnderCondition(string propertyName, string propertyValue, string condition)
        {
            string conditionTrimmed = (condition == null) ? String.Empty : condition.Trim();

            if (conditionTrimmed.Length == 0)
            {
                this.project.BuildProject.SetProperty(propertyName, propertyValue);
                return;
            }

            // New OM doesn't have a convenient equivalent for setting a property with a particular property group condition.
            // So do it ourselves.
            MSBuildConstruction.ProjectPropertyGroupElement newGroup = null;

            foreach (MSBuildConstruction.ProjectPropertyGroupElement group in this.project.BuildProject.Xml.PropertyGroups)
            {
                if (String.Equals(group.Condition.Trim(), conditionTrimmed, StringComparison.OrdinalIgnoreCase))
                {
                    newGroup = group;
                    break;
                }
            }

            if (newGroup == null)
            {
                newGroup           = this.project.BuildProject.Xml.AddPropertyGroup(); // Adds after last existing PG, else at start of project
                newGroup.Condition = condition;
            }

            foreach (MSBuildConstruction.ProjectPropertyElement property in newGroup.PropertiesReversed) // If there's dupes, pick the last one so we win
            {
                if (String.Equals(property.Name, propertyName, StringComparison.OrdinalIgnoreCase) && property.Condition.Length == 0)
                {
                    property.Value = propertyValue;
                    return;
                }
            }

            newGroup.AddProperty(propertyName, propertyValue);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// For internal use only.
        /// This creates a copy of an existing configuration and add it to the project.
        /// Caller should change the condition on the PropertyGroup.
        /// If derived class want to accomplish this, they should call ConfigProvider.AddCfgsOfCfgName()
        /// It is expected that in the future MSBuild will have support for this so we don't have to
        /// do it manually.
        /// </summary>
        /// <param name="group">PropertyGroup to clone</param>
        /// <returns></returns>
        protected virtual ProjectPropertyGroupElement ClonePropertyGroup(MSBuild.Project project, ProjectPropertyGroupElement group)
        {
            if (project == null)
                throw new ArgumentNullException("project");
            if (group == null)
                throw new ArgumentNullException("group");

            // Create a new (empty) PropertyGroup
            ProjectPropertyGroupElement newPropertyGroup = project.Xml.CreatePropertyGroupElement();
            project.Xml.InsertAfterChild(newPropertyGroup, group);

            // Now copy everything from the group we are trying to clone to the group we are creating
            if (!String.IsNullOrEmpty(group.Condition))
                newPropertyGroup.Condition = group.Condition;

            foreach (ProjectPropertyElement prop in group.Properties)
            {
                ProjectPropertyElement newProperty = newPropertyGroup.AddProperty(prop.Name, prop.Value);
                if (!String.IsNullOrEmpty(prop.Condition))
                    newProperty.Condition = prop.Condition;
            }

            return newPropertyGroup;
        }
Ejemplo n.º 7
0
		private void AddOutputPath(ProjectPropertyGroupElement newConfig, string configName)
		{
			//add the output path
			string outputBasePath = this.ProjectMgr.OutputBaseRelativePath;
			if (outputBasePath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
				outputBasePath = Path.GetDirectoryName(outputBasePath);
			newConfig.AddProperty("OutputPath", Path.Combine(outputBasePath, configName) + Path.DirectorySeparatorChar.ToString());

		}
Ejemplo n.º 8
0
        /// <summary>
        /// Parse a ProjectPropertyGroupElement from the element
        /// </summary>
        private ProjectPropertyGroupElement ParseProjectPropertyGroupElement(XmlElementWithLocation element, ProjectElementContainer parent)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, s_validAttributesOnlyConditionAndLabel);

            ProjectPropertyGroupElement propertyGroup = new ProjectPropertyGroupElement(element, parent, _project);

            foreach (XmlElementWithLocation childElement in ProjectXmlUtilities.GetVerifyThrowProjectChildElements(element))
            {
                ProjectPropertyElement property = ParseProjectPropertyElement(childElement, propertyGroup);

                propertyGroup.AppendParentedChildNoChecks(property);
            }

            return propertyGroup;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Parse a ProjectPropertyElement from the element
        /// </summary>
        private ProjectPropertyElement ParseProjectPropertyElement(XmlElementWithLocation element, ProjectPropertyGroupElement parent)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, s_validAttributesOnlyConditionAndLabel);

            XmlUtilities.VerifyThrowProjectValidElementName(element);
            ProjectErrorUtilities.VerifyThrowInvalidProject(XMakeElements.IllegalItemPropertyNames[element.Name] == null && !ReservedPropertyNames.IsReservedProperty(element.Name), element.Location, "CannotModifyReservedProperty", element.Name);

            // All children inside a property are ignored, since they are only part of its value
            return(new ProjectPropertyElement(element, parent, _project));
        }
        private ToolChainOptions LoadToolChainOptions(ProjectPropertyGroupElement grp)
        {
            ToolChainOptions opts = new ToolChainOptions();
            List<ProjectPropertyElement> remList = new List<ProjectPropertyElement>();

            foreach (ProjectPropertyElement bp in grp.Properties)
            {
                ToolFlag flag;
                remList.Add(bp);

                switch (bp.Name)
                {
                    case "ToolName":
                        opts.ToolName = bp.Value;
                        break;
                    case "DEVICE_TYPE":
                        opts.DeviceType = bp.Value;
                        break;
                    case CommonToolFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.CommonFlags.Add(flag);
                        break;
                    case CCppCommonFlagTag:
                    case CCppTargFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.C_CppFlags.Add(flag);
                        break;
                    case CppFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.CppFlags.ToolFlags.Add(flag);
                        break;
                    case AsmFlagTag:
                    case AsmArmFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.AsmFlags.ToolFlags.Add(flag);
                        break;
                    case ArchiverFlagTag:
                    case ArchiverArmFlagTag:
                    case ArchiverPlatFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.ArchiverFlags.ToolFlags.Add(flag);
                        break;
                    case LinkerFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.LinkerFlags.ToolFlags.Add(flag);
                        break;

                    default:
                        {
                            string uc = bp.Name.ToUpper();

                            if (uc.Contains("CC_CPP_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.C_CppFlags.Add(flag);
                            }
                            else if (uc.Contains("CC_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.CFlags.ToolFlags.Add(flag);
                            }
                            else if (uc.Contains("AS_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.AsmFlags.ToolFlags.Add(flag);
                            }
                            else
                            {
                                remList.Remove(bp);
                            }
                        }
                        break;
                }
            }
            foreach (ProjectPropertyElement bp in remList)
            {
                grp.RemoveChild(bp);
            }

            return opts;
        }
 private void AddFormattedPropGroup(string flagTag, List<ToolFlag> flags, Project proj, ProjectPropertyGroupElement group)
 {
     if (group == null)
     {
         AddFormattedPropGroup(flagTag, flags, proj);
     }
     else
     {
         foreach (ToolFlag flag in flags)
         {
             group.AddProperty(flagTag, ToEnvVar(flagTag) + flag.Flag);
         }
     }
 }
Ejemplo n.º 12
0
        internal ProjectPropertyElement LookupProperty(ProjectPropertyGroupElement parent, string name, string condition = null) {
            ProjectPropertyElement property = null;

            var label = Pivots.GetExpressionLabel(condition);
            name = name.Replace(".", "_");

            if(string.IsNullOrEmpty(condition)) {
                property = parent.Properties.FirstOrDefault(each => name == each.Name && string.IsNullOrEmpty(each.Condition));
                if(property != null) {
                    return property;
                }
                return parent.AddProperty(name, "");
            }

            var conditionExpression = Pivots.GetMSBuildCondition(Name, condition);
            property = parent.Properties.FirstOrDefault(each => name == each.Name && each.Condition == conditionExpression);
            if(property != null) {
                return property;
            }

            property = parent.AddProperty(name, "");

            property.Label = label;
            property.Condition = conditionExpression;
            return property;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initialize all member variables to get ready for a conversion.
        /// </summary>
        /// <owner>RGoel</owner>
        private void Initialize()
        {
            this.xmakeProject = null;
            this.globalPropertyGroup = null;
            this.language = null;
            this.projectGuid = null;
            this.preBuildEvent = null;
            this.postBuildEvent = null;
            this.solution = null;
            this.newWebReferencePropertiesAdded = false;
            this.platformForVSD = null;
            this.assemblyName = null;
            this.outputType = null;
            this.hasWindowsFormsReference = false;
            this.isMyTypeAlreadySetInOriginalProject = false;
            this.conversionWarnings = new ArrayList();

            this.propertiesToEscape = new Dictionary<string,string>(StringComparer.OrdinalIgnoreCase);
            this.propertiesToEscape.Add("ApplicationIcon", null);
            this.propertiesToEscape.Add("AssemblyKeyContainerName", null);
            this.propertiesToEscape.Add("AssemblyName", null);
            this.propertiesToEscape.Add("AssemblyOriginatorKeyFile", null);
            this.propertiesToEscape.Add("RootNamespace", null);
            this.propertiesToEscape.Add("StartupObject", null);
            this.propertiesToEscape.Add("ConfigurationOverrideFile", null);
            this.propertiesToEscape.Add("DocumentationFile", null);
            this.propertiesToEscape.Add("OutputPath", null);
        }
		/// <summary>
		/// Finds the &lt;Configuration&gt; or &lt;Platform&gt; element in this property group.
		/// </summary>
		ProjectPropertyElement FindConfigElement(ProjectPropertyGroupElement g)
		{
			return g.Properties.FirstOrDefault(p => MSBuildInternals.PropertyNameComparer.Equals(p.Name, isPlatform ? "Platform" : "Configuration"));
		}
Ejemplo n.º 15
0
 internal ProjectPropertyGroupElement AddPropertyInitializer(string propertyName, string conditionExpression, string value, ProjectPropertyGroupElement ppge = null) {
     ppge = ppge ?? Xml.AddPropertyGroup();
     ppge.Label = "Additional property initializers";
     ppge.AddProperty(propertyName, value).Condition = conditionExpression;
     return ppge;
 }
		/// <summary>
		/// copy properties from g into a new property group for newConfiguration and newPlatform
		/// </summary>
		void CopyProperties(ProjectRootElement project, ProjectPropertyGroupElement g, ConfigurationAndPlatform newConfig)
		{
			ProjectPropertyGroupElement ng = project.AddPropertyGroup();
			ng.Condition = newConfig.ToCondition();
			foreach (var p in g.Properties) {
				ng.AddProperty(p.Name, p.Value).Condition = p.Condition;
			}
		}
Ejemplo n.º 17
0
        /// <summary>
        /// Populate the property group with the individual options
        /// </summary>
        private void PopulatePropertyGroup(ProjectPropertyGroupElement configPropertyGroup)
        {
            string propertyName;

            foreach (CompSwitchInfo compSwitchInfo in validCompilerSwitches)
            {
                propertyName = compSwitchInfo.SwitchProjectPropertyName;

                // No need to remove the already existing property node
                // since the switches we are dealing with couldnt have been
                // set anywhere else in the property pages except the additional
                // options

                switch (compSwitchInfo.SwitchValueType)
                {
                    case SwitchValueType.SVT_Boolean:
                        if (null != compSwitchInfo.SwitchValue)
                        {
                            configPropertyGroup.AddProperty(
                                propertyName, 
                                compSwitchInfo.SwitchValue.ToString().ToLower(CultureInfo.InvariantCulture)
                            );
                        }
                    break;

                    case SwitchValueType.SVT_String:
                        if (null != compSwitchInfo.SwitchValue)
                        {
                            configPropertyGroup.AddProperty(
                                propertyName,
                                compSwitchInfo.SwitchValue.ToString()
                            );
                        }
                    break;

                    case SwitchValueType.SVT_MultiString:
                        Debug.Assert(null != compSwitchInfo.SwitchValue, "Expected non null value for multistring switch");
                        if (0 != ((StringBuilder)(compSwitchInfo.SwitchValue)).Length)
                        {
                            configPropertyGroup.AddProperty(
                                propertyName,
                                compSwitchInfo.SwitchValue.ToString()
                            );
                        }
                    break;

                    default:
                        Debug.Assert(false, "Unknown switch value type");
                    break;
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// One and only entry point to the functionality offered by this class
        /// </summary>
        public void ProcessAdditionalOptions(
            string additionalOptionsValue,
            ProjectPropertyGroupElement configPropertyGroup
        )
        {
            // Trivial case
            if (null == additionalOptionsValue)
            {
                return;
            }

            // Tokenize the additional options first
            string[] compSwitchList;
            compSwitchList = TokenizeAdditionalOptionsValue(additionalOptionsValue);
            
            // Extract the switch arguments
            foreach (string compSwitch in compSwitchList)
            {
                foreach (CompSwitchInfo compSwitchInfo in validCompilerSwitches)
                {
                    if (ExtractSwitchInfo(compSwitchInfo, compSwitch))
                    {
                        break;
                    }
                }
            }
            
            // Finally populate the project file and we'r done!
            PopulatePropertyGroup(configPropertyGroup);
        }
Ejemplo n.º 19
0
 void SetKnownProperties (ProjectPropertyGroupElement properties)
 {
         properties.AddProperty ("AssemblyName", Path.GetFileNameWithoutExtension ("ZigZag.exe"));
         properties.AddProperty ("ProjectGuid", projectGuid.ToString ("B"));
         properties.AddProperty ("CheckForOverflowUnderflow", false.ToString ());
         properties.AddProperty ("CodePage", String.Empty);
         properties.AddProperty ("DebugSymbols", true.ToString ());
         properties.AddProperty ("DebugType", "Full");
         properties.AddProperty ("Optimize", false.ToString ());
         properties.AddProperty ("Platform", "AnyCPU");
         properties.AddProperty ("ProjectTypeGuids", projectTypeGuid.ToString ("B"));
         properties.AddProperty ("AllowUnsafeBlocks", false.ToString ());
         properties.AddProperty ("WarningLevel", "4");
         properties.AddProperty ("OutputPath", ProjectCollection.Escape ("bin\\Debug"));
         properties.AddProperty ("OutputType", "winexe");
         properties.AddProperty ("DefineConstants", "DEBUG,TRACE");
         properties.AddProperty ("TreatWarningsAsErrors", true.ToString ());
 }
Ejemplo n.º 20
0
 static void createNullProperty(ProjectPropertyGroupElement ppge, string key, string val)
 {
     var avar = ppge.AddProperty(key, val);
     avar.Condition = "'" + propRef(key) + "'==''";
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initialize a parented ProjectPropertyElement
 /// </summary>
 internal ProjectPropertyElement(XmlElementWithLocation xmlElement, ProjectPropertyGroupElement parent, ProjectRootElement containingProject)
     : base(xmlElement, parent, containingProject)
 {
     ErrorUtilities.VerifyThrowArgumentNull(parent, nameof(parent));
 }
Ejemplo n.º 22
0
 static void createNullProperty1(ProjectPropertyGroupElement ppge, string key, string valRef)
 {
     createNullProperty(ppge, key, propRef(valRef));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Processes the &lt;InteropRegistration&gt; element, and everything within it.
        /// As it is doing this, it will add extra properties to the configuration's
        /// property group.
        /// </summary>
        /// <owner>RGoel</owner>
        private void ProcessInteropRegistrationElement
            (
            XmlElementWithLocation      interopRegistrationElement,
            ProjectPropertyGroupElement configPropertyGroup
            )
        {
            // Make sure this is the <InteropRegistration> element.
            error.VerifyThrow((interopRegistrationElement != null) &&
                (interopRegistrationElement.Name == VSProjectElements.interopRegistration),
                "Expected <InteropRegistration> element.");

            // Make sure we've been given a valid configuration property group.
            error.VerifyThrow(configPropertyGroup != null,
                "Expected configuration's property group.");

            // All of the attributes on the <InteropRegistration> tag get converted to XMake
            // properties.  For example,
            // -----------------------------------------------------------------------
            // Everett format:
            // ===============
            //    <Config
            //        ...
            //        ...
            //        ... <all other configuration properties>
            //        ...
            //        ...
            //    >
            //        <InteropRegistration
            //            RegisteredComClassic = "true"
            //            RegisteredOutput = "Project1.dll"
            //            RegisteredTypeLib = "Project1.tlb"
            //        />
            //    </Config>
            // -----------------------------------------------------------------------
            // XMake format:
            // =============
            //    <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
            //        ...
            //        ...
            //        ... <all other configuration properties>
            //        ...
            //        ...
            //        <RegisteredComClassic>true</RegisteredComClassic>
            //        <RegisteredOutput>Project1.dll</RegisteredOutput>
            //        <RegisteredTypeLib>Project1.tlb</RegisteredTypeLib>
            //    </PropertyGroup>
            // -----------------------------------------------------------------------
            this.AddXMakePropertiesFromXMLAttributes(configPropertyGroup, interopRegistrationElement);

            // There should be no children of the <InteropRegistration> element.
            ProjectXmlUtilities.VerifyThrowProjectNoChildElements(interopRegistrationElement);
        }
Ejemplo n.º 24
0
        private void PopulateEmptyConfig(ref ProjectPropertyGroupElement newConfig)
        {
            newConfig = this.project.BuildProject.Xml.AddPropertyGroup();
            foreach (KeyValuePair<KeyValuePair<string, string>, string> pair in this.NewConfigProperties)
            {
                var key = pair.Key;
                var unevaluatedValue = pair.Value;
                var element = newConfig.AddProperty(key.Key, unevaluatedValue);

                if (!string.IsNullOrEmpty(key.Value))
                    element.Condition = key.Value;
            }
        }
        private ISA LoadISASettings(ProjectPropertyGroupElement isaGrp)
        {
            ISA isa = new ISA();

            isa.BuildToolOptions = LoadToolChainOptions(isaGrp);

            foreach (ProjectPropertyElement prop in isaGrp.Properties)
            {
                switch (prop.Name)
                {
                    case ISAsTag:
                        isa.Name = prop.Value;
                        break;
                }
            }
            return isa;
        }
Ejemplo n.º 26
0
		/// <summary>
		/// Finds the <c>BuildProperty</c> object used to store <paramref name="propertyName"/>
		/// in the specified configuration/platform.
		/// </summary>
		/// 
		/// Warning: you need to lock(project.SyncRoot) around calls to GetAllProperties
		/// until you no longer need to access the BuildProperty objects!
		/// <param name="configuration">The configuration to use.</param>
		/// <param name="platform">The platform to use.</param>
		/// <param name="propertyName">The property to look for.</param>
		/// <param name="group">[Out], the property group in which the property was found</param>
		/// <param name="location">[Out], the storage location the condition of the property
		/// group was referring to</param>
		protected ProjectPropertyElement FindPropertyObject(string configuration, string platform,
		                                                    string propertyName,
		                                                    out ProjectPropertyGroupElement group,
		                                                    out PropertyStorageLocations location)
		{
			using (var c = OpenConfiguration(configuration, platform)) {
				bool wasHiddenByImportedProperty;
				var prop = c.GetNonImportedProperty(propertyName, out wasHiddenByImportedProperty);
				if (prop != null) {
					group = (ProjectPropertyGroupElement)prop.Xml.Parent;
					location = c.GetLocation(prop);
					return prop.Xml;
				} else {
					group = null;
					location = PropertyStorageLocations.Unknown;
					return null;
				}
			}
		}
        private void AddBuildToolFlags(ToolChainOptions options, Project proj, ProjectPropertyGroupElement group)
        {
            //ProjectPropertyGroupElement group;
            //ProjectPropertyElement prop;

            AddFormattedPropGroup(CommonToolFlagTag, options.CommonFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach(ToolFlag flag in options.CommonFlags)
            //{
            //    prop = group.AddProperty(CommonToolFlagTag, ToEnvVar(CommonToolFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(CCppCommonFlagTag, options.C_CppFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.C_CppFlags)
            //{
            //    prop = group.AddProperty(CCppCommonFlagTag, ToEnvVar(CCppCommonFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(CFlagTag, options.CFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.CFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(CFlagTag, ToEnvVar(CFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(CppFlagTag, options.CppFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.CppFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(CppFlagTag, ToEnvVar(CppFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(AsmFlagTag, options.AsmFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.AsmFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(AsmFlagTag, ToEnvVar(AsmFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(ArchiverFlagTag, options.ArchiverFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.ArchiverFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(ArchiverFlagTag, ToEnvVar(ArchiverFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(LinkerFlagTag, options.LinkerFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.LinkerFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(LinkerFlagTag, ToEnvVar(LinkerFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Processes the language (e.g. &lt;CSHARP&gt;) XML element, and everything
        /// within it.  As it is doing this, it will add stuff to the xmakeProject.
        /// </summary>
        /// <owner>RGoel</owner>
        private void ProcessLanguageElement
            (
            XmlElementWithLocation      languageElement
            )
        {
            // Make sure we have a valid XML element to process.
            error.VerifyThrow(languageElement != null, "Expected valid XML language element.");

            // Make sure the caller has given us a valid xmakeProject object.
            error.VerifyThrow(xmakeProject != null, "Expected valid XMake project object.");

            // Get the project instance GUID for this project file.  It is required for
            // the main project file, but not for the .USER file.
            this.projectGuid = languageElement.GetAttribute(VSProjectAttributes.projectGuid);
            ProjectErrorUtilities.VerifyThrowInvalidProject((this.projectGuid != null) || (this.isUserFile == true),
                languageElement.Location, "MissingAttribute", languageElement.Name, VSProjectAttributes.projectGuid);

            // Get the project type for this project file.  We only support "Local".  We do not
            // convert web projects -- that's Venus's job.
            string projectType = languageElement.GetAttribute(VSProjectAttributes.projectType);
            ProjectErrorUtilities.VerifyThrowInvalidProject(projectType == null || projectType.Length == 0 ||
                (String.Compare(projectType, VSProjectAttributes.local, StringComparison.OrdinalIgnoreCase) == 0),
                languageElement.Location, "ProjectTypeCannotBeConverted", projectType);

            // All of the attributes on the language tag get converted to XMake
            // properties.  A couple exceptions ... for the "ProductVersion"
            // and "SchemaVersion" properties, we don't just copy the previous
            // value; we actually set it to 8.0.##### and 2.0 respectively.
            // In addition, we also add a default value for the "Configuration"
            // property.  For example,
            // -----------------------------------------------------------------------
            // Everett format:
            // ===============
            //    <CSHARP
            //        ProjectType = "Local"
            //        ProductVersion = "7.10.2284"
            //        SchemaVersion = "1.0"
            //        ProjectGuid = "{71F4C768-901B-4027-BD9D-378665D6C0B2}"
            //    >
            //        ...
            //        ...
            //        ...
            //    </CSHARP>
            // -----------------------------------------------------------------------
            // XMake format:
            // =============
            //    <PropertyGroup>
            //        <ProjectType>Local</ProjectType>
            //        <ProductVersion>8.0.31031</ProductVersion>
            //        <SchemaVersion>2.0</SchemaVersion>
            //        <ProjectGuid>{71F4C768-901B-4027-BD9D-378665D6C0B2}</ProjectGuid>
            //        <Configuration Condition = " '$(Configuration)' == '' ">Debug</Configuration>
            //    </PropertyGroup>
            // -----------------------------------------------------------------------
            // For Dev11, we are removing "ProductVersion" and "SchemaVersion" from all
            // project templates. Thus, eliminated writing these tags from this method.
            // -----------------------------------------------------------------------

            string originalMyType = languageElement.GetAttribute(XMakeProjectStrings.myType);
            if ((originalMyType != null) && (originalMyType.Length != 0))
            {
                // Flag the fact that the Everett project already had a MyType property in there,
                // so we don't try to override it later.
                this.isMyTypeAlreadySetInOriginalProject = true;
            }

            // Copy over all the other properties.
            this.globalPropertyGroup = xmakeProject.AddPropertyGroup();
            this.AddXMakePropertiesFromXMLAttributes(this.globalPropertyGroup, languageElement);

            // Add the "Configuration" property.  Put a condition on it so it only gets
            // set to the default if the user doesn't have an environment variable called
            // "Configuration".  The final XML looks something like this:
            //        <Configuration Condition = " '$(Configuration)' == '' ">Debug</Configuration>
            ProjectPropertyElement configurationProperty = this.globalPropertyGroup.AddProperty(
                XMakeProjectStrings.configuration, XMakeProjectStrings.defaultConfiguration);
            configurationProperty.Condition = XMakeProjectStrings.configurationPrefix +
                XMakeProjectStrings.configurationSuffix;

            // Add the "Platform" property.  Put a condition on it so it only gets
            // set to the default if the user doesn't have an environment variable called
            // "Platform".  The final XML looks something like this:
            //        <Property Platform = "AnyCPU" Condition = " '$(Platform)' == '' " />
            // Platform of course depends on the language we are dealing with - J# in whidbey supports only x86
            string platform = (this.language != VSProjectElements.visualJSharp)
                ? XMakeProjectStrings.defaultPlatform
                : XMakeProjectStrings.x86Platform;
            ProjectPropertyElement platformProperty = this.globalPropertyGroup.AddProperty(
                XMakeProjectStrings.platform, platform);
            platformProperty.Condition = XMakeProjectStrings.platformPrefix +
                XMakeProjectStrings.platformSuffix;

            bool isTriumphProject = false;

            // For SDE projects, we need to add a special <ProjectTypeGuids> property to
            // the project file.  This will contain the project types for both the
            // flavor and the main language project type.  In addition, SDE projects
            // need to have the host process disabled.
            if (!this.isUserFile)
            {
                if (languageElement.Name == VSProjectElements.ECSharp)
                {
                    this.globalPropertyGroup.AddProperty ( XMakeProjectStrings.projectTypeGuids,
                                                              "{" +
                                                              XMakeProjectStrings.VSDCSProjectTypeGuid +
                                                              "};{" +
                                                              XMakeProjectStrings.cSharpGuid +
                                                              "}" );
                    string visualStudioProjectExtensions =  GetProjectExtensionsString(XMakeProjectStrings.visualStudio);
                    visualStudioProjectExtensions += XMakeProjectStrings.disableCSHostProc;
                    SetProjectExtensionsString(XMakeProjectStrings.visualStudio, visualStudioProjectExtensions);
                }
                else if (languageElement.Name == VSProjectElements.EVisualBasic)
                {
                    this.globalPropertyGroup.AddProperty ( XMakeProjectStrings.projectTypeGuids,
                                                              "{" +
                                                              XMakeProjectStrings.VSDVBProjectTypeGuid +
                                                              "};{" +
                                                              XMakeProjectStrings.visualBasicGuid +
                                                              "}" );
                    string visualStudioProjectExtensions = GetProjectExtensionsString(XMakeProjectStrings.visualStudio);
                    visualStudioProjectExtensions += XMakeProjectStrings.disableVBHostProc;
                    SetProjectExtensionsString(XMakeProjectStrings.visualStudio, visualStudioProjectExtensions);
                }
            }


            // Loop through all the direct child elements of the language element.
            foreach(XmlNode languageChildNode in languageElement)
            {
                // Handle XML comments under the the language node (just ignore them).
                if ((languageChildNode.NodeType == XmlNodeType.Comment) ||
                    (languageChildNode.NodeType == XmlNodeType.Whitespace))
                {
                    continue;
                }

                if (languageChildNode.NodeType == XmlNodeType.Element)
                {
                    XmlElementWithLocation languageChildElement = (XmlElementWithLocation)languageChildNode;

                    switch (languageChildElement.Name)
                    {
                        // The <Build> element.
                        case VSProjectElements.build:
                            this.ProcessBuildElement((XmlElementWithLocation)languageChildElement);
                            break;

                        case VSProjectElements.files:
                            this.ProcessFilesElement((XmlElementWithLocation)languageChildElement);
                            break;

                        case VSProjectElements.startupServices:
                            this.ProcessStartupServicesElement((XmlElementWithLocation)languageChildElement);
                            break;

                        case VSProjectElements.userProperties:
                            this.ProcessUserPropertiesElement((XmlElementWithLocation)languageChildElement, out isTriumphProject);
                            break;

                        case VSProjectElements.otherProjectSettings:
                            this.ProcessOtherProjectSettingsElement((XmlElementWithLocation)languageChildElement);
                            break;

                        default:
                            ProjectErrorUtilities.VerifyThrowInvalidProject(false, languageChildElement.Location,
                                "UnrecognizedChildElement", languageChildNode.Name,
                                languageElement.Name);
                            break;
                    }
                }
                else
                {
                    ProjectXmlUtilities.ThrowProjectInvalidChildElement(languageChildNode.Name, languageElement.Name, languageElement.Location);
                }
            }

            AddFinalPropertiesAndImports(languageElement, isTriumphProject);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Parse a ProjectPropertyElement from the element
        /// </summary>
        private ProjectPropertyElement ParseProjectPropertyElement(XmlElementWithLocation element, ProjectPropertyGroupElement parent)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, s_validAttributesOnlyConditionAndLabel);

            XmlUtilities.VerifyThrowProjectValidElementName(element);
            ProjectErrorUtilities.VerifyThrowInvalidProject(XMakeElements.IllegalItemPropertyNames[element.Name] == null && !ReservedPropertyNames.IsReservedProperty(element.Name), element.Location, "CannotModifyReservedProperty", element.Name);

            // All children inside a property are ignored, since they are only part of its value
            return new ProjectPropertyElement(element, parent, _project);
        }
Ejemplo n.º 30
0
		private void PopulateEmptyConfig(ref ProjectPropertyGroupElement newConfig)
		{
			newConfig = this.project.BuildProject.Xml.AddPropertyGroup();
			// Get the list of property name, condition value from the config provider
			IList<KeyValuePair<KeyValuePair<string, string>, string>> propVals = this.NewConfigProperties;
			foreach (KeyValuePair<KeyValuePair<string, string>, string> data in propVals)
			{
				KeyValuePair<string, string> propData = data.Key;
				string value = data.Value;
				ProjectPropertyElement newProperty = newConfig.AddProperty(propData.Key, value);
				if (!String.IsNullOrEmpty(propData.Value))
					newProperty.Condition = propData.Value;
			}

		}
Ejemplo n.º 31
0
		/// <summary>
		/// copy properties from g into a new property group for newConfiguration and newPlatform
		/// </summary>
		void CopyProperties(ProjectRootElement project, ProjectPropertyGroupElement g, string newConfiguration, string newPlatform)
		{
			ProjectPropertyGroupElement ng = project.AddPropertyGroup();
			ng.Condition = CreateCondition(newConfiguration, newPlatform);
			foreach (var p in g.Properties) {
				ng.AddProperty(p.Name, p.Value).Condition = p.Condition;
			}
		}
Ejemplo n.º 32
0
 /// <summary>
 /// Initialize a parented ProjectPropertyElement
 /// </summary>
 internal ProjectPropertyElement(XmlElementWithLocation xmlElement, ProjectPropertyGroupElement parent, ProjectRootElement containingProject)
     : base(xmlElement, parent, containingProject)
 {
     ErrorUtilities.VerifyThrowArgumentNull(parent, "parent");
 }
Ejemplo n.º 33
0
 static void b2(ProjectPropertyGroupElement ppge)
 {
     //            ppge.AddProperty("OutDir", "$(SolutionDir)");
     //            ppge.AddProperty("LinkIncremental", "false");
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Takes an XML element from an Everett project file, and loops through
        /// all its attributes.  For each attribute, it adds a new XMake property
        /// to the destination project file in the property group passed in.
        /// </summary>
        /// <owner>RGoel</owner>
        private void AddXMakePropertiesFromXMLAttributes
            (
            ProjectPropertyGroupElement propertyGroup,
            XmlElement          xmlElement
            )
        {
            error.VerifyThrow(propertyGroup != null, "Expected valid ProjectPropertyElementGroup to add properties to.");

            foreach (XmlAttribute xmlAttribute in xmlElement.Attributes)
            {
                // Add this as a property to the MSBuild project file.  If the property is one of those
                // that contains an identifier or a path, we must escape it to treat it as a literal.
                string value = xmlAttribute.Value;
                if (this.propertiesToEscape.ContainsKey(xmlAttribute.Name))
                {
                    value = ProjectCollection.Escape(value);
                }

                propertyGroup.AddProperty(xmlAttribute.Name, value);
            }
        }