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


C# Execution.ProjectInstance类代码示例

本文整理汇总了C#中Microsoft.Build.Execution.ProjectInstance的典型用法代码示例。如果您正苦于以下问题:C# ProjectInstance类的具体用法?C# ProjectInstance怎么用?C# ProjectInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TestResolveEnvironment

        public void TestResolveEnvironment() {
            var proj1 = new ProjectInstance(TestData.GetPath(@"TestData\Targets\Environments1.pyproj"));
            Assert.IsTrue(proj1.Build("TestResolveEnvironment", new ILogger[] { new ConsoleLogger(LoggerVerbosity.Detailed) }));

            var proj2 = new ProjectInstance(TestData.GetPath(@"TestData\Targets\Environments2.pyproj"));
            Assert.IsTrue(proj2.Build("TestResolveEnvironment", new ILogger[] { new ConsoleLogger(LoggerVerbosity.Detailed) }));
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:BuildTasksTests.cs

示例2: ItemsAndProperties

		public void ItemsAndProperties ()
		{
            string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <ItemGroup>
    <X Condition='false' Include='bar.txt' />
    <X Include='foo.txt'>
      <M>m</M>
      <N>=</N>
    </X>
  </ItemGroup>
  <PropertyGroup>
    <P Condition='false'>void</P>
    <P Condition='true'>valid</P>
  </PropertyGroup>
</Project>";
            var xml = XmlReader.Create (new StringReader(project_xml));
            var root = ProjectRootElement.Create (xml);
            var proj = new ProjectInstance (root);
            var item = proj.Items.First ();
			Assert.AreEqual ("foo.txt", item.EvaluatedInclude, "#1");
			var prop = proj.Properties.First (p => p.Name=="P");
			Assert.AreEqual ("valid", prop.EvaluatedValue, "#2");
			Assert.IsNotNull (proj.GetProperty ("MSBuildProjectDirectory"), "#3");
			Assert.AreEqual ("4.0", proj.ToolsVersion, "#4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:25,代码来源:ProjectInstanceTest.cs

示例3: BuildAsync

    internal static async Task<BuildResult> BuildAsync(this BuildManager buildManager, ITestOutputHelper logger, ProjectCollection projectCollection, ProjectRootElement project, string target, IDictionary<string, string> globalProperties = null, LoggerVerbosity logVerbosity = LoggerVerbosity.Detailed, ILogger[] additionalLoggers = null)
    {
        Requires.NotNull(buildManager, nameof(buildManager));
        Requires.NotNull(projectCollection, nameof(projectCollection));
        Requires.NotNull(project, nameof(project));

        globalProperties = globalProperties ?? new Dictionary<string, string>();
        var projectInstance = new ProjectInstance(project, globalProperties, null, projectCollection);
        var brd = new BuildRequestData(projectInstance, new[] { target }, null, BuildRequestDataFlags.ProvideProjectStateAfterBuild);

        var parameters = new BuildParameters(projectCollection);

        var loggers = new List<ILogger>();
        loggers.Add(new ConsoleLogger(logVerbosity, s => logger.WriteLine(s.TrimEnd('\r', '\n')), null, null));
        loggers.AddRange(additionalLoggers);
        parameters.Loggers = loggers.ToArray();

        buildManager.BeginBuild(parameters);

        var result = await buildManager.BuildAsync(brd);

        buildManager.EndBuild();

        return result;
    }
开发者ID:azeno,项目名称:Nerdbank.GitVersioning,代码行数:25,代码来源:MSBuildExtensions.cs

示例4: OutputPropertyExists

		public void OutputPropertyExists ()
		{
			string project_xml = @"
<Project DefaultTargets='Build' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
	<PropertyGroup>
		<C>False</C>
	</PropertyGroup>
	<Target Name='Build' DependsOnTargets='ResolveReferences' />
	<Target Name='Build2' DependsOnTargets='Bar' />
	<Target Name='ResolveReferences' DependsOnTargets='Foo;Bar' />
	<Target Name='Foo'>
		<CreateProperty Value='True'>
			<Output TaskParameter='Value' PropertyName='C' />
		</CreateProperty>
	</Target>
	<Target Name='Bar' Condition='!($(C))' DependsOnTargets='ResolveReferences'>
	</Target>
</Project>";
			var xml = XmlReader.Create (new StringReader(project_xml));
			var root = ProjectRootElement.Create (xml);
			var proj = new ProjectInstance (root);
			Assert.AreEqual (5, proj.Targets.Count, "#1");
			var foo = proj.Targets ["Foo"];
			Assert.IsNotNull (foo, "#2");
			Assert.AreEqual (1, foo.Tasks.Count, "#3");
			var cp = foo.Tasks.First ();
			Assert.AreEqual (1, cp.Outputs.Count, "#4");
			var po = cp.Outputs.First () as ProjectTaskOutputPropertyInstance;
			Assert.IsNotNull (po, "#5");
			Assert.AreEqual ("C", po.PropertyName, "#5");
			proj.Build ("Build", null);
			Assert.AreEqual (string.Empty, foo.Outputs, "#6");
			Assert.AreEqual ("True", proj.GetPropertyValue ("C"), "#7");
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:34,代码来源:ProjectTaskInstanceTest.cs

示例5: ExecuteAsync

        /// <summary>
        /// Builds a project.
        /// </summary>
        /// <param name="projectInstance">The project to build.</param>
        /// <param name="targetsToBuild">The targets to build. If not specified, the project's default target will be invoked.</param>
        /// <returns>A task whose result is the result of the build.</returns>
        public static async Task<BuildResultAndLogs> ExecuteAsync(ProjectInstance projectInstance, params string[] targetsToBuild)
        {
            targetsToBuild = (targetsToBuild == null || targetsToBuild.Length == 0) ? projectInstance.DefaultTargets.ToArray() : targetsToBuild;

            var logger = new EventLogger();
            var logLines = new List<string>();
            var parameters = new BuildParameters
            {
                Loggers = new List<ILogger>
                {
                    new ConsoleLogger(LoggerVerbosity.Detailed, logLines.Add, null, null),
                    logger,
                },
            };

            BuildResult result;
            using (var buildManager = new BuildManager())
            {
                buildManager.BeginBuild(parameters);
                try
                {
                    var brdFlags = BuildRequestDataFlags.ProvideProjectStateAfterBuild;
                    var requestData = new BuildRequestData(projectInstance, targetsToBuild, null, brdFlags);
                    var submission = buildManager.PendBuildRequest(requestData);
                    result = await submission.ExecuteAsync();
                }
                finally
                {
                    buildManager.EndBuild();
                }
            }

            return new BuildResultAndLogs(result, logger.LogEvents, logLines);
        }
开发者ID:NN---,项目名称:nuproj,代码行数:40,代码来源:MSBuild.cs

示例6: ExplicitToolsVersion

		public void ExplicitToolsVersion ()
		{
            string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' />";
            var xml = XmlReader.Create (new StringReader(project_xml));
            var root = ProjectRootElement.Create (xml);
			var proj = new ProjectInstance (root, null, "4.0", new ProjectCollection ());
			Assert.AreEqual ("4.0", proj.ToolsVersion, "#1");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:ProjectInstanceTest.cs

示例7: AssertPropertyDoesNotExist

        public static void AssertPropertyDoesNotExist(ProjectInstance projectInstance, string propertyName)
        {
            ProjectPropertyInstance propertyInstance = projectInstance.GetProperty(propertyName);

            string value = propertyInstance == null ? null : propertyInstance.EvaluatedValue;

            Assert.IsNull(propertyInstance, "Not expecting the property to exist. Property: {0}, Value: {1}", propertyName, value);
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:8,代码来源:BuildAssertions.cs

示例8: BuildRequestData

		public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices,
				BuildRequestDataFlags flags)
		{
			ProjectInstance = projectInstance;
			TargetNames = targetsToBuild;
			HostServices = hostServices;
			Flags = flags;
		}
开发者ID:GirlD,项目名称:mono,代码行数:8,代码来源:BuildRequestData.cs

示例9: ProjectItemInstance

		internal ProjectItemInstance (ProjectInstance project, string itemType, IEnumerable<KeyValuePair<string,string>> metadata, string evaluatedInclude)
		{
			this.project = project;
			this.evaluated_include = evaluatedInclude;
			this.item_type = itemType;
			this.metadata = new List<ProjectMetadataInstance> ();
			SetMetadata (metadata);
		}
开发者ID:GirlD,项目名称:mono,代码行数:8,代码来源:ProjectItemInstance.cs

示例10: DefaultTargetsEmpty

		public void DefaultTargetsEmpty ()
		{
            string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
</Project>";
            var xml = XmlReader.Create (new StringReader (project_xml));
            var root = ProjectRootElement.Create (xml);
            var proj = new ProjectInstance (root);
			Assert.AreEqual (new string [0], proj.DefaultTargets, "#1");
		}
开发者ID:GirlD,项目名称:mono,代码行数:9,代码来源:ProjectTargetInstanceTest.cs

示例11: GetConfigurationProperty

 public virtual string GetConfigurationProperty(string propertyName, bool resetCache)
 {
     if (snapshot == null)
         snapshot = proj.CreateProjectInstance(config, platform);
     ProjectPropertyInstance property = snapshot.GetProperty(propertyName);
     if (property == null)
         return null;
     return property.EvaluatedValue;
 }
开发者ID:whuthj,项目名称:VisualRust,代码行数:9,代码来源:MsBuildConfiguration.cs

示例12: DefaultTargetsFromAttribute

		public void DefaultTargetsFromAttribute ()
		{
            string project_xml = @"<Project DefaultTargets='Foo Bar Baz;Foo' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
</Project>";
            var xml = XmlReader.Create (new StringReader (project_xml));
            var root = ProjectRootElement.Create (xml);
            var proj = new ProjectInstance (root);
			string [] expected = {"Foo Bar Baz", "Foo"};
			Assert.AreEqual (expected, proj.DefaultTargets, "#1");
		}
开发者ID:GirlD,项目名称:mono,代码行数:10,代码来源:ProjectTargetInstanceTest.cs

示例13: ToStringOverride

		public void ToStringOverride ()
		{
			var xml = XmlReader.Create (new StringReader (project_xml));
			string path = Path.GetFullPath ("foo.xml");
			var root = ProjectRootElement.Create (xml);
			var proj = new ProjectInstance (root);
			var item = proj.Items.First ();
			Assert.AreEqual ("M=m", item.Metadata.First ().ToString (), "#1");
			Assert.AreEqual ("N==", item.Metadata.Last ().ToString (), "#2"); // haha
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:10,代码来源:ProjectMetadataInstanceTest.cs

示例14: GetProjectReferencesCore

            private IEnumerable<ProjectFileReference> GetProjectReferencesCore(ProjectInstance executedProject)
            {
                foreach (var projectReference in GetProjectReferenceItems(executedProject))
                {
                    var filePath = projectReference.EvaluatedInclude;
                    var aliases = GetAliases(projectReference);

                    yield return new ProjectFileReference(filePath, aliases);
                }
            }
开发者ID:JinGuoGe,项目名称:roslyn,代码行数:10,代码来源:CSharpProjectFileLoader.CSharpProjectFile.cs

示例15: BuildRequestData

		public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices,
				BuildRequestDataFlags flags)
		{
			if (targetsToBuild == null)
				throw new ArgumentNullException ("targetsToBuild");
			ProjectInstance = projectInstance;
			TargetNames = targetsToBuild;
			HostServices = hostServices;
			Flags = flags;
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:10,代码来源:BuildRequestData.cs


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