当前位置: 首页>>代码示例>>C#>>正文


C# ProjectRootElement.AppendChild方法代码示例

本文整理汇总了C#中Microsoft.Build.Construction.ProjectRootElement.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectRootElement.AppendChild方法的具体用法?C# ProjectRootElement.AppendChild怎么用?C# ProjectRootElement.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.Construction.ProjectRootElement的用法示例。


在下文中一共展示了ProjectRootElement.AppendChild方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPropertyWithCondition

		void AddPropertyWithCondition(ProjectRootElement projectRoot, string name, string value, string condition)
		{
			ProjectPropertyGroupElement groupProperty = projectRoot.CreatePropertyGroupElement();
			groupProperty.Condition = condition;
			projectRoot.AppendChild(groupProperty);
			
			ProjectPropertyElement property = projectRoot.CreatePropertyElement(name);
			groupProperty.AppendChild(property);
			property.Value = value;
			property.Condition = condition;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:11,代码来源:MSBuildProjectPropertiesMergerTests.cs

示例2: AddNewPropertyGroup

		ProjectPropertyGroupElement AddNewPropertyGroup(ProjectRootElement targetProject, PropertyPosition position)
		{
			if (position == PropertyPosition.UseExistingOrCreateAfterLastImport) {
				var propertyGroup = targetProject.CreatePropertyGroupElement();
				targetProject.AppendChild(propertyGroup);
				return propertyGroup;
			}
			return targetProject.AddPropertyGroup();
		}
开发者ID:Netring,项目名称:SharpDevelop,代码行数:9,代码来源:MSBuildBasedProject.cs

示例3: AddGlobalProperties

        /// <summary>
        /// Adds solution related build event macros and other global properties to the wrapper project
        /// </summary>
        private void AddGlobalProperties(ProjectRootElement traversalProject)
        {
            ProjectPropertyGroupElement globalProperties = traversalProject.CreatePropertyGroupElement();
            traversalProject.AppendChild(globalProperties);

            string directoryName = _solutionFile.SolutionFileDirectory;
            if (!directoryName.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                directoryName += Path.DirectorySeparatorChar;
            }

            globalProperties.AddProperty("SolutionDir", EscapingUtilities.Escape(directoryName));
            globalProperties.AddProperty("SolutionExt", EscapingUtilities.Escape(Path.GetExtension(_solutionFile.FullPath)));
            globalProperties.AddProperty("SolutionFileName", EscapingUtilities.Escape(Path.GetFileName(_solutionFile.FullPath)));
            globalProperties.AddProperty("SolutionName", EscapingUtilities.Escape(Path.GetFileNameWithoutExtension(_solutionFile.FullPath)));

            globalProperties.AddProperty("SolutionPath", EscapingUtilities.Escape(Path.Combine(_solutionFile.SolutionFileDirectory, Path.GetFileName(_solutionFile.FullPath))));

            // Add other global properties
            ProjectPropertyGroupElement frameworkVersionProperties = traversalProject.CreatePropertyGroupElement();
            traversalProject.AppendChild(frameworkVersionProperties);

            // Set the property "TargetFrameworkVersion". This is needed for the GetFrameworkPath target.
            // If TargetFrameworkVersion is already set by the user, use that value.
            // Otherwise if MSBuildToolsVersion is 2.0, use "v2.0"
            // Otherwise if MSBuildToolsVersion is 3.5, use "v3.5"
            // Otherwise use "v4.0".
            ProjectPropertyElement tfv20Property = frameworkVersionProperties.AddProperty("TargetFrameworkVersion", "v2.0");
            ProjectPropertyElement tfv35Property = frameworkVersionProperties.AddProperty("TargetFrameworkVersion", "v3.5");
            ProjectPropertyElement tfv40Property = frameworkVersionProperties.AddProperty("TargetFrameworkVersion", "v4.0");
            tfv20Property.Condition = "'$(TargetFrameworkVersion)' == '' and '$(MSBuildToolsVersion)' == '2.0'";
            tfv35Property.Condition = "'$(TargetFrameworkVersion)' == '' and ('$(MSBuildToolsVersion)' == '3.5' or '$(MSBuildToolsVersion)' == '3.0')";
            tfv40Property.Condition = "'$(TargetFrameworkVersion)' == '' and !('$(MSBuildToolsVersion)' == '3.5' or '$(MSBuildToolsVersion)' == '3.0' or '$(MSBuildToolsVersion)' == '2.0')";
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:37,代码来源:SolutionProjectGenerator.cs

示例4: AddVenusConfigurationDefaults

        /// <summary>
        /// Creates the default Venus configuration property based on the selected solution configuration.
        /// Unfortunately, Venus projects only expose one project configuration in the IDE (Debug) although
        /// they allow building Debug and Release from command line. This means that if we wanted to use 
        /// the project configuration from the active solution configuration for Venus projects, we'd always
        /// end up with Debug and there'd be no way to build the Release configuration. To work around this,
        /// we use a special mechanism for choosing ASP.NET project configuration: we set it to Release if
        /// we're building a Release solution configuration, and to Debug if we're building a Debug solution 
        /// configuration. The property is also settable from the command line, in which case it takes 
        /// precedence over this algorithm.
        /// </summary>
        private void AddVenusConfigurationDefaults(ProjectRootElement traversalProject)
        {
            ProjectPropertyGroupElement venusConfiguration = traversalProject.CreatePropertyGroupElement();
            traversalProject.AppendChild(venusConfiguration);

            venusConfiguration.Condition = " ('$(AspNetConfiguration)' == '') ";
            venusConfiguration.AddProperty("AspNetConfiguration", "$(Configuration)");
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:19,代码来源:SolutionProjectGenerator.cs

示例5: AddConfigurationPlatformDefaults

        /// <summary>
        /// Creates default Configuration and Platform values based on solution configurations present in the solution
        /// </summary>
        private void AddConfigurationPlatformDefaults(ProjectRootElement traversalProject)
        {
            ProjectPropertyGroupElement configurationDefaultingPropertyGroup = traversalProject.CreatePropertyGroupElement();
            traversalProject.AppendChild(configurationDefaultingPropertyGroup);

            configurationDefaultingPropertyGroup.Condition = " '$(Configuration)' == '' ";
            configurationDefaultingPropertyGroup.AddProperty("Configuration", EscapingUtilities.Escape(_solutionFile.GetDefaultConfigurationName()));

            ProjectPropertyGroupElement platformDefaultingPropertyGroup = traversalProject.CreatePropertyGroupElement();
            traversalProject.AppendChild(platformDefaultingPropertyGroup);

            platformDefaultingPropertyGroup.Condition = " '$(Platform)' == '' ";
            platformDefaultingPropertyGroup.AddProperty("Platform", EscapingUtilities.Escape(_solutionFile.GetDefaultPlatformName()));
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:17,代码来源:SolutionProjectGenerator.cs

示例6: AddPropertyGroupForSolutionConfiguration

        /// <summary>
        /// Adds a new property group with contents of the given solution configuration to the project
        /// Internal for unit-testing.
        /// </summary>
        internal static void AddPropertyGroupForSolutionConfiguration(ProjectRootElement msbuildProject, SolutionFile solutionFile, SolutionConfigurationInSolution solutionConfiguration)
        {
            ProjectPropertyGroupElement solutionConfigurationProperties = msbuildProject.CreatePropertyGroupElement();
            msbuildProject.AppendChild(solutionConfigurationProperties);
            solutionConfigurationProperties.Condition = GetConditionStringForConfiguration(solutionConfiguration);

            StringBuilder solutionConfigurationContents = new StringBuilder(1024);
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.OmitXmlDeclaration = true;
            using (XmlWriter xw = XmlWriter.Create(solutionConfigurationContents, settings))
            {
                xw.WriteStartElement("SolutionConfiguration");

                // add a project configuration entry for each project in the solution
                foreach (ProjectInSolution project in solutionFile.ProjectsInOrder)
                {
                    ProjectConfigurationInSolution projectConfiguration = null;

                    if (project.ProjectConfigurations.TryGetValue(solutionConfiguration.FullName, out projectConfiguration))
                    {
                        xw.WriteStartElement("ProjectConfiguration");
                        xw.WriteAttributeString("Project", project.ProjectGuid);
                        xw.WriteAttributeString("AbsolutePath", project.AbsolutePath);
                        xw.WriteAttributeString("BuildProjectInSolution", projectConfiguration.IncludeInBuild.ToString());
                        xw.WriteString(projectConfiguration.FullName);

                        foreach (string dependencyProjectGuid in project.Dependencies)
                        {
                            // This is a project that the current project depends *ON* (ie., it must build first)
                            ProjectInSolution dependencyProject;
                            if (!solutionFile.ProjectsByGuid.TryGetValue(dependencyProjectGuid, out dependencyProject))
                            {
                                // If it's not itself part of the solution, that's an invalid solution
                                ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(dependencyProject != null, "SubCategoryForSolutionParsingErrors", new BuildEventFileInfo(solutionFile.FullPath), "SolutionParseProjectDepNotFoundError", project.ProjectGuid, dependencyProjectGuid);
                            }

                            // Add it to the list of dependencies, but only if it should build in this solution configuration 
                            // (If a project is not selected for build in the solution configuration, it won't build even if it's depended on by something that IS selected for build)
                            // .. and only if it's known to be MSBuild format, as projects can't use the information otherwise 
                            if (dependencyProject.ProjectType == SolutionProjectType.KnownToBeMSBuildFormat)
                            {
                                ProjectConfigurationInSolution dependencyProjectConfiguration = null;
                                if (dependencyProject.ProjectConfigurations.TryGetValue(solutionConfiguration.FullName, out dependencyProjectConfiguration) &&
                                    WouldProjectBuild(solutionFile, solutionConfiguration.FullName, dependencyProject, dependencyProjectConfiguration))
                                {
                                    xw.WriteStartElement("ProjectDependency");
                                    xw.WriteAttributeString("Project", dependencyProjectGuid);
                                    xw.WriteEndElement();
                                }
                            }
                        }

                        xw.WriteEndElement(); // </ProjectConfiguration>
                    }
                }

                xw.WriteEndElement(); // </SolutionConfiguration>
            }

            var escapedSolutionConfigurationContents = EscapingUtilities.Escape(solutionConfigurationContents.ToString());

            solutionConfigurationProperties.AddProperty("CurrentSolutionConfigurationContents", escapedSolutionConfigurationContents);

            msbuildProject.AddItem(
                "SolutionConfiguration",
                solutionConfiguration.FullName,
                new Dictionary<string, string>
                {
                    { "Configuration", solutionConfiguration.ConfigurationName },
                    { "Platform", solutionConfiguration.PlatformName },
                    { "Content", escapedSolutionConfigurationContents },
                });
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:78,代码来源:SolutionProjectGenerator.cs

示例7: addImportGroup

        static void addImportGroup(ProjectRootElement root, string label, string condition, Blah blah)
        {
            var avar = root.CreateImportGroupElement();

            root.AppendChild(avar);
            if (!string.IsNullOrEmpty(label))
                avar.Label = label;
            if (!string.IsNullOrEmpty(condition))
                avar.Condition = condition;
            if (blah != null)
                blah(root, avar);
        }
开发者ID:surak8,项目名称:ProjectGen,代码行数:12,代码来源:CProjectGenerator.cs

示例8: createItemDef

 static void createItemDef(ProjectRootElement root, bool p)
 {
     var avar = root.CreateItemDefinitionGroupElement();
     root.AppendChild(avar);
     avar.Condition = makeCfgCondition(p ? DEBUG : RELEASE, PLATFORM);
     addItemDef(avar, COMPILER, p, new Blah3(populateCompiler));
     addItemDef(avar, LINKER, p, new Blah3(populateLinker));
 }
开发者ID:surak8,项目名称:ProjectGen,代码行数:8,代码来源:CProjectGenerator.cs

示例9: createCfgProp

        static void createCfgProp(ProjectRootElement root, string typeDesc, bool isDebug)
        {
            var avar = root.CreatePropertyGroupElement();

            avar.Condition = makeCfgCondition(isDebug ? DEBUG : RELEASE, PLATFORM);
            avar.Label = "Configuration";
            root.AppendChild(avar);
            avar.AddProperty("ConfigurationType", typeDesc);
            avar.AddProperty("UseDebugLibraries", isDebug.ToString());
            if (!isDebug)
                avar.AddProperty("WholeProgramOptimization", "true");
            avar.AddProperty("CharacterSet", "MultiByte");
        }
开发者ID:surak8,项目名称:ProjectGen,代码行数:13,代码来源:CProjectGenerator.cs

示例10: addPropertyGroup

        static ProjectPropertyGroupElement addPropertyGroup(ProjectRootElement root, string p)
        {
            ProjectPropertyGroupElement v1 = root.CreatePropertyGroupElement();

            root.AppendChild(v1);
            if (!string.IsNullOrEmpty(p))
                v1.Label = p;
            return v1;
        }
开发者ID:surak8,项目名称:ProjectGen,代码行数:9,代码来源:CProjectGenerator.cs

示例11: addLabeledGroup

        static void addLabeledGroup(ProjectRootElement root, string p)
        {
            var v0 = root.CreateImportGroupElement();

            v0.Label = p;
            root.AppendChild(v0);
        }
开发者ID:surak8,项目名称:ProjectGen,代码行数:7,代码来源:CProjectGenerator.cs

示例12: addItemGroup

        static ProjectItemGroupElement addItemGroup(ProjectRootElement root)
        {
            ProjectItemGroupElement avar = root.CreateItemGroupElement();

            root.AppendChild(avar);
            return avar;
        }
开发者ID:surak8,项目名称:ProjectGen,代码行数:7,代码来源:CProjectGenerator.cs

示例13: ToProjectTargetElement

        /// <summary>
        /// Creates a ProjectTargetElement representing this instance.  Attaches it to the specified root element.
        /// </summary>
        /// <param name="rootElement">The root element to which the new element will belong.</param>
        /// <returns>The new element.</returns>
        internal ProjectTargetElement ToProjectTargetElement(ProjectRootElement rootElement)
        {
            ProjectTargetElement target = rootElement.CreateTargetElement(Name);
            rootElement.AppendChild(target);

            target.Condition = Condition;
            target.DependsOnTargets = DependsOnTargets;
            target.Inputs = Inputs;
            target.Outputs = Outputs;
            target.Returns = Returns;

            foreach (ProjectTaskInstance taskInstance in Tasks)
            {
                ProjectTaskElement taskElement = target.AddTask(taskInstance.Name);
                taskElement.Condition = taskInstance.Condition;
                taskElement.ContinueOnError = taskInstance.ContinueOnError;
                taskElement.MSBuildArchitecture = taskInstance.MSBuildArchitecture;
                taskElement.MSBuildRuntime = taskInstance.MSBuildRuntime;

                foreach (KeyValuePair<string, string> taskParameterEntry in taskInstance.Parameters)
                {
                    taskElement.SetParameter(taskParameterEntry.Key, taskParameterEntry.Value);
                }

                foreach (ProjectTaskInstanceChild outputInstance in taskInstance.Outputs)
                {
                    if (outputInstance is ProjectTaskOutputItemInstance)
                    {
                        ProjectTaskOutputItemInstance outputItemInstance = outputInstance as ProjectTaskOutputItemInstance;
                        taskElement.AddOutputItem(outputItemInstance.TaskParameter, outputItemInstance.ItemType, outputItemInstance.Condition);
                    }
                    else if (outputInstance is ProjectTaskOutputPropertyInstance)
                    {
                        ProjectTaskOutputPropertyInstance outputPropertyInstance = outputInstance as ProjectTaskOutputPropertyInstance;
                        taskElement.AddOutputItem(outputPropertyInstance.TaskParameter, outputPropertyInstance.PropertyName, outputPropertyInstance.Condition);
                    }
                }
            }

            return target;
        }
开发者ID:nikson,项目名称:msbuild,代码行数:46,代码来源:ProjectTargetInstance.cs


注:本文中的Microsoft.Build.Construction.ProjectRootElement.AppendChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。