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


C# Project.ReevaluateIfNecessary方法代码示例

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


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

示例1: RemoveImportStatement

        /// <summary>
        /// Removes the Import element from the project file.
        /// </summary>
        /// <param name="msBuildProject">The project file.</param>
        /// <param name="targetsPath">The path to the imported file.</param>
        internal static void RemoveImportStatement(MicrosoftBuildEvaluationProject msBuildProject, string targetsPath)
        {
            if (msBuildProject.Xml.Imports != null)
            {
                // search for this import statement and remove it
                var importElement = msBuildProject.Xml.Imports.FirstOrDefault(
                    import => targetsPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase));

                if (importElement != null)
                {
                    importElement.Parent.RemoveChild(importElement);
                    RemoveEnsureImportedTarget(msBuildProject, targetsPath);
                    msBuildProject.ReevaluateIfNecessary();
                }
            }
        }
开发者ID:mauroa,项目名称:NuGet.VisualStudioExtension,代码行数:21,代码来源:MicrosoftBuildEvaluationProjectUtility.cs

示例2: AddImportStatement

        internal static void AddImportStatement(MicrosoftBuildEvaluationProject msBuildProject, string targetsPath, ImportLocation location)
        {
            if (msBuildProject.Xml.Imports == null ||
                msBuildProject.Xml.Imports.All(import => !targetsPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase)))
            {
                ProjectImportElement pie = msBuildProject.Xml.AddImport(targetsPath);
                pie.Condition = "Exists('" + targetsPath + "')";
                if (location == ImportLocation.Top)
                {
                    // There's no public constructor to create a ProjectImportElement directly.
                    // So we have to cheat by adding Import at the end, then remove it and insert at the beginning
                    pie.Parent.RemoveChild(pie);
                    msBuildProject.Xml.InsertBeforeChild(pie, msBuildProject.Xml.FirstChild);
                }

                AddEnsureImportedTarget(msBuildProject, targetsPath);
                msBuildProject.ReevaluateIfNecessary();
            }
        }
开发者ID:mauroa,项目名称:NuGet.VisualStudioExtension,代码行数:19,代码来源:MicrosoftBuildEvaluationProjectUtility.cs

