本文整理汇总了C#中Microsoft.Build.BuildEngine.Project.SetExtensionsPathProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Project.SetExtensionsPathProperties方法的具体用法?C# Project.SetExtensionsPathProperties怎么用?C# Project.SetExtensionsPathProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.Project
的用法示例。
在下文中一共展示了Project.SetExtensionsPathProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForEachExtensionPathTillFound
// For every extension path, in order, finds suitable
// import filename(s) matching the Import, and calls
// @func with them
//
// func: bool func(importPath, from_source_msg)
//
// If for an extension path, atleast one file gets imported,
// then it stops at that.
// So, in case imports like "$(MSBuildExtensionsPath)\foo\*",
// for every extension path, it will try to import the "foo\*",
// and if atleast one file gets successfully imported, then it
// stops at that
internal static void ForEachExtensionPathTillFound (XmlElement xmlElement, Project project, ImportedProject importingProject,
Func<string, string, bool> func)
{
string project_attribute = xmlElement.GetAttribute ("Project");
string condition_attribute = xmlElement.GetAttribute ("Condition");
bool has_extn_ref = project_attribute.IndexOf ("$(MSBuildExtensionsPath)") >= 0 ||
project_attribute.IndexOf ("$(MSBuildExtensionsPath32)") >= 0 ||
project_attribute.IndexOf ("$(MSBuildExtensionsPath64)") >= 0;
string importingFile = importingProject != null ? importingProject.FullFileName : project.FullFileName;
DirectoryInfo base_dir_info = null;
if (!String.IsNullOrEmpty (importingFile))
base_dir_info = new DirectoryInfo (Path.GetDirectoryName (importingFile));
else
base_dir_info = new DirectoryInfo (Directory.GetCurrentDirectory ());
IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
bool import_needed = false;
try {
foreach (string path in extn_paths) {
string extn_msg = null;
if (has_extn_ref) {
project.SetExtensionsPathProperties (path);
extn_msg = "from extension path " + path;
}
// do this after setting new Extension properties, as condition might
// reference it
if (!ConditionParser.ParseAndEvaluate (condition_attribute, project))
continue;
import_needed = true;
// We stop if atleast one file got imported.
// Remaining extension paths are *not* tried
bool atleast_one = false;
foreach (string importPath in GetImportPathsFromString (project_attribute, project, base_dir_info)) {
try {
if (func (importPath, extn_msg))
atleast_one = true;
} catch (Exception e) {
throw new InvalidProjectFileException (String.Format (
"{0}: Project file could not be imported, it was being imported by " +
"{1}: {2}", importPath, importingFile, e.Message), e);
}
}
if (atleast_one)
return;
}
} finally {
if (has_extn_ref)
project.SetExtensionsPathProperties (Project.DefaultExtensionsPath);
}
if (import_needed)
throw new InvalidProjectFileException (String.Format ("{0} could not import \"{1}\"", importingFile, project_attribute));
}