本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildItem类的典型用法代码示例。如果您正苦于以下问题:C# BuildItem类的具体用法?C# BuildItem怎么用?C# BuildItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildItem类属于Microsoft.Build.BuildEngine命名空间,在下文中一共展示了BuildItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CacheEntryGettersDefaultConstructors
public void CacheEntryGettersDefaultConstructors()
{
BuildItem[] buildItems = new BuildItem[2] { null, null };
BuildItemCacheEntry tice = new BuildItemCacheEntry();
Assertion.AssertEquals(null, tice.Name);
Assertion.AssertEquals(null, tice.BuildItems);
tice.Name = "tice";
tice.BuildItems = buildItems;
Assertion.AssertEquals("tice", tice.Name);
Assertion.AssertEquals(buildItems, tice.BuildItems);
PropertyCacheEntry pce = new PropertyCacheEntry();
Assertion.AssertEquals(null, pce.Name);
Assertion.AssertEquals(null, pce.Value);
pce.Name = "pce";
pce.Value = "propertyValue";
Assertion.AssertEquals("pce", pce.Name);
Assertion.AssertEquals("propertyValue", pce.Value);
BuildResultCacheEntry brce = new BuildResultCacheEntry();
Assertion.AssertEquals(null, brce.Name);
Assertion.AssertEquals(null, brce.BuildItems);
Assertion.AssertEquals(default(bool), brce.BuildResult);
brce.Name = "brce";
brce.BuildItems = buildItems;
brce.BuildResult = false;
Assertion.AssertEquals("brce", brce.Name);
Assertion.AssertEquals(buildItems, brce.BuildItems);
Assertion.AssertEquals(false, brce.BuildResult);
}
示例2: BuildItemProxy
internal BuildItemProxy(object buildItem)
{
instance = (Microsoft.Build.BuildEngine.BuildItem)buildItem;
// I am not sure what's going on here, but sometimes, in particular when the project is initialized
// the build item is not what we are getting here, but rather the child element
// 'get_ParentPersistedItem" gives us what we need
var persisted_instance = (BuildItem)typeof(BuildItem)
.InvokeMember("get_ParentPersistedItem", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, instance, new object[] { });
if (persisted_instance != null)
instance = persisted_instance;
buildItemGroup = (BuildItemGroup)typeof(BuildItem)
.InvokeMember("get_ParentPersistedItemGroup", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, instance, new object[] { });
int i = -1;
foreach (BuildItem item in buildItemGroup)
{
i++;
if (item == instance)
{
index = i;
break;
}
}
Include = instance.Include;
Type = instance.Name;
}
示例3: Initialize
public void Initialize()
{
// Create some items and place them in a dictionary
// Add some include information so that when we check the final
// item spec we can verify that the item was recreated properly
BuildItem buildItem1 = new BuildItem("BuildItem1", "Item1");
buildItem1.Include = "TestInclude1";
BuildItem[] buildItems = new BuildItem[1];
buildItems[0] = buildItem1;
Dictionary<object, object> dictionary = new Dictionary<object, object>();
dictionary.Add("TaskItems", buildItems);
Hashtable resultByTargetSuccess = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultByTargetSuccess.Add("TaskItems", Target.BuildState.CompletedSuccessfully);
Hashtable resultByTargetFailure = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultByTargetFailure.Add("TaskItems", Target.BuildState.CompletedUnsuccessfully);
Hashtable resultByTargetSkipped = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultByTargetSkipped.Add("TaskItems", Target.BuildState.Skipped);
resultWithOutputs = new BuildResult(dictionary, resultByTargetSuccess, true, 1, 1, 3, true, string.Empty, string.Empty, 0, 0, 0);
failedResult = new BuildResult(dictionary, resultByTargetFailure, false, 1, 1, 3, true, string.Empty, string.Empty, 0, 0, 0);
uncacheableResult = new BuildResult(dictionary, resultByTargetSkipped, true, 1, 1, 3, true, string.Empty, string.Empty, 0, 0, 0);
cacheScope = new CacheScope("temp.proj", new BuildPropertyGroup(), "3.5");
}
示例4: Initialize
public void Initialize()
{
// Create some items and place them in a dictionary
// Add some include information so that when we check the final
// item spec we can verify that the item was recreated properly
BuildItem[] buildItems = new BuildItem[1];
buildItems[0] = new BuildItem("BuildItem1", "Item1");
Dictionary<object, object> dictionary1 = new Dictionary<object, object>();
dictionary1.Add("Target1", buildItems);
Hashtable resultsByTarget1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultsByTarget1.Add("Target1", Target.BuildState.CompletedSuccessfully);
Dictionary<object, object> dictionary2 = new Dictionary<object, object>();
dictionary2.Add("Target2", buildItems);
dictionary2.Add("Target3", null);
Hashtable resultsByTarget2 = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultsByTarget2.Add("Target2", Target.BuildState.CompletedSuccessfully);
resultsByTarget2.Add("Target3", Target.BuildState.CompletedSuccessfully);
Dictionary<object, object> dictionary3 = new Dictionary<object, object>();
dictionary3.Add("Target4", buildItems);
Hashtable resultsByTarget3 = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultsByTarget3.Add("Target4", Target.BuildState.Skipped);
resultWith0Outputs = new BuildResult(new Hashtable(), new Hashtable(StringComparer.OrdinalIgnoreCase), true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
resultWith1Outputs = new BuildResult(dictionary1, resultsByTarget1, true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
resultWith2Outputs = new BuildResult(dictionary2, resultsByTarget2, true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
uncacheableResult = new BuildResult(dictionary3, resultsByTarget3, true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
}
示例5: ProjectElement
/// <summary>
/// Constructor to create a new MSBuild.BuildItem and add it to the project
/// Only have internal constructors as the only one who should be creating
/// such object is the project itself (see Project.CreateFileNode()).
/// </summary>
internal ProjectElement(ProjectNode project, string itemPath, string itemType)
{
if (project == null)
{
throw new ArgumentNullException("project");
}
if (String.IsNullOrEmpty(itemPath))
{
throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemPath");
}
if (String.IsNullOrEmpty(itemType))
{
throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemType");
}
this.itemProject = project;
// create and add the item to the project
this.item = project.BuildProject.AddNewItem(itemType, Microsoft.Build.BuildEngine.Utilities.Escape(itemPath));
this.itemProject.SetProjectFileDirty(true);
this.RefreshProperties();
}
示例6: BasicProxying
public void BasicProxying()
{
BuildItemGroup ig = new BuildItemGroup();
BuildItem i1 = new BuildItem("name1", "value1");
i1.SetMetadata("myMetaName", "myMetaValue");
BuildItem i2 = new BuildItem("name2", "value2");
ig.AddItem(i1);
ig.AddItem(i2);
BuildItemGroupProxy proxy = new BuildItemGroupProxy(ig);
// Gather everything into our own table
Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry item in proxy)
{
list.Add(item.Key, item.Value);
}
// Check we got all the items
Assertion.AssertEquals(2, list.Count);
Assertion.AssertEquals("value1", ((TaskItem)list["name1"]).ItemSpec);
Assertion.AssertEquals("value2", ((TaskItem)list["name2"]).ItemSpec);
// Check they have all their metadata
int builtInMetadata = FileUtilities.ItemSpecModifiers.All.Length;
Assertion.AssertEquals(1 + builtInMetadata, ((TaskItem)list["name1"]).MetadataCount);
Assertion.AssertEquals(0 + builtInMetadata, ((TaskItem)list["name2"]).MetadataCount);
Assertion.AssertEquals("myMetaValue", ((TaskItem)list["name1"]).GetMetadata("myMetaName"));
}
示例7: BuildItemGroup
internal BuildItemGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool dynamic)
{
this.buildItems = new List <BuildItem> ();
this.importedProject = importedProject;
this.itemGroupElement = xmlElement;
this.parentProject = project;
this.read_only = readOnly;
this.isDynamic = dynamic;
if (!FromXml)
return;
foreach (XmlNode xn in xmlElement.ChildNodes) {
if (!(xn is XmlElement))
continue;
XmlElement xe = (XmlElement) xn;
BuildItem bi = new BuildItem (xe, this);
buildItems.Add (bi);
project.LastItemGroupContaining [bi.Name] = this;
}
DefinedInFileName = importedProject != null ? importedProject.FullFileName :
project != null ? project.FullFileName : null;
}
示例8: IsOrphaned
public static bool IsOrphaned(BuildItem buildItem, ProjectBase owner)
{
bool considerBuildItem = (buildItem.Name == "Compile" || buildItem.Name == "Content" || buildItem.Name == "None");
if(!considerBuildItem)
{
if (owner is VisualStudioProject)
{
var asVisualStudioProject = owner as VisualStudioProject;
if (!considerBuildItem && buildItem.Name == asVisualStudioProject.DefaultContentAction)
{
considerBuildItem = true;
}
}
}
if (considerBuildItem)
{
// characters like '%' are encoded, so we have to decode them:
string relativeName = System.Web.HttpUtility.UrlDecode( buildItem.Include);
string fullName = owner.MakeAbsolute(relativeName);
return !FileManager.FileExists(fullName) && buildItem.Name != "ProjectReference";
}
return false;
}
示例9: AssertItemsMatch
/// <summary>
/// Amazingly sophisticated :) helper function to determine if the set of ITaskItems returned from
/// a task match the expected set of ITaskItems. It can also check that the ITaskItems have the expected
/// metadata, and that the ITaskItems are returned in the correct order.
///
/// The "expectedItemsString" is a formatted way of easily specifying which items you expect to see.
/// The format is:
///
/// itemspec1 : metadataname1=metadatavalue1 ; metadataname2=metadatavalue2 ; ...
/// itemspec2 : metadataname3=metadatavalue3 ; metadataname4=metadatavalue4 ; ...
/// itemspec3 : metadataname5=metadatavalue5 ; metadataname6=metadatavalue6 ; ...
///
/// (Each item needs to be on its own line.)
///
/// </summary>
/// <param name="expectedItemsString"></param>
/// <param name="actualItems"></param>
/// <owner>RGoel</owner>
static internal void AssertItemsMatch
(
string expectedItemsString,
BuildItem[] actualItems
)
{
AssertItemsMatch(expectedItemsString, actualItems, true);
}
示例10: Basic
public void Basic()
{
BuildItem item = new BuildItem("i", "i1");
Assertion.AssertEquals("i", item.Name);
Assertion.AssertEquals("i1", item.EvaluatedItemSpec);
Assertion.AssertEquals("i1", item.FinalItemSpec);
Assertion.AssertEquals("i1", item.FinalItemSpecEscaped);
}
示例11: AddDependencies
public void AddDependencies(ProjectInfo[] depends)
{
foreach (ProjectInfo proj in depends)
{
BuildItem bi = new BuildItem("Reference", proj.AssemblyName);
bi.SetMetadata("SpecificVersion", false.ToString());
bi.SetMetadata("HintPath", proj.AbsoluteOutputPath);
_psedoDepends.Add(new ProjectRef(bi, GetProjectPath));
}
}
示例12: GetReferenceDllName
private string GetReferenceDllName(BuildItem item)
{
string spec = item.FinalItemSpec;
int commaIndex = spec.IndexOf(CHAR_Comma);
if (commaIndex >= 0)
{
return spec.Substring(0, commaIndex);
}
return spec;
}
示例13: GetAssemblyPathFromVSInstalDir
private string GetAssemblyPathFromVSInstalDir(BuildItem item)
{
string name = GetReferenceDllName(item);
string[] installDirs = FrameworkHelper.GetVSInstallFoldersPaths();
string path = FrameworkHelper.GetAssemblyPath(name, installDirs);
if (File.Exists(path))
{
return path;
}
return string.Empty;
}
示例14: ProjectElement
/// <summary>
/// Constructor to create a new MSBuild.BuildItem and add it to the project
/// Only have internal constructors as the only one who should be creating
/// such object is the project itself (see Project.CreateFileNode()).
/// </summary>
internal ProjectElement(ProjectNode project, string itemPath, string itemType)
{
if (project == null)
throw new ArgumentNullException("project", String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.AddToNullProjectError), itemPath));
itemProject = project;
// create and add the item to the project
item = project.BuildProject.AddNewItem(itemType, itemPath);
project.SetProjectFileDirty(true);
this.RefreshProperties();
}
示例15: Hashtable
/// <summary>
/// Copy constructor
/// </summary>
internal BuildResult
(BuildResult buildResultToCopy, bool deepCopy)
{
ErrorUtilities.VerifyThrowArgumentNull(buildResultToCopy, "Cannot have a null build result passed in");
this.flags = buildResultToCopy.flags;
this.handleId = buildResultToCopy.handleId;
this.requestId = buildResultToCopy.requestId;
this.projectId = buildResultToCopy.projectId;
this.outputsByTarget = new Hashtable();
this.defaultTargets = buildResultToCopy.defaultTargets;
this.initialTargets = buildResultToCopy.initialTargets;
this.resultByTarget = new Hashtable(buildResultToCopy.resultByTarget, StringComparer.OrdinalIgnoreCase);
if (buildResultToCopy.outputsByTarget == null)
{
return;
}
if (deepCopy)
{
// Copy all the old data
foreach (DictionaryEntry entry in buildResultToCopy.outputsByTarget)
{
// Make deep copies of all the target outputs before
// passing them back
BuildItem[] originalArray = (BuildItem[])entry.Value;
BuildItem[] itemArray = new BuildItem[originalArray.Length];
for (int i = 0; i < originalArray.Length; i++)
{
if (!originalArray[i].IsUninitializedItem)
{
itemArray[i] = originalArray[i].Clone();
itemArray[i].CloneVirtualMetadata();
}
else
{
itemArray[i] = new BuildItem(null, originalArray[i].FinalItemSpecEscaped);
}
}
this.outputsByTarget.Add(entry.Key, itemArray);
}
}
else
{
// Create a new hashtable but point at the same data
foreach (DictionaryEntry entry in buildResultToCopy.outputsByTarget)
{
this.outputsByTarget.Add(entry.Key, entry.Value);
}
}
}