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


C# ProjectInstance.ExpandString方法代码示例

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


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

示例1: ExpandStringWithMetadata

		public void ExpandStringWithMetadata ()
		{
			string project_xml = @"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <ItemGroup>
    <Foo Include='xxx'><M>x</M></Foo>
    <Foo Include='yyy'><M>y</M></Foo>
  </ItemGroup>
</Project>";
			var xml = XmlReader.Create (new StringReader (project_xml));
			var root = ProjectRootElement.Create (xml);
			root.FullPath = "ProjectInstanceTest.ExpandStringWithMetadata.proj";
			var proj = new ProjectInstance (root);
			Assert.AreEqual ("xxx;yyy", proj.ExpandString ("@(FOO)"), "#1"); // so, metadata is gone...
		}
开发者ID:Profit0004,项目名称:mono,代码行数:14,代码来源:ProjectInstanceTest.cs

示例2: GetPropertiesMetadataForProjectReference

        /// <summary>
        /// The value to be assigned to the metadata for a particular project reference.  Contains only configuration and platform specified in the project configuration, evaluated.
        /// </summary>
        private string GetPropertiesMetadataForProjectReference(ProjectInstance traversalProject, string configurationAndPlatformProperties)
        {
            string directProjectProperties = traversalProject.ExpandString(configurationAndPlatformProperties);

            if (traversalProject.SubToolsetVersion != null)
            {
                // Note: it is enough below to compare traversalProject.SubToolsetVersion with 4.0 as a means to verify if 
                // traversalProject.SubToolsetVersion < 12.0 since this path isn't followed for traversalProject.SubToolsetVersion values of 2.0 and 3.5
                if (traversalProject.SubToolsetVersion.Equals("4.0", StringComparison.OrdinalIgnoreCase))
                {
                    directProjectProperties = String.Format(CultureInfo.InvariantCulture, "{0}; {1}={2}", directProjectProperties, Constants.SubToolsetVersionPropertyName, traversalProject.SubToolsetVersion);
                }
            }

            return directProjectProperties;
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:19,代码来源:SolutionProjectGenerator.cs

示例3: LoadUsingTasks

		// FIXME: my guess is the tasks does not have to be loaded entirely but only requested tasks must be loaded at invocation time.
		void LoadUsingTasks (ProjectInstance projectInstance, IEnumerable<ProjectUsingTaskElement> usingTasks)
		{
			Func<string,bool> cond = s => projectInstance != null ? projectInstance.EvaluateCondition (s) : Convert.ToBoolean (s);
			Func<string,string> expand = s => projectInstance != null ? projectInstance.ExpandString (s) : s;
			foreach (var ut in usingTasks) {
				var aName = expand (ut.AssemblyName);
				var aFile = expand (ut.AssemblyFile);
				if (string.IsNullOrEmpty (aName) && string.IsNullOrEmpty (aFile)) {
					var errorNoAssembly = string.Format ("Task '{0}' does not specify either of AssemblyName or AssemblyFile.", ut.TaskName);
					engine.LogWarningEvent (new BuildWarningEventArgs (null, null, projectInstance.FullPath, ut.Location.Line, ut.Location.Column, 0, 0, errorNoAssembly, null, null));
					continue;
				}
				var ta = assemblies.FirstOrDefault (a => a.AssemblyFile.Equals (aFile, StringComparison.OrdinalIgnoreCase) || a.AssemblyName.Equals (aName, StringComparison.OrdinalIgnoreCase));
				if (ta == null) {
					var path = Path.GetDirectoryName (string.IsNullOrEmpty (ut.Location.File) ? projectInstance.FullPath : ut.Location.File);
					ta = new TaskAssembly () { AssemblyName = aName, AssemblyFile = aFile };
					try {
						ta.LoadedAssembly = !string.IsNullOrEmpty (ta.AssemblyName) ? Assembly.Load (ta.AssemblyName) : Assembly.LoadFile (Path.Combine (path, ta.AssemblyFile));
					} catch {
						var errorNotLoaded = string.Format ("For task '{0}' Specified assembly '{1}' was not found", ut.TaskName, string.IsNullOrEmpty (ta.AssemblyName) ? Path.Combine (path, ta.AssemblyFile) : ta.AssemblyName);
						engine.LogWarningEvent (new BuildWarningEventArgs (null, null, projectInstance.FullPath, ut.Location.Line, ut.Location.Column, 0, 0, errorNotLoaded, null, null));
						continue;
					}
					assemblies.Add (ta);
				}
				var pg = ut.ParameterGroup == null ? null : ut.ParameterGroup.Parameters.Select (p => new TaskPropertyInfo (p.Name, Type.GetType (p.ParameterType), cond (p.Output), cond (p.Required)))
					.ToDictionary (p => p.Name);
				

				Type type = null;
				string error = null;
				TaskDescription task = new TaskDescription () {
					TaskAssembly = ta,
					Name = ut.TaskName,
					TaskFactoryParameters = pg,
					TaskBody = ut.TaskBody != null && cond (ut.TaskBody.Condition) ? ut.TaskBody.TaskBody : null,
					};
				if (string.IsNullOrEmpty (ut.TaskFactory)) {
					type = LoadTypeFrom (ta.LoadedAssembly, ut.TaskName, ut.TaskName);
					if (type == null)
						error = string.Format ("For task '{0}' Specified type '{1}' was not found in assembly '{2}'", ut.TaskName, ut.TaskName, ta.LoadedAssembly.FullName);
					else
						task.TaskType = type;
				} else {
					type = LoadTypeFrom (ta.LoadedAssembly, ut.TaskName, ut.TaskFactory);
					if (type == null)
						error = string.Format ("For task '{0}' Specified factory type '{1}' was not found in assembly '{2}'", ut.TaskName, ut.TaskFactory, ta.LoadedAssembly.FullName);
					else
						task.TaskFactoryType = type;
				}
				if (error != null)
					engine.LogWarningEvent (new BuildWarningEventArgs (null, null, projectInstance.FullPath, ut.Location.Line, ut.Location.Column, 0, 0, error, null, null));
				else
					task_descs.Add (task);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:57,代码来源:BuildTaskDatabase.cs


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