示例3: SandcastleProject

        /// <summary>
        /// This is used to create a Sandcastle Builder project from an existing MSBuild project instance
        /// </summary>
        /// <param name="existingProject">The existing project instance</param>
        /// <remarks>It is assumed that the project has been loaded, the property values are current, and that
        /// the configuration and platform have been set in the MSBuild project global properties in order to
        /// get the correct final values.</remarks>
        public SandcastleProject(Project existingProject) : this()
        {
            // Do not remove the project from the MSBuild project collection when this is disposed of since we
            // didn't create it.
            removeProjectWhenDisposed = false;

            msBuildProject = existingProject;
            msBuildProject.ReevaluateIfNecessary();

            this.UsingFinalValues = true;
            this.LoadProperties();
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:19,代码来源:SandcastleProject.cs

示例4: SettingItemExcludeDirties

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

            item.Xml.Exclude = "i1";
            project.ReevaluateIfNecessary();

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

示例5: RemoveGlobalProperties

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

            bool existed = project.RemoveGlobalProperty("g");
            Assert.Equal(true, existed);
            Assert.Equal(true, project.IsDirty);
            project.ReevaluateIfNecessary();
            Assert.Equal("v0", project.GetPropertyValue("p"));
            Assert.Equal(false, project.GlobalProperties.ContainsKey("g"));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:16,代码来源:Project_Tests.cs

示例6: 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

示例7: ChangeEnvironmentProperty

        public void ChangeEnvironmentProperty()
        {
            Project project = new Project();
            project.SetProperty("computername", "v1");

            Assert.Equal("v1", project.GetPropertyValue("computername"));
            Assert.Equal(true, project.IsDirty);

            project.ReevaluateIfNecessary();

            Assert.Equal("v1", project.GetPropertyValue("computername"));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:12,代码来源: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: ImportedXmlModified

        public void ImportedXmlModified()
        {
            string path = null;

            try
            {
                path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
                ProjectRootElement import = ProjectRootElement.Create(path);
                import.Save();

                Project project = new Project();
                int last = project.EvaluationCounter;

                project.Xml.AddImport(path);
                project.ReevaluateIfNecessary();
                Assert.NotEqual(project.EvaluationCounter, last);
                last = project.EvaluationCounter;

                project.ReevaluateIfNecessary();
                Assert.Equal(project.EvaluationCounter, last);

                import.AddProperty("p", "v");
                Assert.Equal(true, project.IsDirty);
                project.ReevaluateIfNecessary();
                Assert.NotEqual(project.EvaluationCounter, last);
                last = project.EvaluationCounter;
                Assert.Equal("v", project.GetPropertyValue("p"));

                project.ReevaluateIfNecessary();
                Assert.Equal(project.EvaluationCounter, last);
            }
            finally
            {
                File.Delete(path);
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:36,代码来源:Project_Tests.cs

示例10: ReevaluationCounter

        public void ReevaluationCounter()
        {
            Project project = new Project();
            int last = project.EvaluationCounter;

            project.ReevaluateIfNecessary();
            Assert.Equal(project.EvaluationCounter, last);
            last = project.EvaluationCounter;

            project.SetProperty("p", "v");
            project.ReevaluateIfNecessary();
            Assert.NotEqual(project.EvaluationCounter, last);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:13,代码来源:Project_Tests.cs

示例11: MSBuildToolsVersionProperty

        public void MSBuildToolsVersionProperty()
        {
            if (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version20) == null)
            {
                // "Requires 2.0 to be installed"
                return;
            }

            Project project = new Project();
            project.Xml.ToolsVersion = "2.0";
            project.ReevaluateIfNecessary();

            // ... and after all that, we end up defaulting to the current ToolsVersion instead.  There's a way 
            // to turn this behavior (new in Dev12) off, but it requires setting an environment variable and 
            // clearing some internal state to make sure that the update environment variable is picked up, so 
            // there's not a good way of doing it from these deliberately public OM only tests. 
            Assert.Equal(ObjectModelHelpers.MSBuildDefaultToolsVersion, project.GetPropertyValue("msbuildtoolsversion"));

            project.Xml.ToolsVersion = "4.0";

            // Still current
            Assert.Equal(ObjectModelHelpers.MSBuildDefaultToolsVersion, project.GetPropertyValue("msbuildtoolsversion"));

            project.ReevaluateIfNecessary();

            // Still current
            Assert.Equal(ObjectModelHelpers.MSBuildDefaultToolsVersion, project.GetPropertyValue("msbuildtoolsversion"));
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:28,代码来源:Project_Tests.cs

示例12: ProjectToolsVersion20NotPresent

        public void ProjectToolsVersion20NotPresent()
        {
            if (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version20) != null)
            {
                // "Requires 2.0 to NOT be installed"
                return;
            }

            Project project = new Project();
            project.Xml.ToolsVersion = "2.0";
            project.ReevaluateIfNecessary();

            Assert.Equal(ObjectModelHelpers.MSBuildDefaultToolsVersion, project.ToolsVersion);

            project.Xml.ToolsVersion = ObjectModelHelpers.MSBuildDefaultToolsVersion;

            Assert.Equal(ObjectModelHelpers.MSBuildDefaultToolsVersion, project.ToolsVersion);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:18,代码来源:Project_Tests.cs

示例13: Dirtying_MetadataCondition

        public void Dirtying_MetadataCondition()
        {
            XmlReader content = XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup>
    <i Include=""i1"">
      <m>m1</m>
    </i>
  </ItemGroup>
</Project>")));

            Project project = new Project(content);
            ProjectMetadata metadatum = Helpers.GetFirst(project.Items).GetMetadata("m");

            metadatum.Xml.Condition = "false";

            Assert.Equal("m1", metadatum.EvaluatedValue);

            project.ReevaluateIfNecessary();
            metadatum = Helpers.GetFirst(project.Items).GetMetadata("m");

            Assert.Equal(null, metadatum);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:23,代码来源:ConstructionEditing_Tests.cs

示例14: Dirtying_ItemCondition

        public void Dirtying_ItemCondition()
        {
            XmlReader content = XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup>
    <i Include=""i1"" />
  </ItemGroup>
</Project>")));

            Project project = new Project(content);
            ProjectItem item = Helpers.GetFirst(project.Items);

            item.Xml.Condition = "false";

            Assert.Equal(1, Helpers.Count(project.Items));

            project.ReevaluateIfNecessary();

            Assert.Equal(0, Helpers.Count(project.Items));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:20,代码来源:ConstructionEditing_Tests.cs

示例15: SetUnchangedValue

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

            item.SetMetadataValue("m", "m1");

            Assert.AreEqual(false, project.IsDirty);

            item.GetMetadata("m").UnevaluatedValue = "m1";

            Assert.AreEqual(false, project.IsDirty);
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:15,代码来源:ProjectMetadata_Tests.cs


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