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


C# Project.SetGlobalProperty方法代码示例

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


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

示例1: when_getting_targets_then_does_not_include_initial_targets

        public void when_getting_targets_then_does_not_include_initial_targets()
        {
            var eval = new Project("IntrospectTests.targets");
            eval.SetGlobalProperty("UseCompiledTasks", "true");
            var project = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild(eval);
            IDictionary<string, TargetResult> outputs;

            var result = project.Build(new string[0], new[] { logger }, out outputs);

            Assert.True(result);
            Assert.True(outputs.ContainsKey("Build"));
            Assert.True(!outputs["Build"].Items.Select(t => t.ItemSpec).Contains("Startup"));
        }
开发者ID:kzu,项目名称:MSBuilder,代码行数:13,代码来源:IntrospectTests.cs

示例2: when_introspecting_then_retrieves_current_target

        public void when_introspecting_then_retrieves_current_target()
        {
            var eval = new Project("IntrospectTests.targets");
            eval.SetGlobalProperty("UseCompiledTasks", "true");
            var project = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild(eval);
            IDictionary<string, TargetResult> outputs;

            var result = project.Build(new [] { "IntrospectTargets" }, new[] { logger }, out outputs);

            Assert.True(result);
            Assert.True(outputs.ContainsKey("IntrospectTargets"));
            Assert.Equal(1, outputs["IntrospectTargets"].Items.Length);

            var target = outputs["IntrospectTargets"].Items[0];

            Assert.Equal("IntrospectTargets", target.ItemSpec);
        }
开发者ID:kzu,项目名称:MSBuilder,代码行数:17,代码来源:IntrospectTests.cs

示例3: when_introspecting_then_retrieves_dynamic_value

        public void when_introspecting_then_retrieves_dynamic_value()
        {
            var eval = new Project("IntrospectTests.targets");
            eval.SetGlobalProperty("UseCompiledTasks", "true");
            var project = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild(eval);
            IDictionary<string, TargetResult> outputs;

            project.SetProperty("PropertyName", "MSBuildRuntimeVersion");
            var result = project.Build(new [] { "GetDynamicValue" }, new[] { logger }, out outputs);

            Assert.True(result);
            Assert.True(outputs.ContainsKey("GetDynamicValue"));
            Assert.Equal(1, outputs["GetDynamicValue"].Items.Length);

            var target = outputs["GetDynamicValue"].Items[0];
            var expected = project.GetPropertyValue("MSBuildRuntimeVersion");

            Assert.Equal(expected, target.ItemSpec);
        }
开发者ID:kzu,项目名称:MSBuilder,代码行数:19,代码来源:IntrospectTests.cs

