本文整理汇总了C#中ICSharpCode.SharpDevelop.Project.MSBuildBasedProject.GetItemsOfType方法的典型用法代码示例。如果您正苦于以下问题:C# MSBuildBasedProject.GetItemsOfType方法的具体用法?C# MSBuildBasedProject.GetItemsOfType怎么用?C# MSBuildBasedProject.GetItemsOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpDevelop.Project.MSBuildBasedProject
的用法示例。
在下文中一共展示了MSBuildBasedProject.GetItemsOfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReference
public static ReferenceProjectItem GetReference(MSBuildBasedProject project, string referenceName)
{
foreach (ReferenceProjectItem referenceProjectItem in project.GetItemsOfType(ItemType.Reference)) {
if (referenceProjectItem.Include == referenceName) {
return referenceProjectItem;
}
}
return null;
}
示例2: CSharpProject
public CSharpProject(MSBuildBasedProject project)
{
this.IProject = project;
CompilerSettings.AllowUnsafeBlocks = GetBoolProperty("AllowUnsafeBlocks") ?? false;
CompilerSettings.CheckForOverflow = GetBoolProperty("CheckForOverflowUnderflow") ?? false;
string defineConstants = project.GetEvaluatedProperty("DefineConstants");
foreach (string symbol in defineConstants.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries))
this.CompilerSettings.ConditionalSymbols.Add(symbol.Trim());
// Parse the C# code files
foreach (var item in project.GetItemsOfType(ItemType.Compile)) {
var file = new CSharpFile(this, FileName.Create(item.FileName));
Files.Add(file);
}
}
示例3: ResolveAssemblyReferences
internal static void ResolveAssemblyReferences(MSBuildBasedProject baseProject, ReferenceProjectItem[] referenceReplacements)
{
MSBuild.Engine tempEngine;
MSBuild.Project tempProject;
IEnumerable<ReferenceProjectItem> references;
lock (baseProject.SyncRoot) {
// create a copy of the project
tempEngine = CreateEngine();
tempProject = tempEngine.CreateNewProject();
// tell MSBuild the path so that projects containing <Import Project="relativePath" />
// can be loaded
tempProject.FullFileName = baseProject.MSBuildProject.FullFileName;
MSBuildBasedProject.InitializeMSBuildProject(tempProject);
tempProject.LoadXml(baseProject.MSBuildProject.Xml);
tempProject.SetProperty("Configuration", baseProject.ActiveConfiguration);
tempProject.SetProperty("Platform", baseProject.ActivePlatform);
tempProject.SetProperty("BuildingProject", "false");
if (referenceReplacements == null) {
references = baseProject.GetItemsOfType(ItemType.Reference).OfType<ReferenceProjectItem>();
// remove the "Private" meta data
foreach (MSBuild.BuildItemGroup itemGroup in tempProject.ItemGroups) {
// skip item groups from imported projects
if (itemGroup.IsImported)
continue;
foreach (MSBuild.BuildItem item in itemGroup) {
if (item.Name == ItemType.Reference.ItemName) {
item.RemoveMetadata("Private");
}
}
}
} else {
references = referenceReplacements;
// replace all references in the project with the referenceReplacements
foreach (MSBuild.BuildItemGroup itemGroup in tempProject.ItemGroups) {
// skip item groups from imported projects
if (itemGroup.IsImported)
continue;
foreach (MSBuild.BuildItem item in itemGroup.ToArray()) {
if (item.Name == ItemType.Reference.ItemName) {
itemGroup.RemoveItem(item);
}
}
}
foreach (ReferenceProjectItem item in referenceReplacements) {
tempProject.AddNewItem("Reference", item.Include, true);
}
}
}
var referenceDict = new Dictionary<string, ReferenceProjectItem>();
foreach (ReferenceProjectItem item in references) {
// references could be duplicate, so we cannot use referenceDict.Add or reference.ToDictionary
referenceDict[item.Include] = item;
}
#if DEBUG
//engine.RegisterLogger(new MSBuild.ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Detailed));
#endif
//Environment.CurrentDirectory = Path.GetDirectoryName(tempProject.FullFileName);
lock (MSBuildInternals.InProcessMSBuildLock) {
if (!tempProject.Build("ResolveAssemblyReferences")) {
LoggingService.Warn("ResolveAssemblyReferences exited with error");
return;
}
}
foreach (MSBuild.BuildItem item in tempProject.GetEvaluatedItemsByName("_ResolveAssemblyReferenceResolvedFiles")) {
string originalInclude = item.GetEvaluatedMetadata("OriginalItemSpec");
ReferenceProjectItem reference;
if (referenceDict.TryGetValue(originalInclude, out reference)) {
reference.AssemblyName = new Dom.DomAssemblyName(item.GetEvaluatedMetadata("FusionName"));
//string fullPath = item.GetEvaluatedMetadata("FullPath"); is incorrect for relative paths
string fullPath = FileUtility.GetAbsolutePath(baseProject.Directory, item.GetEvaluatedMetadata("Identity"));
reference.FileName = fullPath;
reference.Redist = item.GetEvaluatedMetadata("Redist");
//LoggingService.Debug("Got information about " + originalInclude + "; fullpath=" + fullPath);
reference.DefaultCopyLocalValue = bool.Parse(item.GetEvaluatedMetadata("CopyLocal"));
} else {
LoggingService.Warn("Unknown item " + originalInclude);
}
}
tempEngine.UnloadAllProjects(); // unload temp project
}