BuildTask
Namespace:
Microsoft.Build.Engine
We found 10 examples in language CSharp for this search.
You will see 32 fragments of code.
Other methods
Other methods
Project:Fluent-Build
File:BuildTaskTests.cs
Examples:6
[Test]
public void AddResource_ShouldAddSingleFileResource()
{
var fileName = "blah.txt";
var build = new BuildTask("csc.exe", "library").AddResource(fileName);
var resrouce = build.Resources[0];
Assert.That(resrouce, Is.Not.Null);
Assert.That(resrouce.FilePath, Is.EqualTo(fileName));
Assert.That(resrouce.Identifier, Is.EqualTo(null));
}
///<summary>
///</summary>
///<summary />
[Test]
public void Args_ShouldCreateProperArgs()
{
string outputAssembly = "myapp.dll";
BuildTask build = new BuildTask("csc.exe", "library").OutputFileTo(outputAssembly);
build.BuildArgs();
Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/out:\"{0}\" /target:{1}", outputAssembly, "library")));
}
[Test]
public void Args_ShouldCreateProperArgsWithDefines()
{
string outputAssembly = "myapp.dll";
BuildTask build = new BuildTask("csc.exe", "library").OutputFileTo(outputAssembly).DefineSymbol("NET20").DefineSymbol("TEST");
build.BuildArgs();
Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/out:\"{0}\" /target:{1} /define:NET20 /define:TEST", outputAssembly, "library")));
}
[Test]
public void Args_ShouldAddAdditionalArgs()
{
string outputAssembly = "myapp.dll";
BuildTask build = new BuildTask("csc.exe", "library").OutputFileTo(outputAssembly).AddArgument("simple");
build.BuildArgs();
Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/simple /out:\"{0}\" /target:{1}", outputAssembly, "library")));
}
[Test]
public void Args_ShouldAddAdditionalArgsWithValue()
{
string outputAssembly = "myapp.dll";
BuildTask build = new BuildTask("csc.exe", "library").OutputFileTo(outputAssembly).AddArgument("key", "value");
build.BuildArgs();
Assert.That(build._argumentBuilder.Build().Trim(), Is.EqualTo(String.Format("/key:value /out:\"{0}\" /target:{1}", outputAssembly, "library")));
}
///<summary>
///</summary>
///<summary />
[Test]
public void UsingCsc_Compiler_Should_Be_CSC()
{
BuildTask build = new BuildTask("csc.exe", "library");
Assert.That(Path.GetFileName(build.Compiler), Is.EqualTo("csc.exe"));
}
Project:NF_forceFeedback
File:ClickableCubeEntity.cs
Examples:1
public void UnClickMe()
{
gameObject.GetComponent<Renderer>().material.color = Color_original;
Bool_firstClicked = false;
BuildTask.List_selectedCubes.Remove(this.gameObject);
BuildTask.List_wallCubes.Add(this.gameObject);
}
Project:mono-android
File:TaskBatchingImpl.cs
Examples:2
bool Execute (IBuildTask buildTask, TaskExecutionMode taskExecutionMode)
{
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project)) {
switch (taskExecutionMode) {
case TaskExecutionMode.Complete:
return buildTask.Execute ();
case TaskExecutionMode.SkipAndSetOutput:
return buildTask.ResolveOutputItems ();
default:
throw new NotImplementedException ();
}
}
return true;
}
// Parse task attributes to get list of referenced metadata and items
// to determine batching
//
void ParseTaskAttributes (IBuildTask buildTask)
{
foreach (var attr in buildTask.GetAttributes ()) {
ParseAttribute (attr);
}
}
Project:Marvin
File:TaskBatchingImpl.cs
Examples:1
//
// TaskBatchingImpl.cs: Class that implements Task Batching Algorithm from the wiki.
//
// Author:
// Marek Sieradzki ([email protected])
// Ankit Jain ([email protected])
//
// (C) 2005 Marek Sieradzki
// Copyright 2008 Novell, Inc (http://www.novell.com)
// Copyright 2009 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#if NET_2_0
using System;
using System.Collections.Generic;
using System.Xml;
namespace Microsoft.Build.BuildEngine {
internal class TaskBatchingImpl : BatchingImplBase
{
public TaskBatchingImpl (Project project)
: base (project)
{
}
public bool Build (BuildTask buildTask, out bool executeOnErrors)
{
executeOnErrors = false;
try {
Init ();
// populate list of referenced items and metadata
ParseTaskAttributes (buildTask);
if (consumedMetadataReferences.Count == 0) {
// No batching required
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project))
return buildTask.Execute ();
else // skipped, it should be logged
return true;
}
BatchAndPrepareBuckets ();
return Run (buildTask, out executeOnErrors);
} finally {
consumedItemsByName = null;
consumedMetadataReferences = null;
consumedQMetadataReferences = null;
consumedUQMetadataReferences = null;
batchedItemsByName = null;
commonItemsByName = null;
}
}
bool Run (BuildTask buildTask, out bool executeOnErrors)
{
executeOnErrors = false;
// Run the task in batches
bool retval = true;
if (buckets.Count == 0) {
// batched mode, but no values in the corresponding items!
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project)) {
retval = buildTask.Execute ();
if (!retval && !buildTask.ContinueOnError)
executeOnErrors = true;
}
return retval;
}
// batched
foreach (Dictionary<string, BuildItemGroup> bucket in buckets) {
project.PushBatch (bucket, commonItemsByName);
try {
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project)) {
retval = buildTask.Execute ();
if (!retval && !buildTask.ContinueOnError) {
executeOnErrors = true;
break;
}
}
} finally {
project.PopBatch ();
}
}
return retval;
}
// Parse task attributes to get list of referenced metadata and items
// to determine batching
//
void ParseTaskAttributes (BuildTask buildTask)
{
foreach (XmlAttribute attrib in buildTask.TaskElement.Attributes)
ParseAttribute (attrib.Value);
foreach (XmlNode xn in buildTask.TaskElement.ChildNodes) {
XmlElement xe = xn as XmlElement;
if (xe == null)
continue;
//FIXME: error on any other child
if (String.Compare (xe.LocalName, "Output", StringComparison.Ordinal) == 0) {
foreach (XmlAttribute attrib in xe.Attributes)
ParseAttribute (attrib.Value);
}
}
}
}
}
#endif
Project:-
File:BuildTask_Tests.cs
Examples:6
/// <summary>
/// Tests BuildTask.Condition Set when no previous exists
/// </summary>
[Test]
public void ConditionSetWhenNoPreviousConditionExists()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = "'t' == 'f'";
Assertion.AssertEquals("'t' == 'f'", task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set to an empty string
/// </summary>
[Test]
public void ConditionSetToEmtpyString()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = String.Empty;
Assertion.AssertEquals(String.Empty, task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set to null
/// </summary>
[Test]
public void ConditionSetToNull()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = null;
Assertion.AssertEquals(String.Empty, task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set to Special Characters
/// </summary>
[Test]
public void ConditionSetToSpecialCharacters()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = "%24%40%3b%5c%25";
Assertion.AssertEquals("%24%40%3b%5c%25", task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set on an Imported Project
/// </summary>
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void ConditionSetOnImportedProject()
{
Project p = GetProjectThatImportsAnotherProject(null, null);
BuildTask task = GetSpecificBuildTask(p, "t3", "t3.Task3");
task.Condition = "true";
}
/// <summary>
/// Tests BuildTask.ContinueOnError Set when no previous ContinueOnError value exists
/// </summary>
[Test]
public void ContinueOnErrorSetWhenNoContinueOnErrorExists()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.ContinueOnError = true;
Assertion.AssertEquals(true, task.ContinueOnError);
}
Project:Fluent-Build
File:BuildTask.cs
Examples:6
/// <summary>
/// Adds an aditional argument to be passed to the command line
/// </summary>
/// <param name="name">The name of the parameter (with no '/')</param>
/// <returns></returns>
public BuildTask AddArgument(string name)
{
_argumentBuilder.AddArgument(name);
return this;
}
/// <summary>
/// Adds an aditional argument to be passed to the command line
/// </summary>
/// <param name="name">The name of the parameter (with no '/')</param>
/// <param name="value">The value of the parameter</param>
/// <returns></returns>
public BuildTask AddArgument(string name, string value)
{
_argumentBuilder.AddArgument(name,value);
return this;
}
/// <summary>
/// Adds a compilation symbol
/// </summary>
/// <param name="symbol">The symbol to include</param>
/// <returns></returns>
public BuildTask DefineSymbol(string symbol)
{
_defineSymbols.Add(symbol);
return this;
}
/// <summary>
/// Sets the output file location
/// </summary>
/// <param name="outputFileLocation">The path to output the file to</param>
/// <returns></returns>
public BuildTask OutputFileTo(string outputFileLocation)
{
_outputFileLocation = outputFileLocation;
return this;
}
/// <summary>
/// Sets the output file location
/// </summary>
/// <param name="artifact">The BuildArtifact to output the file to</param>
/// <returns></returns>
public BuildTask OutputFileTo(File artifact)
{
return OutputFileTo(artifact.ToString());
}
/// <summary>
/// Adds a reference to be included in the build
/// </summary>
/// <param name="fileNames">a param array of string paths to the reference</param>
/// <returns></returns>
public BuildTask AddRefences(params string[] fileNames)
{
_references.AddRange(fileNames);
return this;
}
Project:MutationInjectionFramework
File:TaskBatchingImpl.cs
Examples:1
//
// TaskBatchingImpl.cs: Class that implements Task Batching Algorithm from the wiki.
//
// Author:
// Marek Sieradzki ([email protected])
// Ankit Jain ([email protected])
//
// (C) 2005 Marek Sieradzki
// Copyright 2008 Novell, Inc (http://www.novell.com)
// Copyright 2009 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#if NET_2_0
using System;
using System.Collections.Generic;
using System.Xml;
namespace Microsoft.Build.BuildEngine
{
internal class TaskBatchingImpl : BatchingImplBase
{
public TaskBatchingImpl (Project project)
: base (project)
{
}
public bool Build (BuildTask buildTask, out bool executeOnErrors)
{
executeOnErrors = false;
try
{
Init ();
// populate list of referenced items and metadata
ParseTaskAttributes (buildTask);
if (consumedMetadataReferences.Count == 0)
{
// No batching required
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project))
return buildTask.Execute ();
else // skipped, it should be logged
return true;
}
BatchAndPrepareBuckets ();
return Run (buildTask, out executeOnErrors);
}
finally
{
consumedItemsByName = null;
consumedMetadataReferences = null;
consumedQMetadataReferences = null;
consumedUQMetadataReferences = null;
batchedItemsByName = null;
commonItemsByName = null;
}
}
bool Run (BuildTask buildTask, out bool executeOnErrors)
{
executeOnErrors = false;
// Run the task in batches
bool retval = true;
if (buckets.Count == 0)
{
// batched mode, but no values in the corresponding items!
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project))
{
retval = buildTask.Execute ();
if (!retval && !buildTask.ContinueOnError)
executeOnErrors = true;
}
return retval;
}
// batched
foreach (Dictionary<string, BuildItemGroup> bucket in buckets)
{
project.PushBatch (bucket, commonItemsByName);
try
{
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project))
{
retval = buildTask.Execute ();
if (!retval && !buildTask.ContinueOnError)
{
executeOnErrors = true;
break;
}
}
}
finally
{
project.PopBatch ();
}
}
return retval;
}
// Parse task attributes to get list of referenced metadata and items
// to determine batching
//
void ParseTaskAttributes (BuildTask buildTask)
{
foreach (XmlAttribute attrib in buildTask.TaskElement.Attributes)
ParseAttribute (attrib.Value);
foreach (XmlNode xn in buildTask.TaskElement.ChildNodes)
{
XmlElement xe = xn as XmlElement;
if (xe == null)
continue;
//FIXME: error on any other child
if (String.Compare (xe.LocalName, "Output", StringComparison.Ordinal) == 0)
{
foreach (XmlAttribute attrib in xe.Attributes)
ParseAttribute (attrib.Value);
}
}
}
}
}
#endif
Project:myMono
File:TaskBatchingImpl.cs
Examples:2
bool Execute (IBuildTask buildTask, TaskExecutionMode taskExecutionMode)
{
if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project)) {
switch (taskExecutionMode) {
case TaskExecutionMode.Complete:
return buildTask.Execute ();
case TaskExecutionMode.SkipAndSetOutput:
return buildTask.ResolveOutputItems ();
default:
throw new NotImplementedException ();
}
}
return true;
}
// Parse task attributes to get list of referenced metadata and items
// to determine batching
//
void ParseTaskAttributes (IBuildTask buildTask)
{
foreach (var attr in buildTask.GetAttributes ()) {
ParseAttribute (attr);
}
}
Project:NF_forceFeedback
File:BuildUI.cs
Examples:1
void Return2MainUI()
{
BuildTask.List_wallCubes.Clear();
BuildTask.List_triggers.Clear();
BuildTask.List_selectedCubes.Clear();
GameSceneManager.Instance.Change2MainUI();
}
Project:main
File:BuildTask_Tests.cs
Examples:6
/// <summary>
/// Tests BuildTask.Condition Set when no previous exists
/// </summary>
[Test]
public void ConditionSetWhenNoPreviousConditionExists()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = "'t' == 'f'";
Assertion.AssertEquals("'t' == 'f'", task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set to an empty string
/// </summary>
[Test]
public void ConditionSetToEmtpyString()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = String.Empty;
Assertion.AssertEquals(String.Empty, task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set to null
/// </summary>
[Test]
public void ConditionSetToNull()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = null;
Assertion.AssertEquals(String.Empty, task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set to Special Characters
/// </summary>
[Test]
public void ConditionSetToSpecialCharacters()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.Condition = "%24%40%3b%5c%25";
Assertion.AssertEquals("%24%40%3b%5c%25", task.Condition);
}
/// <summary>
/// Tests BuildTask.Condition Set on an Imported Project
/// </summary>
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void ConditionSetOnImportedProject()
{
Project p = GetProjectThatImportsAnotherProject(null, null);
BuildTask task = GetSpecificBuildTask(p, "t3", "t3.Task3");
task.Condition = "true";
}
/// <summary>
/// Tests BuildTask.ContinueOnError Set when no previous ContinueOnError value exists
/// </summary>
[Test]
public void ContinueOnErrorSetWhenNoContinueOnErrorExists()
{
project.LoadXml(ProjectContentsWithOneTask);
BuildTask task = GetSpecificBuildTask(project, "t", "Task");
task.ContinueOnError = true;
Assertion.AssertEquals(true, task.ContinueOnError);
}
Microsoft.Build.BuildEngine.BuildTask : Object
Methods :
public String get_Name()public String get_Condition()
public Void set_Condition(String value = )
public Boolean get_ContinueOnError()
public Void set_ContinueOnError(Boolean value = )
public Type get_Type()
public ITaskHost get_HostObject()
public Void set_HostObject(ITaskHost value = )
public String[] GetParameterNames()
public String GetParameterValue(String attributeName = )
public Void SetParameterValue(String parameterName = , String parameterValue = , Boolean treatParameterValueAsLiteral = )
public Void SetParameterValue(String parameterName = , String parameterValue = )
public Void AddOutputItem(String taskParameter = , String itemName = )
public Void AddOutputProperty(String taskParameter = , String propertyName = )
public Boolean Execute()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()