示例4: ChangeGlobalPropertiesInitiallyFromProjectCollection

        public void ChangeGlobalPropertiesInitiallyFromProjectCollection()
        {
            Dictionary<string, string> initial = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            initial.Add("p0", "v0");
            initial.Add("p1", "v1");
            ProjectCollection collection = new ProjectCollection(initial, null, ToolsetDefinitionLocations.ConfigurationFile);
            Project project = new Project(collection);
            ProjectPropertyElement propertyElement = project.Xml.AddProperty("pp", "vv");
            propertyElement.Condition = "'$(p0)'=='v0' and '$(p1)'=='v1b'";
            project.ReevaluateIfNecessary();
            Assert.Equal(String.Empty, project.GetPropertyValue("pp"));

            project.SetGlobalProperty("p1", "v1b");
            Assert.Equal(true, project.IsDirty);
            project.ReevaluateIfNecessary();
            Assert.Equal("vv", project.GetPropertyValue("pp"));
            Assert.Equal("v0", collection.GlobalProperties["p0"]);
            Assert.Equal("v1", collection.GlobalProperties["p1"]);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:19,代码来源:Project_Tests.cs

示例5: ChangeGlobalPropertyAfterReevaluation2

 public void ChangeGlobalPropertyAfterReevaluation2()
 {
     Assert.Throws<InvalidOperationException>(() =>
     {
         Project project = new Project();
         project.SetGlobalProperty("p", "v1");
         project.ReevaluateIfNecessary();
         project.SetProperty("p", "v2");
     }
    );
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:11,代码来源:Project_Tests.cs

示例6: ChangeGlobalPropertiesPreexisting

        public void ChangeGlobalPropertiesPreexisting()
        {
            Dictionary<string, string> initial = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            initial.Add("p0", "v0");
            initial.Add("p1", "v1");
            Project project = new Project(ProjectRootElement.Create(), initial, null);
            ProjectPropertyElement propertyElement = project.Xml.AddProperty("pp", "vv");
            propertyElement.Condition = "'$(p0)'=='v0' and '$(p1)'=='v1b'";
            project.ReevaluateIfNecessary();
            Assert.Equal(String.Empty, project.GetPropertyValue("pp"));

            project.SetGlobalProperty("p1", "v1b");
            Assert.Equal(true, project.IsDirty);
            project.ReevaluateIfNecessary();
            Assert.Equal("vv", project.GetPropertyValue("pp"));
            Assert.Equal("v0", project.GlobalProperties["p0"]);
            Assert.Equal("v1b", project.GlobalProperties["p1"]);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:18,代码来源:Project_Tests.cs

示例7: ChangeGlobalPropertyAfterReevaluation

        public void ChangeGlobalPropertyAfterReevaluation()
        {
            Project project = new Project();
            project.SetGlobalProperty("p", "v1");
            project.ReevaluateIfNecessary();
            project.SetGlobalProperty("p", "v2");

            Assert.Equal("v2", project.GetPropertyValue("p"));
            Assert.Equal(true, project.GetProperty("p").IsGlobalProperty);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:10,代码来源:Project_Tests.cs

示例8: SkipEvaluation

        public void SkipEvaluation()
        {
            Project project = new Project();
            project.SetGlobalProperty("p", "v1");
            project.ReevaluateIfNecessary();
            Assert.Equal("v1", project.GetPropertyValue("p"));

            project.SkipEvaluation = true;
            ProjectPropertyElement propertyElement = project.Xml.AddProperty("p1", "v0");
            propertyElement.Condition = "'$(g)'=='v1'";
            project.SetGlobalProperty("g", "v1");
            project.ReevaluateIfNecessary();
            Assert.Equal(String.Empty, project.GetPropertyValue("p1"));

            project.SkipEvaluation = false;
            project.SetGlobalProperty("g", "v1");
            project.ReevaluateIfNecessary();
            Assert.Equal("v0", project.GetPropertyValue("p1"));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:19,代码来源:Project_Tests.cs

示例9: defVariables

        /// <summary>
        /// Define variables for project context from all user-variables
        /// </summary>
        /// <param name="project"></param>
        protected void defVariables(Project project)
        {
            foreach(TUserVariable uvar in uvariable.Variables)
            {
                if(uvar.status != TUserVariable.StatusType.Started) {
                    project.SetGlobalProperty(uvar.ident, getUVariableValue(uvar.ident));
                    continue;
                }

                if(uvar.prev != null && ((TUserVariable)uvar.prev).unevaluated != null)
                {
                    TUserVariable prev = (TUserVariable)uvar.prev;
                    project.SetGlobalProperty(uvar.ident, (prev.evaluated == null)? prev.unevaluated : prev.evaluated);
                }
            }
        }
开发者ID:modulexcite,项目名称:vsCommandEvent,代码行数:20,代码来源:Parser.cs

示例10: ChangeGlobalProperties

        public void ChangeGlobalProperties()
        {
            Project project = new Project();
            ProjectPropertyElement propertyElement = project.Xml.AddProperty("p", "v0");
            propertyElement.Condition = "'$(g)'=='v1'";
            project.ReevaluateIfNecessary();
            Assert.Equal(String.Empty, project.GetPropertyValue("p"));

            Assert.Equal(true, project.SetGlobalProperty("g", "v1"));
            Assert.Equal(true, project.IsDirty);
            project.ReevaluateIfNecessary();
            Assert.Equal("v0", project.GetPropertyValue("p"));
            Assert.Equal("v1", project.GlobalProperties["g"]);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:14,代码来源:Project_Tests.cs

示例11: ProjectXmlChangedEvent

        public void ProjectXmlChangedEvent()
        {
            ProjectCollection collection = new ProjectCollection();
            ProjectRootElement pre = null;
            bool dirtyRaised = false;
            collection.ProjectXmlChanged +=
                (sender, e) =>
                {
                    Assert.Same(collection, sender);
                    Assert.Same(pre, e.ProjectXml);
                    this.TestOutput.WriteLine(e.Reason ?? String.Empty);
                    dirtyRaised = true;
                };
            Assert.False(dirtyRaised);

            // Ensure that the event is raised even when DisableMarkDirty is set.
            collection.DisableMarkDirty = true;

            // Create a new PRE but don't change the template.
            dirtyRaised = false;
            pre = ProjectRootElement.Create(collection);
            Assert.False(dirtyRaised);

            // Change PRE prior to setting a filename and thus associating the PRE with the ProjectCollection.
            dirtyRaised = false;
            pre.AppendChild(pre.CreatePropertyGroupElement());
            Assert.False(dirtyRaised);

            // Associate with the ProjectCollection
            dirtyRaised = false;
            pre.FullPath = FileUtilities.GetTemporaryFile();
            Assert.True(dirtyRaised);

            // Now try dirtying again and see that the event is raised this time.
            dirtyRaised = false;
            pre.AppendChild(pre.CreatePropertyGroupElement());
            Assert.True(dirtyRaised);

            // Make sure that project collection global properties don't raise this event.
            dirtyRaised = false;
            collection.SetGlobalProperty("a", "b");
            Assert.False(dirtyRaised);

            // Change GlobalProperties on a project to see that that doesn't propagate as an XML change.
            dirtyRaised = false;
            var project = new Project(pre);
            project.SetGlobalProperty("q", "s");
            Assert.False(dirtyRaised);

            // Change XML via the Project to verify the event is raised.
            dirtyRaised = false;
            project.SetProperty("z", "y");
            Assert.True(dirtyRaised);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:54,代码来源:ProjectCollection_Tests.cs

示例12: setGlobalProperty

        /// <param name="project">Uses GlobalProjectCollection if null.</param>
        /// <param name="name"></param>
        /// <param name="val"></param>
        /// <returns>Returns true if the value changes, otherwise returns false.</returns>
        protected virtual bool setGlobalProperty(Project project, string name, string val)
        {
            if(project == null) {
                ProjectCollection.GlobalProjectCollection.SetGlobalProperty(name, val);
                return true;
            }

            return project.SetGlobalProperty(name, val);
        }
开发者ID:3F,项目名称:vsCommandEvent,代码行数:13,代码来源:Parser.cs

示例13: ProjectChangedEvent

        public void ProjectChangedEvent()
        {
            ProjectCollection collection = new ProjectCollection();
            ProjectRootElement pre = null;
            Project project = null;
            bool dirtyRaised = false;
            collection.ProjectChanged +=
                (sender, e) =>
                {
                    Assert.Same(collection, sender);
                    Assert.Same(project, e.Project);
                    dirtyRaised = true;
                };
            Assert.False(dirtyRaised);

            pre = ProjectRootElement.Create(collection);
            project = new Project(pre, null, null, collection);

            // all these should still pass with disableMarkDirty set
            collection.DisableMarkDirty = true;
            project.DisableMarkDirty = true;

            dirtyRaised = false;
            pre.AppendChild(pre.CreatePropertyGroupElement());
            Assert.False(dirtyRaised); // "Dirtying the XML directly should not result in a ProjectChanged event."

            // No events should be raised before we associate a filename with the PRE
            dirtyRaised = false;
            project.SetGlobalProperty("someGlobal", "someValue");
            Assert.False(dirtyRaised);

            dirtyRaised = false;
            project.SetProperty("someProp", "someValue");
            Assert.False(dirtyRaised);

            pre.FullPath = FileUtilities.GetTemporaryFile();
            dirtyRaised = false;
            project.SetGlobalProperty("someGlobal", "someValue2");
            Assert.True(dirtyRaised);

            dirtyRaised = false;
            project.RemoveGlobalProperty("someGlobal");
            Assert.True(dirtyRaised);

            dirtyRaised = false;
            collection.SetGlobalProperty("somePCglobal", "someValue");
            Assert.True(dirtyRaised);

            dirtyRaised = false;
            project.SetProperty("someProp", "someValue2");
            Assert.True(dirtyRaised);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:52,代码来源:ProjectCollection_Tests.cs

示例14: ChangeGlobalPropertiesSameValue

        public void ChangeGlobalPropertiesSameValue()
        {
            Project project = new Project();
            project.SetGlobalProperty("g", "v1");
            Assert.Equal(true, project.IsDirty);
            project.ReevaluateIfNecessary();

            Assert.Equal(false, project.SetGlobalProperty("g", "v1"));
            Assert.Equal(false, project.IsDirty);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:10,代码来源:Project_Tests.cs

示例15: when_introspecting_then_retrieves_properties

        public void when_introspecting_then_retrieves_properties()
        {
            var eval = new Project("IntrospectTests.targets");
            eval.SetGlobalProperty("UseCompiledTasks", "true");
            var project = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild(eval);
            IDictionary<string, TargetResult> outputs;

            var result = project.Build(new [] { "IntrospectProperties" }, new[] { logger }, out outputs);

            Assert.True(result);
            Assert.True(outputs.ContainsKey("IntrospectProperties"));
            Assert.Equal(1, outputs["IntrospectProperties"].Items.Length);

            var target = outputs["IntrospectProperties"].Items[0];
            var metadata = new HashSet<string>(target.MetadataNames.OfType<string>());

            Assert.True(metadata.Contains("MSBuildBinPath"));
            Assert.Equal("Bar", target.GetMetadata("Foo"));
        }
开发者ID:kzu,项目名称:MSBuilder,代码行数:19,代码来源:IntrospectTests.cs


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