本文整理汇总了C#中Microsoft.Build.Tasks.CommandLineBuilderExtension类的典型用法代码示例。如果您正苦于以下问题:C# CommandLineBuilderExtension类的具体用法?C# CommandLineBuilderExtension怎么用?C# CommandLineBuilderExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandLineBuilderExtension类属于Microsoft.Build.Tasks命名空间,在下文中一共展示了CommandLineBuilderExtension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCommandLineCommands
protected internal override void AddCommandLineCommands (
CommandLineBuilderExtension commandLine)
{
if (Sources.Length == 0)
return;
foreach (ITaskItem item in Sources)
commandLine.AppendSwitchIfNotNull ("--complist=", item.ItemSpec);
commandLine.AppendSwitchIfNotNull ("--target=", LicenseTarget);
if (ReferencedAssemblies != null)
foreach (ITaskItem reference in ReferencedAssemblies)
commandLine.AppendSwitchIfNotNull ("--load=", reference.ItemSpec);
string outdir;
if (Bag ["OutputDirectory"] != null)
outdir = OutputDirectory;
else
outdir = ".";
commandLine.AppendSwitchIfNotNull ("--outdir=", outdir);
if (Bag ["NoLogo"] != null && NoLogo)
commandLine.AppendSwitch ("--nologo");
OutputLicense = new TaskItem (Path.Combine (OutputDirectory, LicenseTarget.ItemSpec + ".licenses"));
}
示例2: AddResponseFileCommands
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
commandLine.AppendSwitchIfNotNull("/lib:", base.AdditionalLibPaths, ",");
commandLine.AppendPlusOrMinusSwitch("/unsafe", base.Bag, "AllowUnsafeBlocks");
commandLine.AppendPlusOrMinusSwitch("/checked", base.Bag, "CheckForOverflowUnderflow");
commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", new char[] { ';', ',' });
commandLine.AppendWhenTrue("/fullpaths", base.Bag, "GenerateFullPaths");
commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion);
commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName);
commandLine.AppendSwitchIfNotNull("/pdb:", this.PdbFile);
commandLine.AppendPlusOrMinusSwitch("/nostdlib", base.Bag, "NoStandardLib");
commandLine.AppendSwitchIfNotNull("/platform:", this.Platform);
commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport);
commandLine.AppendSwitchWithInteger("/warn:", base.Bag, "WarningLevel");
commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile);
commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress);
commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(base.DefineConstants));
commandLine.AppendSwitchIfNotNull("/win32res:", base.Win32Resource);
commandLine.AppendSwitchIfNotNull("/main:", base.MainEntryPoint);
commandLine.AppendSwitchIfNotNull("/appconfig:", this.ApplicationConfiguration);
this.AddReferencesToCommandLine(commandLine);
base.AddResponseFileCommands(commandLine);
commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", new char[] { ';', ',' });
commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", new char[] { ';', ',' });
if (base.ResponseFiles != null)
{
foreach (ITaskItem item in base.ResponseFiles)
{
commandLine.AppendSwitchIfNotNull("@", item.ItemSpec);
}
}
}
示例3: ValidateHasParameter
/*
* Method: ValidateHasParameter
*
* Validates that the the given ToolTaskExtension's command line contains the indicated
* parameter. Returns the index of the parameter that matched.
*
*/
internal static int ValidateHasParameter(ToolTaskExtension t, string parameter, bool useResponseFile)
{
CommandLineBuilderExtension b = new CommandLineBuilderExtension();
if (useResponseFile)
t.AddResponseFileCommands(b);
else
t.AddCommandLineCommands(b);
string cl = b.ToString();
string msg = String.Format("Command-line = [{0}]\r\n", cl);
msg += String.Format(" Searching for [{0}]\r\n", parameter);
string[] pieces = Parse(cl);
int i = 0;
foreach (string s in pieces)
{
msg += String.Format(" Parm = [{0}]\r\n", s);
if (s == parameter)
{
return i;
}
i++;
}
msg += "Not found!\r\n";
Console.WriteLine(msg);
Assert.Fail(msg); // Could not find the parameter.
return 0;
}
示例4: AddReferencesToCommandLine
private void AddReferencesToCommandLine(CommandLineBuilderExtension commandLine)
{
if ((base.References != null) && (base.References.Length != 0))
{
List<ITaskItem> list = new List<ITaskItem>(base.References.Length);
List<ITaskItem> list2 = new List<ITaskItem>(base.References.Length);
foreach (ITaskItem item in base.References)
{
if (MetadataConversionUtilities.TryConvertItemMetadataToBool(item, "EmbedInteropTypes"))
{
list2.Add(item);
}
else
{
list.Add(item);
}
}
if (list2.Count > 0)
{
commandLine.AppendSwitchIfNotNull("/link:", list2.ToArray(), ",");
}
if (list.Count > 0)
{
commandLine.AppendSwitchIfNotNull("/reference:", list.ToArray(), ",");
}
}
}
示例5: AddCommandLineCommands
private void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
string outputDirectory = Path.GetDirectoryName(this.OutputFile);
if(!Directory.Exists( outputDirectory ))
Directory.CreateDirectory( outputDirectory );
commandLine.AppendSwitch( "-q" );
if (m_inputDirectories != null)
{
commandLine.AppendSwitch("-r");
}
commandLine.AppendFileNameIfNotNull( this.m_outputFile );
if (m_inputFiles != null)
{
foreach (ITaskItem inputFile in InputFiles)
{
Log.LogMessage("Adding file {0}", inputFile.ItemSpec);
commandLine.AppendFileNameIfNotNull(inputFile.ItemSpec);
}
}
if (m_inputDirectories != null)
{
foreach (ITaskItem inputDirectory in InputDirectories)
{
Log.LogMessage("Adding directory {0}", inputDirectory.ItemSpec);
commandLine.AppendFileNameIfNotNull(inputDirectory.ItemSpec);
}
}
}
示例6: AddCommandLineCommands
void AddCommandLineCommands (CommandLineBuilderExtension commandLine)
{
if (Resources.Length == 0)
return;
commandLine.AppendFileNameIfNotNull (OutputFile);
commandLine.AppendFileNamesIfNotNull (Resources, " ");
}
示例7: AddResponseFileCommands
protected internal override void AddResponseFileCommands (
CommandLineBuilderExtension commandLine)
{
commandLine.AppendSwitchIfNotNull ("/algid:", AlgorithmId);
commandLine.AppendSwitchIfNotNull ("/baseaddress:", BaseAddress);
commandLine.AppendSwitchIfNotNull ("/company:", CompanyName);
commandLine.AppendSwitchIfNotNull ("/configuration:", Configuration);
commandLine.AppendSwitchIfNotNull ("/culture:", Culture);
commandLine.AppendSwitchIfNotNull ("/copyright:", Copyright);
if (Bag ["DelaySign"] != null)
if (DelaySign)
commandLine.AppendSwitch ("/delaysign+");
else
commandLine.AppendSwitch ("/delaysign-");
commandLine.AppendSwitchIfNotNull ("/description:", Description);
if (EmbedResources != null) {
foreach (ITaskItem item in EmbedResources) {
string logical_name = item.GetMetadata ("LogicalName");
if (!string.IsNullOrEmpty (logical_name))
commandLine.AppendSwitchIfNotNull ("/embed:", string.Format ("{0},{1}", item.ItemSpec, logical_name));
else
commandLine.AppendSwitchIfNotNull ("/embed:", item.ItemSpec);
}
}
commandLine.AppendSwitchIfNotNull ("/evidence:", EvidenceFile);
commandLine.AppendSwitchIfNotNull ("/fileversion:", FileVersion);
commandLine.AppendSwitchIfNotNull ("/flags:", Flags);
if (GenerateFullPaths)
commandLine.AppendSwitch ("/fullpaths");
commandLine.AppendSwitchIfNotNull ("/keyname:", KeyContainer);
commandLine.AppendSwitchIfNotNull ("/keyfile:", KeyFile);
if (LinkResources != null)
foreach (ITaskItem item in LinkResources)
commandLine.AppendSwitchIfNotNull ("/link:", item.ItemSpec);
commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
if (OutputAssembly != null)
commandLine.AppendSwitchIfNotNull ("/out:", OutputAssembly.ItemSpec);
//platform
commandLine.AppendSwitchIfNotNull ("/product:", ProductName);
commandLine.AppendSwitchIfNotNull ("/productversion:", ProductVersion);
if (ResponseFiles != null)
foreach (string s in ResponseFiles)
commandLine.AppendFileNameIfNotNull (String.Format ("@{0}", s));
if (SourceModules != null)
foreach (ITaskItem item in SourceModules)
commandLine.AppendFileNameIfNotNull (item.ItemSpec);
commandLine.AppendSwitchIfNotNull ("/target:", TargetType);
commandLine.AppendSwitchIfNotNull ("/template:", TemplateFile);
commandLine.AppendSwitchIfNotNull ("/title:", Title);
commandLine.AppendSwitchIfNotNull ("/trademark:", Trademark);
commandLine.AppendSwitchIfNotNull ("/version:", Version);
commandLine.AppendSwitchIfNotNull ("/win32icon:", Win32Icon);
commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
}
示例8: AddCommandLineCommands
protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
this.CreateTemporaryBatchFile();
string batchFile = this.batchFile;
commandLine.AppendSwitch("/Q");
commandLine.AppendSwitch("/C");
if (batchFile.Contains("&") && !batchFile.Contains("^&"))
{
batchFile = Microsoft.Build.Shared.NativeMethodsShared.GetShortFilePath(batchFile).Replace("&", "^&");
}
commandLine.AppendFileNameIfNotNull(batchFile);
}
示例9: AddResponseFileCommands
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
if (((this.OutputAssembly == null) && (this.Sources != null)) && ((this.Sources.Length > 0) && (this.ResponseFiles == null)))
{
try
{
this.OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(this.Sources[0].ItemSpec));
}
catch (ArgumentException exception)
{
throw new ArgumentException(exception.Message, "Sources");
}
if (string.Compare(this.TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
{
ITaskItem outputAssembly = this.OutputAssembly;
outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".dll";
}
else if (string.Compare(this.TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
{
ITaskItem item2 = this.OutputAssembly;
item2.ItemSpec = item2.ItemSpec + ".netmodule";
}
else
{
ITaskItem item3 = this.OutputAssembly;
item3.ItemSpec = item3.ItemSpec + ".exe";
}
}
commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
commandLine.AppendSwitchWithInteger("/codepage:", base.Bag, "CodePage");
this.ConfigureDebugProperties();
commandLine.AppendPlusOrMinusSwitch("/debug", base.Bag, "EmitDebugInformation");
commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);
commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign");
commandLine.AppendSwitchWithInteger("/filealign:", base.Bag, "FileAlignment");
commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo");
commandLine.AppendWhenTrue("/nowin32manifest", base.Bag, "NoWin32Manifest");
commandLine.AppendPlusOrMinusSwitch("/optimize", base.Bag, "Optimize");
commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
commandLine.AppendPlusOrMinusSwitch("/warnaserror", base.Bag, "TreatWarningsAsErrors");
commandLine.AppendWhenTrue("/utf8output", base.Bag, "Utf8Output");
commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);
commandLine.AppendFileNamesIfNotNull(this.Sources, " ");
}
示例10: AddCommandLineCommands
protected internal override void AddCommandLineCommands (CommandLineBuilderExtension commandLine)
{
if (IsRunningOnWindows)
commandLine.AppendSwitch ("/q /c");
if (!String.IsNullOrEmpty (command)) {
scriptFile = Path.GetTempFileName ();
if (IsRunningOnWindows)
scriptFile = scriptFile + ".bat";
using (StreamWriter sw = new StreamWriter (scriptFile)) {
sw.Write (command);
}
commandLine.AppendFileNameIfNotNull (scriptFile);
}
base.AddCommandLineCommands (commandLine);
}
示例11: AddResponseFileCommands
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
if (OutputGeneratedFile != null && !String.IsNullOrEmpty(OutputGeneratedFile.ItemSpec))
commandLine.AppendSwitchIfNotNull("/outputgeneratedfile:", OutputGeneratedFile);
commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(base.DefineConstants));
this.AddReferencesToCommandLine(commandLine);
base.AddResponseFileCommands(commandLine);
if (ResponseFiles != null)
{
foreach (ITaskItem item in ResponseFiles)
{
commandLine.AppendSwitchIfNotNull("@", item.ItemSpec);
}
}
if (ContentFiles != null)
{
foreach (var file in ContentFiles)
{
commandLine.AppendSwitchIfNotNull("/contentfile:", file.ItemSpec);
}
}
if (NoneFiles != null)
{
foreach (var file in NoneFiles)
{
commandLine.AppendSwitchIfNotNull("/nonefile:", file.ItemSpec);
}
}
if (SkcPlugins != null)
{
foreach (var file in SkcPlugins)
{
commandLine.AppendSwitchIfNotNull("/plugin:", file.ItemSpec);
}
}
if (SkcRebuild)
commandLine.AppendSwitch("/rebuild");
if (UseBuildService)
{
Log.LogMessage("CurrentDirectory is: " + Directory.GetCurrentDirectory());
commandLine.AppendSwitchIfNotNull("/dir:", Directory.GetCurrentDirectory());
}
commandLine.AppendSwitchIfNotNull("/TargetFrameworkVersion:", TargetFrameworkVersion);
}
示例12: ARFC
public void ARFC (CommandLineBuilderExtension commandLine)
{
base.AddResponseFileCommands (commandLine);
#if !NET_4_0
string s = commandLine.ToString ();
if (s.Length == 6)
Assert.AreEqual ("/sdk:2", s);
else
Assert.AreEqual ("/sdk:2 ", s.Substring (0, 7));
BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
PropertyInfo pi = typeof (CommandLineBuilderExtension).GetProperty ("CommandLine", flags);
System.Text.StringBuilder sb = (System.Text.StringBuilder) pi.GetValue (commandLine, null);
sb.Length = 0;
if (s.Length > 6)
sb.Append (s.Substring (7));
#endif
}
示例13: AddReferencesToCommandLine
private void AddReferencesToCommandLine(CommandLineBuilderExtension commandLine)
{
if ((base.References != null) && (base.References.Length != 0))
{
foreach (ITaskItem item in base.References)
{
string metadata = item.GetMetadata("Aliases");
string switchName = "/reference:";
if (MetadataConversionUtilities.TryConvertItemMetadataToBool(item, "EmbedInteropTypes"))
{
switchName = "/link:";
}
if ((metadata == null) || (metadata.Length == 0))
{
commandLine.AppendSwitchIfNotNull(switchName, item.ItemSpec);
}
else
{
foreach (string str3 in metadata.Split(new char[] { ',' }))
{
string str4 = str3.Trim();
if (str3.Length != 0)
{
if (str4.IndexOfAny(new char[] { ',', ' ', ';', '"' }) != -1)
{
Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgument(false, "Csc.AssemblyAliasContainsIllegalCharacters", item.ItemSpec, str4);
}
if (string.Compare("global", str4, StringComparison.OrdinalIgnoreCase) == 0)
{
commandLine.AppendSwitchIfNotNull(switchName, item.ItemSpec);
}
else
{
commandLine.AppendSwitchAliased(switchName, str4, item.ItemSpec);
}
}
}
}
}
}
}
示例14: AppendItemWithInvalidBooleanAttribute
public void AppendItemWithInvalidBooleanAttribute()
{
Assert.Throws<ArgumentException>(() =>
{
// Construct the task item.
TaskItem i = new TaskItem();
i.ItemSpec = "MyResource.bmp";
i.SetMetadata("Name", "Kenny");
i.SetMetadata("Private", "Yes"); // This is our flag.
CommandLineBuilderExtension c = new CommandLineBuilderExtension();
// Validate that a legitimate bool works first.
try
{
c.AppendSwitchIfNotNull
(
"/myswitch:",
new ITaskItem[] { i },
new string[] { "Name", "Private" },
new bool[] { false, true }
);
Assert.Equal(@"/myswitch:MyResource.bmp,Kenny,Private", c.ToString());
}
catch (ArgumentException e)
{
Assert.True(false, "Got an unexpected exception:" + e.Message);
}
// Now try a bogus boolean.
i.SetMetadata("Private", "Maybe"); // This is our flag.
c.AppendSwitchIfNotNull
(
"/myswitch:",
new ITaskItem[] { i },
new string[] { "Name", "Private" },
new bool[] { false, true }
); // <-- Expect an ArgumentException here.
}
);
}
示例15: AddResponseFileCommands
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
commandLine.AppendSwitchIfNotNull("/algid:", this.AlgorithmId);
commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress);
commandLine.AppendSwitchIfNotNull("/company:", this.CompanyName);
commandLine.AppendSwitchIfNotNull("/configuration:", this.Configuration);
commandLine.AppendSwitchIfNotNull("/copyright:", this.Copyright);
commandLine.AppendSwitchIfNotNull("/culture:", this.Culture);
commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign");
commandLine.AppendSwitchIfNotNull("/description:", this.Description);
commandLine.AppendSwitchIfNotNull("/evidence:", this.EvidenceFile);
commandLine.AppendSwitchIfNotNull("/fileversion:", this.FileVersion);
commandLine.AppendSwitchIfNotNull("/flags:", this.Flags);
commandLine.AppendWhenTrue("/fullpaths", base.Bag, "GenerateFullPaths");
commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
commandLine.AppendSwitchIfNotNull("/keyname:", this.KeyContainer);
commandLine.AppendSwitchIfNotNull("/main:", this.MainEntryPoint);
commandLine.AppendSwitchIfNotNull("/out:", (this.OutputAssembly == null) ? null : this.OutputAssembly.ItemSpec);
commandLine.AppendSwitchIfNotNull("/platform:", this.Platform);
commandLine.AppendSwitchIfNotNull("/product:", this.ProductName);
commandLine.AppendSwitchIfNotNull("/productversion:", this.ProductVersion);
commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
commandLine.AppendSwitchIfNotNull("/template:", this.TemplateFile);
commandLine.AppendSwitchIfNotNull("/title:", this.Title);
commandLine.AppendSwitchIfNotNull("/trademark:", this.Trademark);
commandLine.AppendSwitchIfNotNull("/version:", this.Version);
commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
commandLine.AppendSwitchIfNotNull("/win32res:", this.Win32Resource);
commandLine.AppendSwitchIfNotNull("", this.SourceModules, new string[] { "TargetFile" });
commandLine.AppendSwitchIfNotNull("/embed:", this.EmbedResources, new string[] { "LogicalName", "Access" });
commandLine.AppendSwitchIfNotNull("/link:", this.LinkResources, new string[] { "LogicalName", "TargetFile", "Access" });
if (this.ResponseFiles != null)
{
foreach (string str in this.ResponseFiles)
{
commandLine.AppendSwitchIfNotNull("@", str);
}
}
}