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


C# Project.ExpandString方法代码示例

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


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

示例1: GetDependsOnTargetsAsList

        public static IList<string> GetDependsOnTargetsAsList(this ProjectTargetInstance target,Project project)
        {
            if (target == null) { throw new ArgumentNullException("target"); }
            if (project == null) { throw new ArgumentNullException("project"); }

            List<string> targets = new List<string>();
            string depTargets = target.DependsOnTargets != null ? target.DependsOnTargets : string.Empty;
            string depTargetsEvaluated = project.ExpandString(depTargets);

            string[] dtArray = depTargetsEvaluated.Split(';');
            dtArray.ToList().ForEach(t => {
                if (!string.IsNullOrWhiteSpace(t)) {
                    string tName = t.Trim();
                    if (!string.IsNullOrWhiteSpace(tName) &&
                        string.Compare(";", tName, StringComparison.InvariantCultureIgnoreCase) != 0) {
                        targets.Add(tName);
                    }
                }
            });

            int numTarges = targets != null ? targets.Count() : 0;
            string tempDebug = null;
            if (numTarges >= 1) {
                tempDebug = targets[0];
            }

            return targets;
        }
开发者ID:sayedihashimi,项目名称:msbuild-analyzer,代码行数:28,代码来源:ProjectTargetInstanceExtension.cs

示例2: MSBuildUsing

 public MSBuildUsing(Project project, ProjectUsingTaskElement pute)
 {
     FileInfo f = new FileInfo(pute.TaskName);
     this.Name = f.Name;
     this.AssemblyFile = pute.AssemblyFile;
     this.TaskFactory = pute.TaskFactory;
     this.Source = project.ExpandString(pute.AssemblyFile);
 }
开发者ID:nagyist,项目名称:MSBuildExplorer,代码行数:8,代码来源:MSBuildUsing.cs

示例3: MSBuildTarget

        public MSBuildTarget(ProjectTargetInstance pti, Project project, MSBuildFile parent = null)
        {
            this.Target = pti;
            this.Name = pti.Name;
            this.Inputs = pti.Inputs;
            this.Outputs = pti.Outputs;
            this.Location = pti.FullPath;
            this.DependsOnTargets = pti.DependsOnTargets;

            this.TargetColor = "Black";
            this.FontStyle = "Normal";

            if (!string.IsNullOrEmpty(this.Target.Condition))
            {
                this.TargetCondition = this.Target.Condition;
                this.TargetColor = "Gray";
                this.FontStyle = "Italic";
            }

            if (project.Xml.DefaultTargets.Contains(pti.Name))
            {
                this.TargetColor = "MediumBlue";
            }

            if (project.Xml.InitialTargets.Contains(pti.Name))
            {
                this.TargetColor = "LimeGreen";
            }

            if (project.Xml.InitialTargets.Contains(pti.Name) && project.Xml.DefaultTargets.Contains(pti.Name))
            {
                this.TargetColor = "Gold";
            }

            this.Targets = new ObservableCollection<MSBuildTarget>();

            string targets = project.ExpandString(pti.DependsOnTargets);
            targets = this.formatRegex.Replace(targets, string.Empty);
            int i = 0;
            foreach (var target in targets.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
                this.Targets.Add(new MSBuildTarget(target));
                i++;
            }

            foreach (var x in project.Xml.Targets.Where(x => x.Name == pti.Name))
            {
                this.BeforeTargets = x.BeforeTargets;
                this.AfterTargets = x.AfterTargets;
            }

            if (parent != null)
            {
                this.Parent = parent;
            }
        }
开发者ID:nagyist,项目名称:MSBuildExplorer,代码行数:56,代码来源:MSBuildTarget.cs

示例4: ProjectToJson

        private static JObject ProjectToJson(Project project)
        {
            JObject jsonProject = new JObject();
            // Project items like resources, sources and references
            foreach (var item in project.ItemsIgnoringCondition)
            {
                if (jsonProject[item.ItemType] == null)
                {
                    jsonProject[item.ItemType] = new JArray();
                }
                JArray array = (JArray)jsonProject[item.ItemType];

                var jsonItem = new JObject();
                jsonItem["Include"] = item.EvaluatedInclude;
                foreach (var metaData in item.Metadata)
                {
                    jsonItem[metaData.Name] = metaData.EvaluatedValue;
                }
                array.Add(jsonItem);
            }
            // Project properties
            JObject jsonProperties = new JObject();
            foreach (var property in project.AllEvaluatedProperties)
            {
                var value = project.ExpandString(property.EvaluatedValue);
                // Multiple values
                if (value.Contains(";") && value.Contains("\n"))
                {
                    var values = value
                        .Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                        .Where(v => !string.IsNullOrWhiteSpace(v))
                        .Select(v => v.Trim());
                    JArray jsonValueArray = new JArray();
                    foreach (var v in values)
                    {
                        jsonValueArray.Add(v);
                    }
                    jsonProperties[property.Name] = jsonValueArray;
                }
                else
                {
                    jsonProperties[property.Name] = value.Trim();
                }
            }
            jsonProject["Properties"] = jsonProperties;
            return jsonProject;
        }
开发者ID:ngyukman,项目名称:gradle-msbuild-plugin,代码行数:47,代码来源:Jsonify.cs

示例5: ExpandString

		public void ExpandString ()
		{
			string xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <PropertyGroup>
    <Foo>What are 'ESCAPE' &amp; ""EVALUATE"" ? $ # % ^</Foo>
    <Bar>y</Bar>
    <Baz Condition=""$(Void)==''"">$(FOO)</Baz>
  </PropertyGroup>
</Project>";
			var reader = XmlReader.Create (new StringReader (xml));
			var root = ProjectRootElement.Create (reader);
			var proj = new Project (root);
			root.FullPath = "ProjectTest.ExpandString.proj";
			Assert.AreEqual ("xyz", proj.ExpandString ("x$(BAR)z"), "#1");
			Assert.AreEqual ("x$(BARz", proj.ExpandString ("x$(BARz"), "#2"); // incomplete
			Assert.AreEqual ("xz", proj.ExpandString ("[email protected](BAR)z"), "#3"); // not an item
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:ProjectTest.cs

示例6: BuildTargetGraph

        protected internal AdjacencyGraph<ProjectTargetInstance, Edge<ProjectTargetInstance>> BuildTargetGraph(Project project)
        {
            AdjacencyGraph<ProjectTargetInstance, Edge<ProjectTargetInstance>> graph =
                new AdjacencyGraph<ProjectTargetInstance, Edge<ProjectTargetInstance>>();

            foreach (string key in project.Targets.Keys) {
                var target = project.Targets[key];
                if (!graph.ContainsVertex(target)) {
                    graph.AddVertex(target);
                }

                // TODO: DependsOnTargets needs to be evalueated
                string depTargetsString = target.DependsOnTargets != null ? target.DependsOnTargets : string.Empty;

                List<string> dependentTargets = target.GetDependsOnTargetsAsList(project).ToList();

                string depTargetsStringEvaluated = project.ExpandString(depTargetsString);

                dependentTargets.ToList().ForEach(depTarget => {
                    var dt = project.Targets[depTarget];
                    if (dt != null) {
                        if (!graph.ContainsVertex(dt)) {
                            graph.AddVertex(dt);
                        }

                        Edge<ProjectTargetInstance> e = new Edge<ProjectTargetInstance>(target, dt);
                        graph.AddEdge(e);
                    }
                });
            }

            return graph;
        }
开发者ID:sayedihashimi,项目名称:msbuild-analyzer,代码行数:33,代码来源:TargetAnalyzer.cs


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