本文整理汇总了C#中Microsoft.Build.BuildEngine.Target类的典型用法代码示例。如果您正苦于以下问题:C# Target类的具体用法?C# Target怎么用?C# Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Target类属于Microsoft.Build.BuildEngine命名空间,在下文中一共展示了Target类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: XnaContentProject
public XnaContentProject(Task task, string msBuildPath, string xnaInstallPath)
{
m_engine = new Engine(msBuildPath);
m_engine.RegisterLogger(new XnaContentLogger(task));
m_project = new Project(m_engine);
m_project.AddNewUsingTaskFromAssemblyName("BuildContent", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");
m_project.AddNewUsingTaskFromAssemblyName("BuildXact", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");
// Add our Content Pipeline Assemblies
m_pipelineGroup = m_project.AddNewItemGroup();
m_contentGroup = m_project.AddNewItemGroup();
m_contentTarget = m_project.Targets.AddNewTarget("_BuildXNAContentLists");
// Add our Build target
m_xnaTarget = m_project.Targets.AddNewTarget("Build");
m_xnaTarget.DependsOnTargets = "_BuildXNAContentLists";
// Add Default Pipeline Assemblies.
AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll");
AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll");
AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll");
AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll");
}
开发者ID:orj,项目名称:xnananttasks,代码行数:25,代码来源:XnaContentProject.cs
示例2: Visit
public void Visit(UsingTaskToken token)
{
currentTarget = null; // Out of any previous target context
valueResolver.Normalize(token);
if (token["AssemblyFile"] != null)
Project.AddNewUsingTaskFromAssemblyFile(token["TaskName"], token["AssemblyFile"]);
}
开发者ID:flq,项目名称:rfb,代码行数:7,代码来源:MsBuildProjectBuilder.cs
示例3: Build
public bool Build (Target target, out bool executeOnErrors)
{
executeOnErrors = false;
try {
string reason;
if (!BuildTargetNeeded (out reason)) {
LogTargetStarted (target);
LogTargetSkipped (target, reason);
LogTargetFinished (target, true);
return true;
}
if (!String.IsNullOrEmpty (reason))
target.Engine.LogMessage (MessageImportance.Low, reason);
Init ();
ParseTargetAttributes (target);
BatchAndPrepareBuckets ();
return Run (target, out executeOnErrors);
} finally {
consumedItemsByName = null;
consumedMetadataReferences = null;
consumedQMetadataReferences = null;
consumedUQMetadataReferences = null;
batchedItemsByName = null;
commonItemsByName = null;
}
}
开发者ID:stabbylambda,项目名称:mono,代码行数:29,代码来源:TargetBatchingImpl.cs
示例4: TestFromXml2
public void TestFromXml2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='Target' Condition='false' DependsOnTargets='X' >
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
project.Targets.CopyTo (t, 0);
Assert.AreEqual ("false", t [0].Condition, "A1");
Assert.AreEqual ("X", t [0].DependsOnTargets, "A2");
t [0].Condition = "true";
t [0].DependsOnTargets = "A;B";
Assert.AreEqual ("true", t [0].Condition, "A3");
Assert.AreEqual ("A;B", t [0].DependsOnTargets, "A4");
}
开发者ID:ancailliau,项目名称:mono,代码行数:26,代码来源:TargetTest.cs
示例5: GetTasks
static BuildTask[] GetTasks (Target t)
{
List <BuildTask> list = new List <BuildTask> ();
foreach (BuildTask bt in t)
list.Add (bt);
return list.ToArray ();
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:BuildTaskTest.cs
示例6: TargetIdWrapper
internal TargetInProgessState
(
EngineCallback engineCallback,
Target target,
List<ProjectBuildState> waitingBuildStates,
ProjectBuildState initiatingRequest,
BuildRequest [] outstandingBuildRequests,
string projectName
)
{
this.targetId = new TargetIdWrapper(target);
this.outstandingBuildRequests = outstandingBuildRequests;
// For each waiting build context try to find the parent target
this.parentBuildRequests = new List<BuildRequest>();
this.parentTargets = new List<TargetIdWrapper>();
this.projectName = projectName;
// Process the waiting contexts if there are any
if (waitingBuildStates != null)
{
for (int i = 0; i < waitingBuildStates.Count; i++)
{
ProcessBuildContext(engineCallback, waitingBuildStates[i], target);
}
}
// Process the initiating context
ProcessBuildContext(engineCallback, initiatingRequest, target);
}
开发者ID:nikson,项目名称:msbuild,代码行数:28,代码来源:TargetInProgressState.cs
示例7:
internal TargetExecutionWrapper
(
Target targetClass,
ArrayList taskElementList,
List<string> targetParameters,
XmlElement targetElement,
Expander expander,
BuildEventContext targetBuildEventContext
)
{
// Initialize the data about the target XML that has been calculated in the target class
this.targetClass = targetClass;
this.parentEngine = targetClass.ParentEngine;
this.parentProject = targetClass.ParentProject;
this.targetElement = targetElement;
this.taskElementList = taskElementList;
this.targetParameters = targetParameters;
this.targetBuildEventContext = targetBuildEventContext;
// Expand the list of depends on targets
dependsOnTargetNames = expander.ExpandAllIntoStringList(targetClass.DependsOnTargets, targetClass.DependsOnTargetsAttribute);
// Starting to build the target
inProgressBuildState = InProgressBuildState.StartingBuild;
// No messages have been logged
loggedTargetStart = false;
}
开发者ID:nikson,项目名称:msbuild,代码行数:27,代码来源:TargetExecutionWrapper.cs
示例8: Build
public bool Build (Target target, out bool executeOnErrors)
{
executeOnErrors = false;
try {
if (!BuildTargetNeeded ()) {
LogTargetStarted (target);
LogTargetSkipped (target);
LogTargetFinished (target, true);
return true;
}
Init ();
ParseTargetAttributes (target);
BatchAndPrepareBuckets ();
return Run (target, out executeOnErrors);
} finally {
consumedItemsByName = null;
consumedMetadataReferences = null;
consumedQMetadataReferences = null;
consumedUQMetadataReferences = null;
batchedItemsByName = null;
commonItemsByName = null;
}
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:25,代码来源:TargetBatchingImpl.cs
示例9: Run
bool Run (Target target, out bool executeOnErrors)
{
executeOnErrors = false;
if (buckets.Count > 0)
return RunBatched (target, out executeOnErrors);
else
return RunUnbatched (target, out executeOnErrors);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:TargetBatchingImpl.cs
示例10: BuildTask
internal BuildTask (XmlElement taskElement, Target parentTarget)
{
if (taskElement == null)
throw new ArgumentNullException ("taskElement");
if (parentTarget == null)
throw new ArgumentNullException ("parentTarget");
this.taskElement = taskElement;
this.parentTarget = parentTarget;
}
开发者ID:rabink,项目名称:mono,代码行数:10,代码来源:BuildTask.cs
示例11: Run
bool Run (Target target, out bool executeOnErrors)
{
executeOnErrors = false;
if (buckets.Count > 0) {
foreach (Dictionary<string, BuildItemGroup> bucket in buckets)
if (!RunTargetWithBucket (bucket, target, out executeOnErrors))
return false;
return true;
} else {
return RunTargetWithBucket (null, target, out executeOnErrors);
}
}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:13,代码来源:TargetBatchingImpl.cs
示例12: TargetDependencyAnalyzer
/// <summary>
/// Creates an instance of this class for the given target.
/// </summary>
/// <owner>SumedhK</owner>
internal TargetDependencyAnalyzer(string projectDirectory, Target targetToAnalyze, EngineLoggingServices loggingServices, BuildEventContext buildEventContext)
{
ErrorUtilities.VerifyThrow(projectDirectory != null, "Need a project directory.");
ErrorUtilities.VerifyThrow(targetToAnalyze != null, "Need a target to analyze.");
ErrorUtilities.VerifyThrow(targetToAnalyze.TargetElement != null, "Need a target element.");
this.projectDirectory = projectDirectory;
this.targetToAnalyze = targetToAnalyze;
this.targetInputsAttribute = targetToAnalyze.TargetElement.Attributes[XMakeAttributes.inputs];
this.targetOutputsAttribute = targetToAnalyze.TargetElement.Attributes[XMakeAttributes.outputs];
this.loggingService = loggingServices;
this.buildEventContext = buildEventContext;
}
开发者ID:nikson,项目名称:msbuild,代码行数:17,代码来源:TargetDependencyAnalyzer.cs
示例13: ProcessBuildContext
/// <summary>
/// Figure out the parent target or the parent build request for the given context
/// </summary>
private void ProcessBuildContext(EngineCallback engineCallback, ProjectBuildState buildContext, Target target)
{
BuildRequest parentRequest = null;
TargetIdWrapper parentName = FindParentTarget(engineCallback, buildContext, target, out parentRequest);
if (parentName != null)
{
parentTargets.Add(parentName);
}
if (parentRequest != null)
{
parentBuildRequests.Add(parentRequest);
}
}
开发者ID:nikson,项目名称:msbuild,代码行数:17,代码来源:TargetInProgressState.cs
示例14: foreach
/// <summary>
/// This constructor initializes a persisted task from an existing task
/// element which exists either in the main project file or one of the
/// imported files.
/// </summary>
/// <param name="taskElement"></param>
/// <param name="parentTarget"></param>
/// <param name="importedFromAnotherProject"></param>
/// <owner>rgoel</owner>
internal BuildTask
(
XmlElement taskElement,
Target parentTarget,
bool importedFromAnotherProject
)
{
// Make sure a valid node has been given to us.
error.VerifyThrow(taskElement != null, "Need a valid XML node.");
// Make sure a valid target has been given to us.
error.VerifyThrow(parentTarget != null, "Need a valid target parent.");
this.taskElement = taskElement;
this.parentTarget = parentTarget;
this.conditionAttribute = null;
this.continueOnErrorAttribute = null;
this.importedFromAnotherProject = importedFromAnotherProject;
// Loop through all the attributes on the task element.
foreach (XmlAttribute taskAttribute in taskElement.Attributes)
{
switch (taskAttribute.Name)
{
case XMakeAttributes.condition:
this.conditionAttribute = taskAttribute;
break;
case XMakeAttributes.continueOnError:
this.continueOnErrorAttribute = taskAttribute;
break;
// this only makes sense in the context of the new OM,
// so just ignore it.
case XMakeAttributes.msbuildRuntime:
// do nothing
break;
// this only makes sense in the context of the new OM,
// so just ignore it.
case XMakeAttributes.msbuildArchitecture:
// do nothing
break;
}
}
this.taskName = taskElement.Name;
}
开发者ID:nikson,项目名称:msbuild,代码行数:57,代码来源:BuildTask.cs
示例15: AddNewTarget
public Target AddNewTarget (string targetName)
{
if (targetName == null)
throw new InvalidProjectFileException (
"The required attribute \"Name\" is missing from element <Target>.");
XmlElement targetElement = parentProject.XmlDocument.CreateElement ("Target", Project.XmlNamespace);
parentProject.XmlDocument.DocumentElement.AppendChild (targetElement);
targetElement.SetAttribute ("Name", targetName);
Target t = new Target (targetElement, parentProject, null);
AddTarget (t);
return t;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:16,代码来源:TargetCollection.cs
示例16: Build
public bool Build (Target target, out bool executeOnErrors)
{
executeOnErrors = false;
try {
Init ();
ParseTargetAttributes (target);
BatchAndPrepareBuckets ();
return Run (target, out executeOnErrors);
} finally {
consumedItemsByName = null;
consumedMetadataReferences = null;
consumedQMetadataReferences = null;
consumedUQMetadataReferences = null;
batchedItemsByName = null;
commonItemsByName = null;
}
}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:18,代码来源:TargetBatchingImpl.cs
示例17:
/// <summary>
/// Default constructor for creation of task execution wrapper
/// </summary>
internal TaskExecutionContext
(
Project parentProject,
Target parentTarget,
XmlElement taskNode,
ProjectBuildState buildContext,
int handleId,
int nodeIndex,
BuildEventContext taskBuildEventContext
)
:base(handleId, nodeIndex, taskBuildEventContext)
{
this.parentProject = parentProject;
this.parentTarget = parentTarget;
this.taskNode = taskNode;
this.buildContext = buildContext;
this.thrownException = null;
}
开发者ID:nikson,项目名称:msbuild,代码行数:21,代码来源:TaskExecutionContext.cs
示例18: TestFromXml1
public void TestFromXml1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='Target'>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
project.Targets.CopyTo (t, 0);
Assert.AreEqual (String.Empty, t [0].Condition, "A1");
Assert.AreEqual (String.Empty, t [0].DependsOnTargets, "A2");
Assert.IsFalse (t [0].IsImported, "A3");
Assert.AreEqual ("Target", t [0].Name, "A4");
}
开发者ID:ancailliau,项目名称:mono,代码行数:22,代码来源:TargetTest.cs
示例19: TestFromXml
public void TestFromXml ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<Property>true</Property>
</PropertyGroup>
<Target Name='T'>
<Message Text='Text' />
<Message Text='Text' Condition='$(Property)' ContinueOnError='$(Property)' />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
Assert.AreEqual (String.Empty, bt [0].Condition, "A1");
Assert.IsFalse (bt [0].ContinueOnError, "A2");
Assert.IsNull (bt [0].HostObject, "A3");
Assert.AreEqual ("Message", bt [0].Name, "A4");
Assert.IsNotNull (bt [0].Type, "A5");
Assert.AreEqual ("$(Property)", bt [1].Condition, "A6");
Assert.IsTrue (bt [1].ContinueOnError, "A7");
Assert.IsNull (bt [1].HostObject, "A8");
Assert.AreEqual ("Message", bt [0].Name, "A9");
Assert.IsNotNull (bt [0].Type, "A10");
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:38,代码来源:BuildTaskTest.cs
示例20: GenerateSafePropertyName
/// <summary>
/// Add a call to the ResolveAssemblyReference task to crack the pre-resolved referenced
/// assemblies for the complete list of dependencies, PDBs, satellites, etc. The invoke
/// the Copy task to copy all these files (or at least the ones that RAR determined should
/// be copied local) into the web project's bin directory.
/// </summary>
/// <param name="target"></param>
/// <param name="proj"></param>
/// <param name="referenceItemName"></param>
/// <param name="conditionDescribingValidConfigurations"></param>
/// <owner>RGoel</owner>
static private void AddTasksToCopyAllDependenciesIntoBinDir
(
Target target,
ProjectInSolution proj,
string referenceItemName,
string conditionDescribingValidConfigurations
)
{
string copyLocalFilesItemName = referenceItemName + "_CopyLocalFiles";
string destinationFolder = String.Format(CultureInfo.InvariantCulture,
@"$({0})\Bin\", GenerateSafePropertyName(proj, "AspNetPhysicalPath"));
// This is a bit of a hack. We're actually calling the "Copy" task on all of
// the *non-existent* files. Why? Because we want to emit a warning in the
// log for each non-existent file, and the Copy task does that nicely for us.
// I would have used the <Warning> task except for the fact that we are in
// string-resource lockdown.
BuildTask copyNonExistentReferencesTask = target.AddNewTask("Copy");
copyNonExistentReferencesTask.SetParameterValue("SourceFiles", "@(" + referenceItemName + "->'%(FullPath)')", false /* Do not treat as literal */);
copyNonExistentReferencesTask.SetParameterValue("DestinationFolder", destinationFolder);
copyNonExistentReferencesTask.Condition = String.Format(CultureInfo.InvariantCulture, "!Exists('%({0}.Identity)')", referenceItemName);
copyNonExistentReferencesTask.ContinueOnError = true;
// Call ResolveAssemblyReference on each of the .DLL files that were found on
// disk from the .REFRESH files as well as the P2P references. RAR will crack
// the dependencies, find PDBs, satellite assemblies, etc., and determine which
// files need to be copy-localed.
BuildTask rarTask = target.AddNewTask("ResolveAssemblyReference");
rarTask.SetParameterValue("Assemblies", "@(" + referenceItemName + "->'%(FullPath)')", false /* Do not treat as literal */);
rarTask.SetParameterValue("TargetFrameworkDirectories", "@(_CombinedTargetFrameworkDirectoriesItem)", false /* Do not treat as literal */);
rarTask.SetParameterValue("InstalledAssemblyTables", "@(InstalledAssemblyTables)", false /* Do not treat as literal */);
rarTask.SetParameterValue("SearchPaths", "{RawFileName};{TargetFrameworkDirectory};{GAC}");
rarTask.SetParameterValue("FindDependencies", "true");
rarTask.SetParameterValue("FindSatellites", "true");
rarTask.SetParameterValue("FindSerializationAssemblies", "true");
rarTask.SetParameterValue("FindRelatedFiles", "true");
rarTask.Condition = String.Format(CultureInfo.InvariantCulture, "Exists('%({0}.Identity)')", referenceItemName);
rarTask.AddOutputItem("CopyLocalFiles", copyLocalFilesItemName);
// Copy all the copy-local files (reported by RAR) to the web project's "bin"
// directory.
BuildTask copyTask = target.AddNewTask("Copy");
copyTask.SetParameterValue("SourceFiles", "@(" + copyLocalFilesItemName + ")", false /* DO NOT treat as literal */);
copyTask.SetParameterValue("DestinationFiles", String.Format(CultureInfo.InvariantCulture,
@"@({0}->'{1}%(DestinationSubDirectory)%(Filename)%(Extension)')",
copyLocalFilesItemName, destinationFolder), false /* DO NOT treat as literal */);
copyTask.Condition = conditionDescribingValidConfigurations;
}
开发者ID:nikson,项目名称:msbuild,代码行数:59,代码来源:SolutionWrapperProject.cs
注:本文中的Microsoft.Build.BuildEngine.Target类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论