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


C# Project.AddItem方法代码示例

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


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

示例1: AddReference

        private void AddReference(InputProjectDriver inputProjectDriver, Project project, string reference)
        {
            string referenceFullPath = Path.GetFullPath(Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), reference));
            string assemblyName = Path.GetFileNameWithoutExtension(referenceFullPath);
            Debug.Assert(assemblyName != null);

            project.AddItem("Reference", assemblyName, new[]
                                                           {
                                                               new KeyValuePair<string, string>("HintPath", referenceFullPath),
                                                           });
        }
开发者ID:JonKruger,项目名称:SpecFlow,代码行数:11,代码来源:ProjectGenerator.cs

示例2: ProjectGetter

        public void ProjectGetter()
        {
            Project project = new Project();
            ProjectItem item = project.AddItem("i", "i1")[0];

            Assert.Equal(true, Object.ReferenceEquals(project, item.Project));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:7,代码来源:ProjectItem_Tests.cs

示例3: BuildProject

		public static MSbuildResult BuildProject(MsBuildSettings settings, string projectFileName, DirectoryInfo dir)
		{
			var result = new MSbuildResult();
			var path = Path.Combine(dir.FullName, projectFileName);
			var project = new Project(path, null, null, new ProjectCollection());
			project.SetProperty("CscToolPath", settings.CompilerDirectory.FullName);
			var includes = new HashSet<string>(
				project.AllEvaluatedItems
				.Where(i => i.ItemType == "None" || i.ItemType == "Content")
				.Select(i => Path.GetFileName(i.EvaluatedInclude.ToLowerInvariant())));
			foreach (var dll in settings.WellKnownLibsDirectory.GetFiles("*.dll"))
				if (!includes.Contains(dll.Name.ToLowerInvariant()))
					project.AddItem("None", dll.FullName);
			project.Save();
			using (var stringWriter = new StringWriter())
			{
				var logger = new ConsoleLogger(LoggerVerbosity.Minimal, stringWriter.Write, color => { }, () => { });
				result.Success = SyncBuild(project, logger);
				if (result.Success)
					result.PathToExe = Path.Combine(project.DirectoryPath,
													project.GetPropertyValue("OutputPath"),
													project.GetPropertyValue("AssemblyName") + ".exe");
				else
					result.ErrorMessage = stringWriter.ToString();
				return result;
			}
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:27,代码来源:MsBuildRunner.cs

示例4: CreateBuildProject

        void CreateBuildProject()
        {
            string projectPath = Path.Combine(buildDirectory, "content.contentproj");
            string outputPath = Path.Combine(buildDirectory, "bin");

            // Create the build project.
            projectRootElement = ProjectRootElement.Create(projectPath);

            // Include the standard targets file that defines how to build XNA Framework content.
            projectRootElement.AddImport(Application.StartupPath + "\\Exporters\\FBX\\XNA\\XNA Game Studio\\" +
                                         "v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");

            buildProject = new Project(projectRootElement);

            buildProject.SetProperty("XnaPlatform", "Windows");
            buildProject.SetProperty("XnaProfile", "Reach");
            buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
            buildProject.SetProperty("Configuration", "Release");
            buildProject.SetProperty("OutputPath", outputPath);
            buildProject.SetProperty("ContentRootDirectory", ".");
            buildProject.SetProperty("ReferencePath", Application.StartupPath);

            // Register any custom importers or processors.
            foreach (string pipelineAssembly in pipelineAssemblies)
            {
                buildProject.AddItem("Reference", pipelineAssembly);
            }

            // Hook up our custom error logger.
            errorLogger = new ErrorLogger();

            buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection)
                                  {Loggers = new ILogger[] {errorLogger}};
        }
开发者ID:nicolasmassouh,项目名称:Babylon.js,代码行数:34,代码来源:ContentBuilder.cs

示例5: ProjectGetter

        public void ProjectGetter()
        {
            Project project = new Project();
            ProjectItem item = project.AddItem("i", "i1")[0];
            ProjectMetadata metadatum = item.SetMetadataValue("m", "m1");

            Assert.AreEqual(true, Object.ReferenceEquals(project, metadatum.Project));
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:8,代码来源:ProjectMetadata_Tests.cs

示例6: IncludeFileInCurrentProject

		public static void IncludeFileInCurrentProject(string approved)
		{
			var p = new Project(GetCurrentProjectFile(approved));
			if (!p.Items.Any(i => approved.EndsWith(i.UnevaluatedInclude)))
			{
				p.AddItem("Content", approved);
				p.Save();
			}
		}
开发者ID:GeertvanHorrik,项目名称:ApprovalTests.Net,代码行数:9,代码来源:VisualStudioProjectFileAdder.cs

示例7: LinkToFile

        public void LinkToFile(Project project, BuildAction buildAction, string includeValue, string projectTargetPath)
        {
            if(projectTargetPath.StartsWith("\\"))
                throw new Exception("project target path cannot begin with a backslash");

            var matchingProjectItemByTargetPath = (from t in project.Items
                                                   where
                                                       t.HasMetadata("Link") &&
                                                       t.GetMetadataValue("Link") == projectTargetPath
                                                   select t).SingleOrDefault();

            if (matchingProjectItemByTargetPath != null) 
                project.RemoveItem(matchingProjectItemByTargetPath);

            var buildActionName = Enum.GetName(typeof(BuildAction), buildAction);

            project.AddItem(buildActionName, includeValue,
                            new[] {new KeyValuePair<string, string>("Link", projectTargetPath)});
        }
开发者ID:GeniusCode,项目名称:GeniusCode.Toolkit.ProjectAutoFileLinker,代码行数:19,代码来源:ProjectFileLinker.cs

示例8: AddItem_EscapedItemInclude

        public void AddItem_EscapedItemInclude()
        {
            Project project = new Project();

            project.AddItem("i", "i%281%29");

            string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup>
    <i Include=""i%281%29"" />
  </ItemGroup>
</Project>");

            Helpers.VerifyAssertProjectContent(expected, project.Xml);

            List<ProjectItem> items = Helpers.MakeList(project.Items);
            Assert.Equal(1, items.Count);
            Assert.Equal("i", items[0].ItemType);
            Assert.Equal("i(1)", items[0].EvaluatedInclude);
            Assert.Equal("i(1)", Helpers.GetFirst(project.GetItems("i")).EvaluatedInclude);
            Assert.Equal("i(1)", Helpers.MakeList(project.CreateProjectInstance().GetItems("i"))[0].EvaluatedInclude);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:22,代码来源:DefinitionEditing_Tests.cs

示例9: SpecialCharactersInMetadataValueEvaluation

        public void SpecialCharactersInMetadataValueEvaluation()
        {
            Project project = new Project();
            ProjectItem item = project.AddItem("None", "MetadataTests", new Dictionary<string, string> {
                {"EscapedSemicolon", "%3B"}, //Microsoft.Build.Evaluation.ProjectCollection.Escape(";")
                {"EscapedDollarSign", "%24"}, //Microsoft.Build.Evaluation.ProjectCollection.Escape("$")
            }).Single();

            EscapingInProjectsHelper.SpecialCharactersInMetadataValueTests(item);
            project.ReevaluateIfNecessary();
            EscapingInProjectsHelper.SpecialCharactersInMetadataValueTests(item);
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:12,代码来源:EscapingInProjects_Tests.cs

示例10: SettingItemIncludeDirties

        public void SettingItemIncludeDirties()
        {
            Project project = new Project();
            ProjectItem item = project.AddItem("i", "i1")[0];
            project.ReevaluateIfNecessary();

            item.Xml.Include = "i2";
            project.ReevaluateIfNecessary();

            Assert.Equal("i2", Helpers.GetFirst(project.Items).EvaluatedInclude);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:11,代码来源:ProjectItemElement_Tests.cs

示例11: ItemsByEvaluatedIncludeDirectAdd

        public void ItemsByEvaluatedIncludeDirectAdd()
        {
            Project project = new Project();
            project.AddItem("i", "i1");

            List<ProjectItem> items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i1"));
            Assert.Equal(1, items.Count);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:8,代码来源:Project_Tests.cs

示例12: SpecialCharactersInMetadataValueEvaluation

        public void SpecialCharactersInMetadataValueEvaluation()
        {
            Microsoft.Build.Evaluation.Project project = new Microsoft.Build.Evaluation.Project();
            var metadata = new Dictionary<string, string>
            {
                { "EscapedSemicolon", "%3B" }, // Microsoft.Build.Internal.Utilities.Escape(";")
                { "EscapedDollarSign", "%24" }, // Microsoft.Build.Internal.Utilities.Escape("$")
            };
            Microsoft.Build.Evaluation.ProjectItem item = project.AddItem(
                "None",
                "MetadataTests",
                metadata).Single();

            SpecialCharactersInMetadataValueTests(item);
            project.ReevaluateIfNecessary();
            SpecialCharactersInMetadataValueTests(item);
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:17,代码来源:ProjectMetadata_Tests.cs

示例13: SetValueWithPropertyExpression

        public void SetValueWithPropertyExpression()
        {
            Project project = new Project();
            project.SetProperty("p", "p0");
            ProjectItem item = project.AddItem("i", "i1")[0];
            ProjectMetadata metadatum = item.SetMetadataValue("m", "m1");
            project.ReevaluateIfNecessary();

            metadatum.UnevaluatedValue = "$(p)";

            Assert.AreEqual("$(p)", metadatum.UnevaluatedValue);
            Assert.AreEqual("p0", metadatum.EvaluatedValue);
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:13,代码来源:ProjectMetadata_Tests.cs

示例14: AddItem_MatchesWildcardWithCondition

        public void AddItem_MatchesWildcardWithCondition()
        {
            Project project = new Project();
            ProjectItemElement itemElement = project.Xml.AddItem("i", "*.xxx");
            itemElement.Condition = "true";
            project.ReevaluateIfNecessary();

            project.AddItem("i", "i1.xxx");

            string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup>
    <i Include=""*.xxx"" Condition=""true"" />
    <i Include=""i1.xxx"" />
  </ItemGroup>
</Project>");

            Helpers.VerifyAssertProjectContent(expected, project);
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:19,代码来源:DefinitionEditing_Tests.cs

示例15: AddItem_ContainingSemicolonExistingWildcard

        public void AddItem_ContainingSemicolonExistingWildcard()
        {
            Project project = new Project();
            project.Xml.AddItem("i", "*.xxx");
            project.ReevaluateIfNecessary();

            project.AddItem("i", "i1.xxx;i2.xxx");

            string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup>
    <i Include=""*.xxx"" />
    <i Include=""i1.xxx;i2.xxx"" />
  </ItemGroup>
</Project>");

            Helpers.VerifyAssertProjectContent(expected, project);
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:18,代码来源:DefinitionEditing_Tests.cs


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