本文整理汇总了C#中Microsoft.Build.Tasks.CommandLineBuilderExtension.AppendTextUnquoted方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineBuilderExtension.AppendTextUnquoted方法的具体用法?C# CommandLineBuilderExtension.AppendTextUnquoted怎么用?C# CommandLineBuilderExtension.AppendTextUnquoted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Tasks.CommandLineBuilderExtension
的用法示例。
在下文中一共展示了CommandLineBuilderExtension.AppendTextUnquoted方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddResponseFileCommandsImpl
protected void AddResponseFileCommandsImpl(CommandLineBuilderExtension cmdline)
{
XSharpCommandLineBuilder commandLine = (XSharpCommandLineBuilder)cmdline;
// The managed compiler command line options are called from the cscCompiler options
if (this.Dialect?.Length > 0)
{
cmdline.AppendTextUnquoted(" /dialect:" + this.Dialect);
}
AddCscCompilerCommands(commandLine);
AddVOCompatibilityCommands(commandLine);
}
示例2: CalculateResourceBatchSize
/// <summary>
/// Given the list of inputs and outputs, returns the number of resources (starting at the provided initial index)
/// that can fit onto the commandline without exceeding MaximumCommandLength.
/// </summary>
private int CalculateResourceBatchSize(List<ITaskItem> inputsToProcess, List<ITaskItem> outputsToProcess, string resourcelessCommand, int initialResourceIndex)
{
CommandLineBuilderExtension currentCommand = new CommandLineBuilderExtension();
if (!String.IsNullOrEmpty(resourcelessCommand))
{
currentCommand.AppendTextUnquoted(resourcelessCommand);
}
int i = initialResourceIndex;
while (currentCommand.Length < s_maximumCommandLength && i < inputsToProcess.Count)
{
currentCommand.AppendFileNamesIfNotNull
(
new ITaskItem[] { inputsToProcess[i], outputsToProcess[i] },
","
);
i++;
}
int numberOfResourcesToAdd = 0;
if (currentCommand.Length <= s_maximumCommandLength)
{
// We've successfully added all the rest.
numberOfResourcesToAdd = i - initialResourceIndex;
}
else
{
// The last one added tossed us over the edge.
numberOfResourcesToAdd = i - initialResourceIndex - 1;
}
return numberOfResourcesToAdd;
}
示例3: AddCommandLineCommands
/// <summary>
/// Fills the provided CommandLineBuilderExtension with all the command line options used when
/// executing this tool that must go on the command line
/// </summary>
/// <comments>
/// Has to be command line commands because ResGen 3.5 and earlier don't know about
/// response files.
/// </comments>
/// <param name="commandLine">Gets filled with command line options</param>
protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
ErrorUtilities.VerifyThrow(!ResGen.IsNullOrEmpty(InputFiles), "If InputFiles is empty, the task should have returned before reaching this point");
CommandLineBuilderExtension resGenArguments = new CommandLineBuilderExtension();
GenerateResGenCommands(resGenArguments, false /* don't line-delimit arguments; spaces are just fine */);
string pathToResGen = GenerateResGenFullPath();
if (
pathToResGen != null &&
!pathToResGen.Equals(NativeMethodsShared.GetLongFilePath(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version35)), StringComparison.OrdinalIgnoreCase) &&
String.IsNullOrEmpty(StronglyTypedLanguage)
)
{
// 4.0 resgen.exe does support response files (at least as long as you're not building an STR), so we can
// make use of them here by returning nothing!
}
else
{
// otherwise, the toolname is ResGen.exe and we just need the resgen arguments in CommandLineCommands.
commandLine.AppendTextUnquoted(resGenArguments.ToString());
}
}
示例4: GenerateResGenCommands
/// <summary>
/// Generate the command line to be passed to resgen.exe, sans the path to the tool.
/// </summary>
private void GenerateResGenCommands(CommandLineBuilderExtension resGenArguments, bool useForResponseFile)
{
resGenArguments = resGenArguments ?? new CommandLineBuilderExtension();
if (ResGen.IsNullOrEmpty(OutputFiles))
{
GenerateOutputFileNames();
}
// Append boolean flags if requested
string useSourcePathSwitch = "/useSourcePath" + (useForResponseFile ? "\n" : String.Empty);
string publicClassSwitch = "/publicClass" + (useForResponseFile ? "\n" : String.Empty);
resGenArguments.AppendWhenTrue(useSourcePathSwitch, Bag, "UseSourcePath");
resGenArguments.AppendWhenTrue(publicClassSwitch, Bag, "PublicClass");
// append the references, if any
if (References != null)
{
foreach (ITaskItem reference in References)
{
// ResGen.exe response files frown on quotes in filenames, even if there are
// spaces in the names of the files.
if (useForResponseFile && reference != null)
{
resGenArguments.AppendTextUnquoted("/r:");
resGenArguments.AppendTextUnquoted(reference.ItemSpec);
resGenArguments.AppendTextUnquoted("\n");
}
else
{
resGenArguments.AppendSwitchIfNotNull("/r:", reference);
}
}
}
if (String.IsNullOrEmpty(StronglyTypedLanguage))
{
// append the compile switch
resGenArguments.AppendSwitch("/compile" + (useForResponseFile ? "\n" : String.Empty));
// append the resources to compile
if (InputFiles != null && InputFiles.Length > 0)
{
ITaskItem[] inputFiles = InputFiles;
ITaskItem[] outputFiles = OutputFiles;
for (int i = 0; i < inputFiles.Length; ++i)
{
if (useForResponseFile)
{
// ResGen.exe response files frown on quotes in filenames, even if there are
// spaces in the names of the files.
if (inputFiles[i] != null && outputFiles[i] != null)
{
resGenArguments.AppendTextUnquoted(inputFiles[i].ItemSpec);
resGenArguments.AppendTextUnquoted(",");
resGenArguments.AppendTextUnquoted(outputFiles[i].ItemSpec);
resGenArguments.AppendTextUnquoted("\n");
}
}
else
{
resGenArguments.AppendFileNamesIfNotNull
(
new ITaskItem[] { inputFiles[i], outputFiles[i] },
","
);
}
}
}
}
else
{
// append the resource to compile
resGenArguments.AppendFileNamesIfNotNull(InputFiles, " ");
resGenArguments.AppendFileNamesIfNotNull(OutputFiles, " ");
// append the strongly-typed resource details
resGenArguments.AppendSwitchIfNotNull
(
"/str:",
new string[] { StronglyTypedLanguage, StronglyTypedNamespace, StronglyTypedClassName, StronglyTypedFileName },
","
);
}
}
示例5: AddCommandLineCommands
protected override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
if (!string.IsNullOrEmpty(JvmOptions))
commandLine.AppendTextUnquoted(" " + JvmOptions.Trim());
}
示例6: AddResponseFileCommands
/// <summary>
/// Fills the provided CommandLineBuilderExtension with all the command line options used when
/// executing this tool that can go into a response file.
/// </summary>
/// <comments>
/// ResGen 3.5 and earlier doesn't support response files, but ResGen 4.0 and later does.
/// </comments>
/// <param name="commandLine">Gets filled with command line options</param>
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
string pathToResGen = GenerateResGenFullPath();
// Only do anything if we can actually use response files
if (
pathToResGen != null &&
!pathToResGen.Equals(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version35), StringComparison.OrdinalIgnoreCase) &&
String.IsNullOrEmpty(StronglyTypedLanguage)
)
{
// 4.0 resgen.exe does support response files, so we can return the resgen arguments here!
CommandLineBuilderExtension resGenArguments = new CommandLineBuilderExtension();
GenerateResGenCommands(resGenArguments, true /* arguments must be line-delimited */);
commandLine.AppendTextUnquoted(resGenArguments.ToString());
}
else
{
// return nothing -- if it's not 4.0, or if we're building strongly typed resources, we assume that,
// as far as ToolTask is concerned at least, response files are not supported.
}
}
示例7: AddResponseFileCommands
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
// the -verbose flag must be included or there's no way to figure out what the output files are
commandLine.AppendSwitch("-verbose");
if (!string.IsNullOrEmpty(Encoding))
commandLine.AppendSwitchIfNotNull("-encoding ", Encoding);
switch (DebugSymbols)
{
case "All":
commandLine.AppendSwitch("-g");break;
case "None":
commandLine.AppendSwitch("-g:none");break;
case "Specific":
if (!string.IsNullOrEmpty(SpecificDebugSymbols))
commandLine.AppendSwitchIfNotNull("-g:", SpecificDebugSymbols);
else
commandLine.AppendSwitch("-g:none");
break;
case "Default":
default:
break;
}
if (!string.IsNullOrEmpty(SourceRelease) && !string.Equals(SourceRelease, "Default", StringComparison.OrdinalIgnoreCase))
commandLine.AppendSwitchIfNotNull("-source ", SourceRelease);
if (!string.IsNullOrEmpty(TargetRelease) && !string.Equals(TargetRelease, "Default", StringComparison.OrdinalIgnoreCase))
commandLine.AppendSwitchIfNotNull("-target ", TargetRelease);
if (!string.IsNullOrEmpty(OutputPath))
commandLine.AppendSwitchIfNotNull("-d ", OutputPath);
if (!ShowWarnings)
{
commandLine.AppendSwitch("-nowarn");
}
else if (ShowAllWarnings)
{
commandLine.AppendSwitch("-Xlint");
commandLine.AppendSwitch("-deprecation");
}
if (!string.IsNullOrEmpty(BuildArgs))
commandLine.AppendTextUnquoted(" " + BuildArgs);
// reference paths
List<string> referencePaths = new List<string>();
foreach (var reference in (References ?? Enumerable.Empty<ITaskItem>()))
{
string path = GetReferencePath(reference);
if (!string.IsNullOrEmpty(path))
referencePaths.Add(path);
}
if (referencePaths.Count > 0)
{
commandLine.AppendSwitchIfNotNull("-cp ", referencePaths.ToArray(), ";");
}
commandLine.AppendSwitchIfNotNull("-classpath ", ClassPath, ";");
commandLine.AppendFileNamesIfNotNull(Sources, " ");
}
示例8: GenerateResGenCommands
private void GenerateResGenCommands(CommandLineBuilderExtension resGenArguments, bool useForResponseFile)
{
resGenArguments = resGenArguments ?? new CommandLineBuilderExtension();
if (IsNullOrEmpty(this.OutputFiles))
{
this.GenerateOutputFileNames();
}
string switchName = "/useSourcePath" + (useForResponseFile ? "\n" : string.Empty);
string str2 = "/publicClass" + (useForResponseFile ? "\n" : string.Empty);
resGenArguments.AppendWhenTrue(switchName, base.Bag, "UseSourcePath");
resGenArguments.AppendWhenTrue(str2, base.Bag, "PublicClass");
if (this.References != null)
{
foreach (ITaskItem item in this.References)
{
if (useForResponseFile && (item != null))
{
resGenArguments.AppendTextUnquoted("/r:");
resGenArguments.AppendTextUnquoted(item.ItemSpec);
resGenArguments.AppendTextUnquoted("\n");
}
else
{
resGenArguments.AppendSwitchIfNotNull("/r:", item);
}
}
}
if (string.IsNullOrEmpty(this.StronglyTypedLanguage))
{
resGenArguments.AppendSwitch("/compile" + (useForResponseFile ? "\n" : string.Empty));
if ((this.InputFiles != null) && (this.InputFiles.Length > 0))
{
ITaskItem[] inputFiles = this.InputFiles;
ITaskItem[] outputFiles = this.OutputFiles;
for (int i = 0; i < inputFiles.Length; i++)
{
if (useForResponseFile)
{
if ((inputFiles[i] != null) && (outputFiles[i] != null))
{
resGenArguments.AppendTextUnquoted(inputFiles[i].ItemSpec);
resGenArguments.AppendTextUnquoted(",");
resGenArguments.AppendTextUnquoted(outputFiles[i].ItemSpec);
resGenArguments.AppendTextUnquoted("\n");
}
}
else
{
resGenArguments.AppendFileNamesIfNotNull(new ITaskItem[] { inputFiles[i], outputFiles[i] }, ",");
}
}
}
}
else
{
resGenArguments.AppendFileNamesIfNotNull(this.InputFiles, " ");
resGenArguments.AppendFileNamesIfNotNull(this.OutputFiles, " ");
resGenArguments.AppendSwitchIfNotNull("/str:", new string[] { this.StronglyTypedLanguage, this.StronglyTypedNamespace, this.StronglyTypedClassName, this.StronglyTypedFileName }, ",");
}
}
示例9: AddResponseFileCommands
protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
{
string str = this.GenerateResGenFullPath();
if ((!this.TrackFileAccess && (str != null)) && (str.Equals(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version40), StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(this.StronglyTypedLanguage)))
{
CommandLineBuilderExtension resGenArguments = new CommandLineBuilderExtension();
this.GenerateResGenCommands(resGenArguments, true);
commandLine.AppendTextUnquoted(resGenArguments.ToString());
}
}
示例10: AddCommandLineCommands
protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
{
Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(!IsNullOrEmpty(this.InputFiles), "If InputFiles is empty, the task should have returned before reaching this point");
CommandLineBuilderExtension resGenArguments = new CommandLineBuilderExtension();
this.GenerateResGenCommands(resGenArguments, false);
string str = this.GenerateResGenFullPath();
if (this.TrackFileAccess)
{
string rootFiles = FileTracker.FormatRootingMarker(this.InputFiles);
string temporaryFile = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
string fileTrackerPath = FileTracker.GetFileTrackerPath(this.ToolType, this.TrackerFrameworkPath);
using (StreamWriter writer = new StreamWriter(temporaryFile, false, this.ResponseFileEncoding))
{
writer.Write(FileTracker.TrackerResponseFileArguments(fileTrackerPath, this.TrackerLogDirectory, rootFiles));
}
commandLine.AppendTextUnquoted(this.GetResponseFileSwitch(temporaryFile));
commandLine.AppendSwitch(FileTracker.TrackerCommandArguments(str ?? string.Empty, resGenArguments.ToString()));
}
else if (((str == null) || !str.Equals(Microsoft.Build.Shared.NativeMethodsShared.GetLongFilePath(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version40)), StringComparison.OrdinalIgnoreCase)) || !string.IsNullOrEmpty(this.StronglyTypedLanguage))
{
commandLine.AppendTextUnquoted(resGenArguments.ToString());
}
}
示例11: CalculateResourceBatchSize
private int CalculateResourceBatchSize(List<ITaskItem> inputsToProcess, List<ITaskItem> outputsToProcess, string resourcelessCommand, int initialResourceIndex)
{
CommandLineBuilderExtension extension = new CommandLineBuilderExtension();
if (!string.IsNullOrEmpty(resourcelessCommand))
{
extension.AppendTextUnquoted(resourcelessCommand);
}
int num = initialResourceIndex;
while ((extension.Length < MaximumCommandLength) && (num < inputsToProcess.Count))
{
extension.AppendFileNamesIfNotNull(new ITaskItem[] { inputsToProcess[num], outputsToProcess[num] }, ",");
num++;
}
if (num == inputsToProcess.Count)
{
return (num - initialResourceIndex);
}
return ((num - initialResourceIndex) - 1);
}