protected override String GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(false); if (!String.IsNullOrEmpty(DLLExport)) { builder.AppendSwitch("--dll-export"); builder.AppendFileNameIfNotNull(DLLExport); } if (!HeaderExt.Equals("h")) { builder.AppendSwitch("--header-ext"); builder.AppendFileNameIfNotNull(HeaderExt); } if (!SourceExt.Equals("cpp")) { builder.AppendSwitch("--source-ext"); builder.AppendFileNameIfNotNull(SourceExt); } if (!String.IsNullOrEmpty(BaseDirectoryForGeneratedInclude)) { builder.AppendSwitch("--include-dir"); builder.AppendFileNameIfNotNull(BaseDirectoryForGeneratedInclude); } builder.AppendTextUnquoted(" "); builder.AppendTextUnquoted(base.GenerateCommandLineCommands()); return(builder.ToString()); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void AppendStringValue(CommandLineBuilder builder, BaseProperty property, string subtype, string value) { string switchName = property.SwitchPrefix; if (string.IsNullOrEmpty(property.SwitchPrefix)) { switchName = m_parsedBuildRule.SwitchPrefix; } switchName += property.Switch + property.Separator; if (subtype == "file" || subtype == "folder") { if (!string.IsNullOrWhiteSpace(switchName)) { builder.AppendSwitchIfNotNull(switchName, value); } else { builder.AppendTextUnquoted(" " + PathUtils.QuoteIfNeeded(value)); } } else if (!string.IsNullOrEmpty(property.Switch)) { builder.AppendSwitchUnquotedIfNotNull(switchName, value); } else if (!string.IsNullOrEmpty(value)) { builder.AppendTextUnquoted(" " + value); } }
protected override string GenerateCommandLineCommands() { UsageError = false; CommandLineBuilder builder = new CommandLineBuilder(false); if (!string.IsNullOrEmpty(OutputDir)) { builder.AppendSwitch("--output-dir"); builder.AppendFileNameIfNotNull(OutputDir); } if (IncludeDirectories != null) { foreach (string path in IncludeDirectories) { builder.AppendSwitchIfNotNull("-I", path); } } builder.AppendSwitchIfNotNull("-I", Path.Combine(IceHome, "slice")); if (AdditionalOptions != null) { foreach (var option in AdditionalOptions) { builder.AppendTextUnquoted(" "); builder.AppendTextUnquoted(option); } } builder.AppendFileNamesIfNotNull(Sources, " "); return(builder.ToString()); }
protected override String GenerateCommandLineCommands() { UsageError = false; CommandLineBuilder builder = new CommandLineBuilder(false); if (Depend) { builder.AppendSwitch("--depend-xml"); builder.AppendSwitch("--depend-file"); builder.AppendFileNameIfNotNull(Path.Combine(OutputDir, DependFile)); } if (!String.IsNullOrEmpty(OutputDir)) { builder.AppendSwitch("--output-dir"); builder.AppendFileNameIfNotNull(OutputDir); } if (AllowIcePrefix) { builder.AppendSwitch("--ice"); } if (Underscore) { builder.AppendSwitch("--underscore"); } if (Stream) { builder.AppendSwitch("--stream"); } if (Checksum) { builder.AppendSwitch("--checksum"); } if (IncludeDirectories != null) { foreach (String path in IncludeDirectories) { builder.AppendSwitchIfNotNull("-I", path); } } if (!String.IsNullOrEmpty(AdditionalOptions)) { builder.AppendTextUnquoted(" "); builder.AppendTextUnquoted(AdditionalOptions); } builder.AppendFileNamesIfNotNull(Sources, " "); return(builder.ToString()); }
protected string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(false); builder.AppendSwitch("sign"); if (AdditionalOptions != null) { builder.AppendTextUnquoted(" "); builder.AppendTextUnquoted(AdditionalOptions); } builder.AppendFileNamesIfNotNull(Files, " "); return(builder.ToString()); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); builder.AppendTextUnquoted("install"); foreach (var package in Packages) { try { var pkg = new PackageInfo(package); var triplet = pkg.Triplet; if (string.IsNullOrEmpty(triplet)) { triplet = VcpkgTriplet; } if (!string.IsNullOrEmpty(triplet)) { triplet = PackageInfo.InfoSeparator + triplet; } builder.AppendTextUnquoted(" " + pkg.Name + triplet); } catch (Exception ex) { this.BuildEngine.LogErrorEvent(new BuildErrorEventArgs("PackageNameParsing", "InvalidPackageName", "", 0, 0, 0, 0, package + "\n" + ex.ToString(), "PackageNameParsing", "Vcpkg.PackageNameParsing")); } } if (!string.IsNullOrEmpty(VcpkgRoot)) { builder.AppendSwitch("--vcpkg-root"); builder.AppendFileNameIfNotNull(VcpkgRoot); } return(builder.ToString()); }
/// <summary> /// Invoked by ToolTask to generate the command to execute. /// </summary> /// <returns>A string representing the command to execute</returns> protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); builder.AppendSwitch("-c"); builder.AppendTextUnquoted(" \"" + RunPythonScript + "\" "); builder.AppendSwitch("glean_parser"); builder.AppendSwitch(GleanParserVersion); builder.AppendSwitch("translate"); builder.AppendSwitch("-f \"csharp\""); builder.AppendSwitch("-o"); builder.AppendFileNameIfNotNull(OutputPath); builder.AppendSwitch("-s \"glean_namespace=Mozilla.Glean\""); builder.AppendSwitch($"-s \"namespace={Namespace}\""); if (AllowReserved) { builder.AppendSwitch("--allow-reserved"); } foreach (ITaskItem file in RegistryFiles) { builder.AppendFileNameIfNotNull(Path.GetFullPath(file.ItemSpec)); } Log.LogMessage(MessageImportance.Low, "GleanParser.GenerateCommandLineCommands command: " + builder.ToString()); return(builder.ToString()); }
protected override void GenerateCommandLineCommands(CommandLineBuilder commandLineBuilder) { commandLineBuilder.AppendSwitch("restore"); commandLineBuilder.AppendFileNameIfNotNull(File); commandLineBuilder.AppendSwitchIfTrue("-RequireConsent", RequireConsent); commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-PackagesDirectory ", PackagesDirectory); commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-SolutionDirectory ", SolutionDirectory); commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-MSBuildVersion ", MsBuildVersion); if (IsNuGetVersion4OrGreater()) { commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-MSBuildPath ", MSBuildPath); } commandLineBuilder.AppendSwitchIfNotNullOrWhiteSpace("-Project2ProjectTimeOut ", Project2ProjectTimeOut); commandLineBuilder.AppendTextUnquoted(AdditionalArguments); base.GenerateCommandLineCommands(commandLineBuilder); }
protected override string GenerateCommandLineCommands() { var cmd = new CommandLineBuilder(); cmd.AppendSwitchIfNotNull("-jar ", JarPath); cmd.AppendTextUnquoted(" " + Arguments); if (!string.IsNullOrEmpty(AdbToolPath)) { var adb = !string.IsNullOrEmpty(AdbToolExe) ? AdbToolExe : "adb"; if (OS.IsWindows && !adb.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { adb += ".exe"; } cmd.AppendSwitchIfNotNull("--adb ", Path.Combine(AdbToolPath, adb)); } if (!string.IsNullOrEmpty(Aapt2ToolPath)) { cmd.AppendSwitchIfNotNull("--aapt2 ", Path.Combine(Aapt2ToolPath, OS.IsWindows ? "aapt2.exe" : "aapt2")); } cmd.AppendSwitchIfNotNull("--ks ", KeyStore); cmd.AppendSwitchIfNotNull("--ks-key-alias ", KeyAlias); if (!string.IsNullOrEmpty(KeyPass)) { cmd.AppendSwitchIfNotNull("--key-pass ", $"pass:{KeyPass}"); } if (!string.IsNullOrEmpty(StorePass)) { cmd.AppendSwitchIfNotNull("--ks-pass ", $"pass:{StorePass}"); } return(cmd.ToString()); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); var c = Environment.OSVersion.Platform == PlatformID.Unix ? "-" : "--"; if (EnableShadowCopy) { builder.AppendSwitch(c + "shadowcopy"); } if (_testInNewThread.HasValue && !_testInNewThread.Value) { builder.AppendSwitch(c + "nothread"); } if (Force32Bit) { builder.AppendSwitch(c + "x86"); } if (NoHeader) { builder.AppendSwitch(c + "noheader"); } if (NoColor) { builder.AppendSwitch(c + "nocolor"); } if (Verbose) { builder.AppendSwitch(c + "verbose"); } if (ReportProgressToTeamCity) { builder.AppendSwitch(c + "teamcity"); } builder.AppendFileNamesIfNotNull(Assemblies, " "); builder.AppendSwitchIfNotNull(c + "config=", ProjectConfiguration); builder.AppendSwitchIfNotNull(c + "err=", ErrorOutputFile); builder.AppendSwitchIfNotNull(c + "out=", TextOutputFile); builder.AppendSwitchIfNotNull(c + "framework=", Framework); builder.AppendSwitchIfNotNull(c + "process=", Process); builder.AppendSwitchIfNotNull(c + "domain=", Domain); builder.AppendSwitchIfNotNull(c + "apartment=", Apartment); builder.AppendSwitchIfNotNull(c + "where=", Where); builder.AppendSwitchIfNotNull(c + "timeout=", TestTimeout); builder.AppendSwitchIfNotNull(c + "workers=", Workers); builder.AppendSwitchIfNotNull(c + "result=", OutputXmlFile); builder.AppendSwitchIfNotNull(c + "work=", WorkingDirectory); builder.AppendSwitchIfNotNull(c + "labels=", ShowLabels); builder.AppendSwitchIfNotNull(c + "trace=", InternalTrace); if (!string.IsNullOrWhiteSpace(AdditionalArguments)) { builder.AppendTextUnquoted(" " + AdditionalArguments); } return(builder.ToString()); }
static void Main(string[] args) { CreateTemporaryBatchFile(); CommandLineBuilder commandLine = new CommandLineBuilder(); string batchFileForCommandLine = _batchFile; commandLine.AppendSwitch("-c"); commandLine.AppendTextUnquoted(" \"\"\""); commandLine.AppendTextUnquoted("export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; . "); commandLine.AppendFileNameIfNotNull(batchFileForCommandLine); commandLine.AppendTextUnquoted("\"\"\""); string commandLineCommands = commandLine.ToString(); // ensure the command line arguments string is not null if ((commandLineCommands == null) || (commandLineCommands.Length == 0)) { commandLineCommands = String.Empty; } // add a leading space to the command line arguments (if any) to // separate them from the tool path else { commandLineCommands = " " + commandLineCommands; } string pathToTool = "/bin/sh";// ComputePathToTool(); //if (pathToTool == null) //{ // // An appropriate error should have been logged already. // return false; //} commandLineCommands = AdjustCommandsForOperatingSystem(commandLineCommands); _exitCode = 0; _exitCode = ExecuteTool(pathToTool, string.Empty, /*responseFileCommands,*/ commandLineCommands); Console.WriteLine(_exitCode); }
protected override String GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); if (Tie) { builder.AppendSwitch("--tie "); } builder.AppendTextUnquoted(String.Format(" {0}", base.GenerateCommandLineCommands())); return(builder.ToString()); }
protected override string GenerateCommandLineCommands() { var bldr = new CommandLineBuilder(); if (Environment.OSVersion.Platform == PlatformID.Unix) { bldr.AppendSwitchIfNotNull("BUILD_CONFIG=", Configuration); bldr.AppendSwitchIfNotNull("BUILD_TYPE=", BuildType); bldr.AppendSwitchIfNotNull("BUILD_ROOT=", BuildRoot); bldr.AppendSwitchIfNotNull("BUILD_ARCH=", BuildArch); if (!string.IsNullOrEmpty(Macros)) { bldr.AppendTextUnquoted(" "); bldr.AppendTextUnquoted(Macros); } bldr.AppendSwitchIfNotNull("-C ", WorkingDirectory); bldr.AppendSwitchIfNotNull("-f ", Makefile); bldr.AppendSwitch(string.IsNullOrEmpty(Target) ? "all" : Target); } else { bldr.AppendSwitch("/nologo"); bldr.AppendSwitchIfNotNull("BUILD_CONFIG=", Configuration); bldr.AppendSwitchIfNotNull("BUILD_TYPE=", BuildType); bldr.AppendSwitchIfNotNull("BUILD_ROOT=", BuildRoot); bldr.AppendSwitchIfNotNull("BUILD_ARCH=", BuildArch); if (!string.IsNullOrEmpty(Macros)) { bldr.AppendTextUnquoted(" "); bldr.AppendTextUnquoted(Macros); } bldr.AppendSwitchIfNotNull("/f ", Makefile); if (!string.IsNullOrEmpty(Target)) { bldr.AppendSwitch(Target); } } return(bldr.ToString()); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); if (Source != null) { builder.AppendTextUnquoted("--file "); builder.AppendFileNameIfNotNull(Source); } var r = base.GenerateResponseFileCommands() + " " + builder.ToString(); return(r); }
protected override string GenerateCommandLineCommands() { var builder = new CommandLineBuilder(); var nugetFramework = NuGetFramework.Parse(Framework.ItemSpec); builder.AppendSwitch("-o"); CreateOutputDirectoryItem(nugetFramework); builder.AppendFileNameIfNotNull(OutputDirectory.ItemSpec); string frameworkPath = GetFrameworkPath(nugetFramework); builder.AppendSwitch("-f"); builder.AppendFileNameIfNotNull(frameworkPath); foreach (var assembly in IntersectionAssembly.NullAsEmpty()) { builder.AppendSwitch("-i"); builder.AppendFileNameIfNotNull(assembly.ItemSpec); } foreach (var referencePath in ReferencePath.NullAsEmpty()) { builder.AppendSwitch("-r"); builder.AppendFileNameIfNotNull(referencePath.ItemSpec); } foreach (var excludeType in ExcludeType.NullAsEmpty()) { builder.AppendSwitch("-b"); builder.AppendTextUnquoted(" \""); builder.AppendTextUnquoted(excludeType.ItemSpec); builder.AppendTextUnquoted("\""); } foreach (var removeAbstractType in RemoveAbstractTypeMembers.NullAsEmpty()) { builder.AppendSwitch("-a"); builder.AppendTextUnquoted(" \""); builder.AppendTextUnquoted(removeAbstractType.ItemSpec); builder.AppendTextUnquoted("\""); } foreach (var assembly in ExcludeAssembly.NullAsEmpty()) { builder.AppendSwitch("-e"); builder.AppendFileNameIfNotNull(assembly.ItemSpec); } AppendSwitchIfTrue(builder, "-k", KeepInternalConstructors); AppendSwitchIfTrue(builder, "-m", KeepMarshalling); AppendSwitchIfTrue(builder, "-iua", IgnoreUnresolvedAssemblies); return(builder.ToString()); }
protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); if (All) { builder.AppendSwitch("--all "); } if (Namespace) { builder.AppendSwitch("--namespace "); } builder.AppendTextUnquoted(string.Format(" {0}", base.GenerateCommandLineCommands())); return(builder.ToString()); }
/// <summary> /// Gets the MSBuild command-line based on the current properties of this object as a response file. /// </summary> /// <param name="useShortSwitchNames"><code>true</code> to use short command-line argument switches like '/nr' instead of '/NodeReuse', otherwise <code>false</code>.</param> /// <param name="responseFilePath">The full path to save the MSBuild response file to.</param> /// <returns>A command-line argument for MSBuild with the path to the response file.</returns> public string ToString(string responseFilePath, bool useShortSwitchNames) { string directoryName = Path.GetDirectoryName(responseFilePath); Directory.CreateDirectory(directoryName); File.WriteAllText(responseFilePath, ToString(useShortSwitchNames)); CommandLineBuilder commandLineBuilder = new CommandLineBuilder(); commandLineBuilder.AppendSwitch("@"); commandLineBuilder.AppendTextUnquoted($"\"{responseFilePath}\""); return(commandLineBuilder.ToString()); }
protected override String GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); if (!String.IsNullOrEmpty(Prefix)) { builder.AppendSwitch("--prefix"); builder.AppendFileNameIfNotNull(Prefix); } if (NoPackage) { builder.AppendSwitch("--no-package"); } builder.AppendTextUnquoted(String.Format(" {0}", base.GenerateCommandLineCommands())); return(builder.ToString()); }
public void UseNewLineSeparators() { CommandLineBuilder c = new CommandLineBuilder(quoteHyphensOnCommandLine: false, useNewLineSeparator: true); c.AppendSwitchIfNotNull("/foo:", "bar"); c.AppendFileNameIfNotNull("18056896847C4FFC9706F1D585C077B4"); c.AppendSwitch("/D:"); c.AppendTextUnquoted("C7E1720B16E5477D8D15733006E68278"); string[] actual = c.ToString().Split(MSBuildConstants.EnvironmentNewLine, StringSplitOptions.None); string[] expected = { "/foo:bar", "18056896847C4FFC9706F1D585C077B4", "/D:C7E1720B16E5477D8D15733006E68278" }; actual.ShouldBe(expected); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void AppendStringListValue(CommandLineBuilder builder, BaseProperty property, string subtype, string [] value, string delimiter) { string switchName = m_parsedBuildRule.SwitchPrefix + property.Switch; switchName += property.Separator; if (subtype == "file" || subtype == "folder") { builder.AppendSwitchUnquotedIfNotNull(switchName, value, delimiter); } else if (!string.IsNullOrEmpty(property.Switch)) { builder.AppendSwitchUnquotedIfNotNull(switchName, value, delimiter); } else if (value.Length > 0) { foreach (string entry in value) { builder.AppendTextUnquoted(entry + delimiter); } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void AppendStringValue(ref CommandLineBuilder builder, Rule rule, StringProperty property, object value) { if (value == null) { return; } string switchPrefix = !string.IsNullOrWhiteSpace(property.SwitchPrefix) ? property.SwitchPrefix : rule.SwitchPrefix; string evaluatedSwitch = $"{switchPrefix ?? string.Empty}{property.Switch ?? string.Empty}{property.Separator ?? string.Empty}"; var delimiter = " ";// !string.IsNullOrWhiteSpace(property.CommandLineValueSeparator) ? property.CommandLineValueSeparator : $" {evaluatedSwitch}"; if (value.GetType() == typeof(ITaskItem)) { builder.AppendSwitchIfNotNull(evaluatedSwitch, ConvertToObject <ITaskItem>(value)); } else if (value.GetType() == typeof(ITaskItem[])) { builder.AppendSwitchIfNotNull(evaluatedSwitch, value as ITaskItem[], $"{delimiter}{evaluatedSwitch}"); } else if (string.Equals(property.DataSource?.ItemType, "Item", StringComparison.OrdinalIgnoreCase)) { builder.AppendSwitchIfNotNull(evaluatedSwitch, value as ITaskItem[], $"{delimiter}{evaluatedSwitch}"); } else if (string.Equals(property.Subtype, "file", StringComparison.OrdinalIgnoreCase) || string.Equals(property.Subtype, "folder", StringComparison.OrdinalIgnoreCase)) { builder.AppendSwitchIfNotNull(evaluatedSwitch, ConvertToObject <ITaskItem>(value)); } else if (!string.IsNullOrWhiteSpace(evaluatedSwitch)) { builder.AppendSwitchUnquotedIfNotNull($"{evaluatedSwitch}", ConvertToObject <string>(value)); } else { builder.AppendTextUnquoted(" " + value); } }
// helper for string-based properties private void AppendStringValue(CommandLineBuilder builder, BaseProperty property, string subtype, string value) { value = value.Trim(); // could cache this SubType test off in property wrapper or somewhere if performance were an issue string switchName = m_parsedBuildRule.SwitchPrefix + property.Switch; switchName += property.Separator; if (subtype == "file" || subtype == "folder") { // for switches that contains files or folders we need quoting builder.AppendSwitchIfNotNull(switchName, value); } else if (!string.IsNullOrEmpty(property.Switch)) { builder.AppendSwitchUnquotedIfNotNull(switchName, value); } else if (!string.IsNullOrEmpty(value)) { // for non-switches such as AdditionalOptions we just append the value builder.AppendTextUnquoted(" " + value); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected virtual string GenerateResponseFileSwitches(CommandLineBuilder builder = default, HashSet <string> propertiesToIgnore = null) { builder ??= new CommandLineBuilder(); propertiesToIgnore ??= new HashSet <string>(); // // Generate a XAML rule based on [Switch...] attributes and any specified properties file. // Rule rule = new Rule(); var parser = new CommandLineGenerator(); if (SwitchAttributes?.Count > 0) { var attributeBasedProperties = SwitchAttributes.Select(attr => attr.Value.GetProperty()); foreach (var property in attributeBasedProperties) { rule.Properties.Add(property); Log.LogMessage($"[{ToolName}] Added property from {GetType().Name}: {property.Name} | {property.GetType().Name}"); } } if (PropertiesFile != null) { var xamlFileRule = CommandLineGenerator.LoadXamlRule(PropertiesFile); rule.Properties.AddRange(xamlFileRule.Properties); } // // Evaluate parameter types and values for each of those attributed with a [ToolSwitch...] variant. // var propertyValues = new Dictionary <string, object>(); try { foreach (var attribute in SwitchAttributes) { string name = attribute.Key; BaseProperty property = attribute.Value.GetProperty(); object value = attribute.Value.GetValue(); propertyValues.Add(name, value); Log.LogMessage($"[{ToolName}] Property from {GetType().Name}: {name} | {property.GetType().Name} | {(value == null ? "(null)" : $"{value} ({value.GetType()})")}"); } if (OutOfDateInputFiles?.Length > 0) { GenerateSwitchesForTaskItem(ref propertyValues, OutOfDateInputFiles[0], rule, propertiesToIgnore); } // // Validate required parameters are present. // foreach (var prop in rule.Properties) { if (prop.IsRequired && !propertyValues.ContainsKey(prop.Name)) { Log.LogError($"[{GetType().Name}] Required parameter {prop.Name} has no assigned property value."); } } string commandLine = parser.GenerateCommandLine(rule, propertyValues, propertiesToIgnore); builder.AppendTextUnquoted(commandLine); }
protected override string GenerateCommandLineCommands() { var cmd = new CommandLineBuilder(); #if DEBUG cmd.AppendSwitch("/v"); #endif if (NoStdLib) { cmd.AppendSwitch("/nostdlib"); } cmd.AppendSwitchIfNotNull("/compiler:", CompilerPath); cmd.AppendSwitchIfNotNull("/baselib:", BaseLibDll); cmd.AppendSwitchIfNotNull("/out:", OutputAssembly); if (NoStdLib) { string dir; if (!string.IsNullOrEmpty(BaseLibDll)) { dir = Path.GetDirectoryName(BaseLibDll); } else { dir = null; } cmd.AppendSwitchIfNotNull("/lib:", dir); cmd.AppendSwitchIfNotNull("/r:", Path.Combine(dir, "mscorlib.dll")); } if (ProcessEnums) { cmd.AppendSwitch("/process-enums"); } if (EmitDebugInformation) { cmd.AppendSwitch("/debug"); } if (AllowUnsafeBlocks) { cmd.AppendSwitch("/unsafe"); } cmd.AppendSwitchIfNotNull("/ns:", Namespace); if (!string.IsNullOrEmpty(DefineConstants)) { var strv = DefineConstants.Split(new [] { ';' }); var sanitized = new List <string> (); foreach (var str in strv) { if (str != string.Empty) { sanitized.Add(str); } } if (sanitized.Count > 0) { cmd.AppendSwitchIfNotNull("/d:", string.Join(";", sanitized.ToArray())); } } //cmd.AppendSwitch ("/e"); foreach (var item in ApiDefinitions) { cmd.AppendFileNameIfNotNull(Path.GetFullPath(item.ItemSpec)); } if (CoreSources != null) { foreach (var item in CoreSources) { cmd.AppendSwitchIfNotNull("/s:", Path.GetFullPath(item.ItemSpec)); } } if (Sources != null) { foreach (var item in Sources) { cmd.AppendSwitchIfNotNull("/x:", Path.GetFullPath(item.ItemSpec)); } } if (AdditionalLibPaths != null) { foreach (var item in AdditionalLibPaths) { cmd.AppendSwitchIfNotNull("/lib:", Path.GetFullPath(item.ItemSpec)); } } HandleReferences(cmd); if (Resources != null) { foreach (var item in Resources) { var args = new List <string> (); string id; args.Add(item.ToString()); id = item.GetMetadata("LogicalName"); if (!string.IsNullOrEmpty(id)) { args.Add(id); } cmd.AppendSwitchIfNotNull("/res:", args.ToArray(), ","); } } if (NativeLibraries != null) { foreach (var item in NativeLibraries) { var args = new List <string> (); string id; args.Add(item.ToString()); id = item.GetMetadata("LogicalName"); if (string.IsNullOrEmpty(id)) { id = Path.GetFileName(args[0]); } args.Add(id); cmd.AppendSwitchIfNotNull("/link-with:", args.ToArray(), ","); } } if (GeneratedSourcesDir != null) { cmd.AppendSwitchIfNotNull("/tmpdir:", Path.GetFullPath(GeneratedSourcesDir)); } if (GeneratedSourcesFileList != null) { cmd.AppendSwitchIfNotNull("/sourceonly:", Path.GetFullPath(GeneratedSourcesFileList)); } cmd.AppendSwitch(GetTargetFrameworkArgument()); if (!string.IsNullOrEmpty(ExtraArgs)) { var extraArgs = ProcessArgumentBuilder.Parse(ExtraArgs); var target = OutputAssembly; string projectDir; if (ProjectDir.StartsWith("~/", StringComparison.Ordinal)) { // Note: Since the Visual Studio plugin doesn't know the user's home directory on the Mac build host, // it simply uses paths relative to "~/". Expand these paths to their full path equivalents. var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); projectDir = Path.Combine(home, ProjectDir.Substring(2)); } else { projectDir = ProjectDir; } var customTags = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase) { { "projectdir", projectDir }, // Apparently msbuild doesn't propagate the solution path, so we can't get it. // { "solutiondir", proj.ParentSolution != null ? proj.ParentSolution.BaseDirectory : proj.BaseDirectory }, { "targetpath", Path.Combine(Path.GetDirectoryName(target), Path.GetFileName(target)) }, { "targetdir", Path.GetDirectoryName(target) }, { "targetname", Path.GetFileName(target) }, { "targetext", Path.GetExtension(target) }, }; for (int i = 0; i < extraArgs.Length; i++) { var argument = extraArgs[i]; cmd.AppendTextUnquoted(StringParserService.Parse(argument, customTags)); } } return(cmd.ToString()); }
/// <summary> /// Gets the MSBuild command-line based on the current properties of this object. /// </summary> /// <param name="useShortSwitchNames"><code>true</code> to use short command-line argument switches like '/nr' instead of '/NodeReuse', otherwise <code>false</code>.</param> /// <returns></returns> public string ToString(bool useShortSwitchNames) { CommandLineBuilder commandLineBuilder = new CommandLineBuilder(); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "t" : "Target")}:", Targets); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "p" : "Property")}:", Properties); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "m" : "MaxCpuCount")}:", MaxCpuCount, minValue: 1); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "tv" : "ToolsVersion")}:", ToolsVersion); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "v" : "Verbosity")}:", Verbosity); commandLineBuilder.AppendSwitchIfNotNullOrEmpty($"/{(useShortSwitchNames ? "val" : "Validate")}:", Validate); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "ignore" : "IgnoreProjectExtensions")}:", IgnoreProjectExtensions); if (ConsoleLoggerParameters != null) { commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "clp" : "ConsoleLoggerParameters")}:", ConsoleLoggerParameters.ToString(useShortSwitchNames)); } commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "dfl" : "DistributedFileLogger")}", DistributedFileLogger); foreach (MSBuildLoggerParameters logger in Loggers) { commandLineBuilder.AppendSwitch($"\"/{(useShortSwitchNames ? "l" : "Logger")}:{logger}\""); } commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "nr" : "NodeReuse")}:", NodeReuse); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "noconlog" : "NoConsoleLogger")}", NoConsoleLogger); for (int i = 0; i < FileLoggers.Count; i++) { string index = FileLoggers.Count > 1 ? i.ToString() : String.Empty; commandLineBuilder.AppendSwitch($"/{(useShortSwitchNames ? "fl" : "FileLogger")}{index}"); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "flp" : "FileLoggerParameters")}{index}:", FileLoggers[i].ToString(useShortSwitchNames)); } foreach (MSBuildDistributedLoggerParameters distributedLogger in DistributedLoggers) { commandLineBuilder.AppendSwitch($"\"/{(useShortSwitchNames ? "dl" : "DistributedLogger")}:{distributedLogger}\""); } if (BinaryLogger != null) { commandLineBuilder.AppendSwitch($"/{(useShortSwitchNames ? "bl" : "BinaryLogger")}{BinaryLogger}"); } commandLineBuilder.AppendSwitchIfNotNullOrEmpty($"/{(useShortSwitchNames ? "pp" : "PreProcess")}:", PreProcess); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "ds" : "DetailedSummary")}", DetailedSummary); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "noautorsp" : "NoAutoResponse")}", NoAutoResponse); commandLineBuilder.AppendSwitchIfTrue("/NoLogo", NoLogo); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "ver" : "Version")}", Version); foreach (string responseFile in ResponseFiles.Where(i => !String.IsNullOrWhiteSpace(i))) { commandLineBuilder.AppendSwitch("@"); commandLineBuilder.AppendTextUnquoted($"\"{responseFile}\""); } commandLineBuilder.AppendFileNameIfNotNull(Project); return(commandLineBuilder.ToString()); }
bool DoExecute() { var results = new List <ITaskItem> (); string bundlepath = Path.Combine(TempOutputPath, "bundles"); if (!Directory.Exists(bundlepath)) { Directory.CreateDirectory(bundlepath); } else { Directory.Delete(bundlepath, true); } foreach (var abi in SupportedAbis) { AndroidTargetArch arch = AndroidTargetArch.Other; switch (abi) { case "arm64": case "arm64-v8a": case "aarch64": arch = AndroidTargetArch.Arm64; break; case "armeabi-v7a": arch = AndroidTargetArch.Arm; break; case "x86": arch = AndroidTargetArch.X86; break; case "x86_64": arch = AndroidTargetArch.X86_64; break; case "mips": arch = AndroidTargetArch.Mips; break; } if (!NdkUtil.ValidateNdkPlatform(Log, AndroidNdkDirectory, arch, enableLLVM: false)) { return(false); } int level = NdkUtil.GetMinimumApiLevelFor(arch, AndroidNdkDirectory); var outpath = Path.Combine(bundlepath, abi); if (!Directory.Exists(outpath)) { Directory.CreateDirectory(outpath); } var clb = new CommandLineBuilder(); clb.AppendSwitch("--dos2unix=false"); clb.AppendSwitch("--nomain"); clb.AppendSwitch("--i18n none"); clb.AppendSwitch("--bundled-header"); clb.AppendSwitch("--mono-api-struct-path"); clb.AppendFileNameIfNotNull(BundleApiPath); clb.AppendSwitch("--style"); clb.AppendSwitch("linux"); clb.AppendSwitch("-c"); clb.AppendSwitch("-o"); clb.AppendFileNameIfNotNull(Path.Combine(outpath, "temp.c")); clb.AppendSwitch("-oo"); clb.AppendFileNameIfNotNull(Path.Combine(outpath, "assemblies.o")); if (AutoDeps) { clb.AppendSwitch("--autodeps"); } if (KeepTemp) { clb.AppendSwitch("--keeptemp"); } clb.AppendSwitch("-z"); // Compress clb.AppendFileNamesIfNotNull(Assemblies, " "); var psi = new ProcessStartInfo() { FileName = MkbundlePath, Arguments = clb.ToString(), UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, }; string windowsCompilerSwitches = NdkUtil.GetCompilerTargetParameters(AndroidNdkDirectory, arch, level); var compilerNoQuotes = NdkUtil.GetNdkTool(AndroidNdkDirectory, arch, "gcc", level); var compiler = $"\"{compilerNoQuotes}\" {windowsCompilerSwitches}".Trim(); var gas = '"' + NdkUtil.GetNdkTool(AndroidNdkDirectory, arch, "as", level) + '"'; psi.EnvironmentVariables ["CC"] = compiler; psi.EnvironmentVariables ["AS"] = gas; Log.LogDebugMessage("CC=" + compiler); Log.LogDebugMessage("AS=" + gas); //psi.EnvironmentVariables ["PKG_CONFIG_PATH"] = Path.Combine (Path.GetDirectoryName (MonoDroidSdk.MandroidTool), "lib", abi); Log.LogDebugMessage("[mkbundle] " + psi.FileName + " " + clb); var proc = new Process(); proc.OutputDataReceived += OnMkbundleOutputData; proc.ErrorDataReceived += OnMkbundleErrorData; proc.StartInfo = psi; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); if (proc.ExitCode != 0) { Log.LogCodedError("XA5102", Properties.Resources.XA5102, proc.ExitCode); return(false); } // then compile temp.c into temp.o and ... clb = new CommandLineBuilder(); // See NdkUtils.GetNdkTool for reasons why if (!String.IsNullOrEmpty(windowsCompilerSwitches)) { clb.AppendTextUnquoted(windowsCompilerSwitches); } clb.AppendSwitch("-c"); // This is necessary only when unified headers are in use but it won't hurt to have it // defined even if we don't use them clb.AppendSwitch($"-D__ANDROID_API__={level}"); // This is necessary because of the injected code, which is reused between libmonodroid // and the bundle clb.AppendSwitch("-DANDROID"); clb.AppendSwitch("-o"); clb.AppendFileNameIfNotNull(Path.Combine(outpath, "temp.o")); if (!string.IsNullOrWhiteSpace(IncludePath)) { clb.AppendSwitch("-I"); clb.AppendFileNameIfNotNull(IncludePath); } string asmIncludePath = NdkUtil.GetNdkAsmIncludePath(AndroidNdkDirectory, arch, level); if (!String.IsNullOrEmpty(asmIncludePath)) { clb.AppendSwitch("-I"); clb.AppendFileNameIfNotNull(asmIncludePath); } clb.AppendSwitch("-I"); clb.AppendFileNameIfNotNull(NdkUtil.GetNdkPlatformIncludePath(AndroidNdkDirectory, arch, level)); clb.AppendFileNameIfNotNull(Path.Combine(outpath, "temp.c")); Log.LogDebugMessage("[CC] " + compiler + " " + clb); if (MonoAndroidHelper.RunProcess(compilerNoQuotes, clb.ToString(), OnCcOutputData, OnCcErrorData) != 0) { Log.LogCodedError("XA5103", Properties.Resources.XA5103, proc.ExitCode); return(false); } // ... link temp.o and assemblies.o into app.so clb = new CommandLineBuilder(); clb.AppendSwitch("--shared"); clb.AppendFileNameIfNotNull(Path.Combine(outpath, "temp.o")); clb.AppendFileNameIfNotNull(Path.Combine(outpath, "assemblies.o")); // API23+ requires that the shared library has its soname set or it won't load clb.AppendSwitch("-soname"); clb.AppendSwitch(BundleSharedLibraryName); clb.AppendSwitch("-o"); clb.AppendFileNameIfNotNull(Path.Combine(outpath, BundleSharedLibraryName)); clb.AppendSwitch("-L"); clb.AppendFileNameIfNotNull(NdkUtil.GetNdkPlatformLibPath(AndroidNdkDirectory, arch, level)); clb.AppendSwitch("-lc"); clb.AppendSwitch("-lm"); clb.AppendSwitch("-ldl"); clb.AppendSwitch("-llog"); clb.AppendSwitch("-lz"); // Compress string ld = NdkUtil.GetNdkTool(AndroidNdkDirectory, arch, "ld", level); Log.LogMessage(MessageImportance.Normal, "[LD] " + ld + " " + clb); if (MonoAndroidHelper.RunProcess(ld, clb.ToString(), OnLdOutputData, OnLdErrorData) != 0) { Log.LogCodedError("XA5201", Properties.Resources.XA5201, proc.ExitCode); return(false); } results.Add(new TaskItem(Path.Combine(outpath, "libmonodroid_bundle_app.so"))); } OutputNativeLibraries = results.ToArray(); return(true); }
private void GenerateTemplatedCommandLine(CommandLineBuilder builder) { // Match all instances of [asdf], where "asdf" can be any combination of any // characters *except* a [ or an ]. i.e., if "[ [ sdf ]" is passed, then we will // match "[ sdf ]" string matchString = @"\[[^\[\]]+\]"; Regex regex = new Regex(matchString, RegexOptions.ECMAScript); MatchCollection matches = regex.Matches(CommandLineTemplate); int indexOfEndOfLastSubstitution = 0; foreach (Match match in matches) { if (match.Length == 0) { continue; } // Because we match non-greedily, in the case where we have input such as "[[[[[foo]", the match will // be "[foo]". However, if there are multiple '[' in a row, we need to do some escaping logic, so we // want to know what the first *consecutive* square bracket was. int indexOfFirstBracketInMatch = match.Index; // Indexing using "indexOfFirstBracketInMatch - 1" is safe here because it will always be // greater than indexOfEndOfLastSubstitution, which will always be 0 or greater. while (indexOfFirstBracketInMatch > indexOfEndOfLastSubstitution && CommandLineTemplate[indexOfFirstBracketInMatch - 1].Equals('[')) { indexOfFirstBracketInMatch--; } // Append everything we know we want to add -- everything between where the last substitution ended and // this match (including previous '[' that were not initially technically part of the match) begins. if (indexOfFirstBracketInMatch != indexOfEndOfLastSubstitution) { builder.AppendTextUnquoted(CommandLineTemplate.Substring(indexOfEndOfLastSubstitution, indexOfFirstBracketInMatch - indexOfEndOfLastSubstitution)); } // Now replace every "[[" with a literal '['. We can do this by simply counting the number of '[' between // the first one and the start of the match, since by definition everything in between is an '['. // + 1 because match.Index is also a bracket. int openBracketsInARow = match.Index - indexOfFirstBracketInMatch + 1; if (openBracketsInARow % 2 == 0) { // even number -- they all go away and the rest of the match is appended literally. for (int i = 0; i < openBracketsInARow / 2; i++) { builder.AppendTextUnquoted("["); } builder.AppendTextUnquoted(match.Value.Substring(1, match.Value.Length - 1)); } else { // odd number -- all but one get merged two at a time, and the rest of the match is substituted. for (int i = 0; i < (openBracketsInARow - 1) / 2; i++) { builder.AppendTextUnquoted("["); } // Determine which property the user has specified in the template. string propertyName = match.Value.Substring(1, match.Value.Length - 2); if (String.Equals(propertyName, "AllOptions", StringComparison.OrdinalIgnoreCase)) { // When [AllOptions] is specified, we append all switch-type options. CommandLineBuilder tempBuilder = new CommandLineBuilder(true); GenerateStandardCommandLine(tempBuilder, true); builder.AppendTextUnquoted(tempBuilder.ToString()); } else if (String.Equals(propertyName, "AdditionalOptions", StringComparison.OrdinalIgnoreCase)) { BuildAdditionalArgs(builder); } else if (IsPropertySet(propertyName)) { CommandLineToolSwitch property = _activeCommandLineToolSwitches[propertyName]; // verify the dependencies if (VerifyDependenciesArePresent(property) && VerifyRequiredArgumentsArePresent(property, false)) { CommandLineBuilder tempBuilder = new CommandLineBuilder(true); GenerateCommandsAccordingToType(tempBuilder, property, false); builder.AppendTextUnquoted(tempBuilder.ToString()); } } else if (!PropertyExists(propertyName)) { // If the thing enclosed in square brackets is not in fact a property, we // don't want to replace it. builder.AppendTextUnquoted('[' + propertyName + ']'); } } indexOfEndOfLastSubstitution = match.Index + match.Length; } builder.AppendTextUnquoted(CommandLineTemplate.Substring(indexOfEndOfLastSubstitution, CommandLineTemplate.Length - indexOfEndOfLastSubstitution)); }
private void GenerateTemplatedCommandLine(CommandLineBuilder builder) { string pattern = @"\[[^\[\]]+\]"; MatchCollection matchs = new Regex(pattern, RegexOptions.ECMAScript).Matches(this.CommandLineTemplate); int startIndex = 0; foreach (Match match in matchs) { if (match.Length == 0) { continue; } int index = match.Index; goto Label_0059; Label_0053: index--; Label_0059: if (index > startIndex) { char ch = this.CommandLineTemplate[index - 1]; if (ch.Equals('[')) { goto Label_0053; } } if (index != startIndex) { builder.AppendTextUnquoted(this.CommandLineTemplate.Substring(startIndex, index - startIndex)); } int num3 = (match.Index - index) + 1; if ((num3 % 2) == 0) { for (int i = 0; i < (num3 / 2); i++) { builder.AppendTextUnquoted("["); } builder.AppendTextUnquoted(match.Value.Substring(1, match.Value.Length - 1)); } else { for (int j = 0; j < ((num3 - 1) / 2); j++) { builder.AppendTextUnquoted("["); } string a = match.Value.Substring(1, match.Value.Length - 2); if (string.Equals(a, "AllOptions", StringComparison.OrdinalIgnoreCase)) { CommandLineBuilder builder2 = new CommandLineBuilder(true); this.GenerateStandardCommandLine(builder2, true); builder.AppendTextUnquoted(builder2.ToString()); } else if (string.Equals(a, "AdditionalOptions", StringComparison.OrdinalIgnoreCase)) { this.BuildAdditionalArgs(builder); } else if (this.IsPropertySet(a)) { CommandLineToolSwitch property = this.activeCommandLineToolSwitches[a]; if (this.VerifyDependenciesArePresent(property) && this.VerifyRequiredArgumentsArePresent(property, false)) { CommandLineBuilder clb = new CommandLineBuilder(true); this.GenerateCommandsAccordingToType(clb, property, false); builder.AppendTextUnquoted(clb.ToString()); } } else if (!this.PropertyExists(a)) { builder.AppendTextUnquoted('[' + a + ']'); } } startIndex = match.Index + match.Length; } builder.AppendTextUnquoted(this.CommandLineTemplate.Substring(startIndex, this.CommandLineTemplate.Length - startIndex)); }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { const string errorReturnValue = ""; if (false == ValidateInputAssemblies() || false == ValidateOutputFile()) { return(errorReturnValue); } #region " ILMerge.exe Command-Line Arguments " /* * [/lib:directory]* * [/log[:filename]] * [/keyfile:filename [/delaysign]] * [/internalize[:filename]] * [/t[arget]:(library|exe|winexe)] * [/closed] * [/ndebug] * [/ver:version] * [/copyattrs [/allowMultiple]] * [/xmldocs] * [/attr:filename] * ([/targetplatform:<version>[,<platformdir>]]|v1|v1.1|v2|v4) * [/useFullPublicKeyForReferences] * [/zeroPeKind] * [/wildcards] * [/allowDup[:typename]]* * [/allowDuplicateResources] * [/union] * [/align:n] * /out:filename * <primary assembly> [<other assemblies>...] */ #endregion " ILMerge.exe Command-Line Arguments " var builder = new CommandLineBuilder(); if (null != DuplicateTypeNames && DuplicateTypeNames.Length > 0) { foreach (var item in DuplicateTypeNames) { var typeName = item.ItemSpec; builder.AppendSwitch(string.Format("/allowDup:{0}", typeName.Trim())); } } else if (AllowDuplicateTypeNames) { builder.AppendSwitch("/allowDup"); } if (AllowMultipleAssemblyLevelAttributes) { builder.AppendSwitch("/allowMultiple"); } if (AllowWildCards) { builder.AppendSwitch("/wildcards"); } if (AllowZeroPeKind) { builder.AppendSwitch("/zeroPeKind"); } if (false == string.IsNullOrWhiteSpace(AttributeFile)) { builder.AppendSwitch(string.Format("/attr:\"{0}\"", AttributeFile.Trim())); } if (Closed) { builder.AppendSwitch("/closed"); } if (CopyAttributes) { builder.AppendSwitch("/copyattrs"); } if (false == DebugInfo) { builder.AppendSwitch("/ndebug"); } if (DelaySign) { builder.AppendSwitch("/delaysign"); } if (FileAlignment != DefaultFileAlignment) { builder.AppendSwitch(string.Format("/align:{0}", FileAlignment)); } if (Internalize) { builder.AppendSwitch(string.Format("/internalize{0}", string.IsNullOrWhiteSpace(ExcludeFile) ? "" : string.Format(":\"{0}\"", ExcludeFile.Trim()))); } if (false == string.IsNullOrWhiteSpace(KeyFile)) { builder.AppendSwitch(string.Format("/keyfile:\"{0}\"", KeyFile.Trim())); } if (false == string.IsNullOrWhiteSpace(LogFile)) { builder.AppendSwitch(string.Format("/log:\"{0}\"", LogFile.Trim())); } if (false == PublicKeyTokens) { builder.AppendSwitch("/useFullPublicKeyForReferences"); } if (null != SearchDirectories && SearchDirectories.Length > 0) { foreach (var item in SearchDirectories) { var directory = item.ItemSpec; builder.AppendSwitch(string.Format("/lib:\"{0}\"", directory.Trim())); } } // Target Platform if (false == string.IsNullOrWhiteSpace(TargetPlatformDirectory) && false == string.IsNullOrWhiteSpace(TargetPlatformVersion)) { var value = string.Format("{0},\"{1}\"", TargetPlatformVersion.Trim().ToLowerInvariant(), TargetPlatformDirectory.Trim()); builder.AppendSwitch(string.Format("/targetplatform:{0}", value)); } if (false == string.IsNullOrWhiteSpace(TargetType)) { builder.AppendSwitch(string.Format("/target:{0}", TargetType.Trim().ToLowerInvariant())); } if (UnionMerge) { builder.AppendSwitch("/union"); } if (XmlDocumentation) { builder.AppendSwitch("/xmldocs"); } if (false == string.IsNullOrWhiteSpace(Version)) { builder.AppendSwitch(string.Format("/ver:{0}", Version.Trim())); } // OutputFile is added after all other switches and before the InputAssemblies. builder.AppendSwitch(string.Format("/out:\"{0}\"", OutputFile)); // InputAssemblies must be added after all other switches. if (null != InputAssemblies && InputAssemblies.Length > 0) { foreach (var inputAssemblyPath in InputAssemblies) { builder.AppendTextUnquoted(string.Format(" \"{0}\"", inputAssemblyPath)); } } return(builder.ToString()); }