protected string GenerateCommandLineCommands(string ManifestFile, string currentAbi, string currentResourceOutputFile) { // For creating Resource.Designer.cs: // Running command: C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt // "package" // "-M" "C:\Users\Jonathan\AppData\Local\Temp\ryob4gaw.way\AndroidManifest.xml" // "-J" "C:\Users\Jonathan\AppData\Local\Temp\ryob4gaw.way" // "-F" "C:\Users\Jonathan\AppData\Local\Temp\ryob4gaw.way\resources.apk" // "-S" "c:\users\jonathan\documents\visual studio 2010\Projects\MonoAndroidApplication4\MonoAndroidApplication4\obj\Debug\res" // "-I" "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-8\android.jar" // "--max-res-version" "10" // For packaging: // Running command: C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt // "package" // "-f" // "-m" // "-M" "AndroidManifest.xml" // "-J" "src" // "--custom-package" "androidmsbuildtest.androidmsbuildtest" // "-F" "bin\packaged_resources" // "-S" "C:\Users\Jonathan\Documents\Visual Studio 2010\Projects\AndroidMSBuildTest\AndroidMSBuildTest\obj\Debug\res" // "-I" "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-8\android.jar" // "--extra-packages" "com.facebook.android:my.another.library" var cmd = new CommandLineBuilder(); cmd.AppendSwitch("package"); if (MonoAndroidHelper.LogInternalExceptions) { cmd.AppendSwitch("-v"); } if (NonConstantId) { cmd.AppendSwitch("--non-constant-id"); } cmd.AppendSwitch("-f"); cmd.AppendSwitch("-m"); string manifestFile; string manifestDir = Path.Combine(Path.GetDirectoryName(ManifestFile), currentAbi != null ? currentAbi : "manifest"); Directory.CreateDirectory(manifestDir); manifestFile = Path.Combine(manifestDir, Path.GetFileName(ManifestFile)); ManifestDocument manifest = new ManifestDocument(ManifestFile, this.Log); if (currentAbi != null) { manifest.SetAbi(currentAbi); } manifest.ApplicationName = ApplicationName; manifest.Save(manifestFile); cmd.AppendSwitchIfNotNull("-M ", manifestFile); Directory.CreateDirectory(JavaDesignerOutputDirectory); cmd.AppendSwitchIfNotNull("-J ", JavaDesignerOutputDirectory); if (PackageName != null) { cmd.AppendSwitchIfNotNull("--custom-package ", PackageName.ToLowerInvariant()); } if (!string.IsNullOrEmpty(currentResourceOutputFile)) { cmd.AppendSwitchIfNotNull("-F ", currentResourceOutputFile + ".bk"); } // The order of -S arguments is *important*, always make sure this one comes FIRST cmd.AppendSwitchIfNotNull("-S ", ResourceDirectory.TrimEnd('\\')); if (AdditionalResourceDirectories != null) { foreach (var resdir in AdditionalResourceDirectories) { cmd.AppendSwitchIfNotNull("-S ", resdir.ItemSpec.TrimEnd('\\')); } } if (AdditionalAndroidResourcePaths != null) { foreach (var dir in AdditionalAndroidResourcePaths) { cmd.AppendSwitchIfNotNull("-S ", Path.Combine(dir.ItemSpec.TrimEnd(System.IO.Path.DirectorySeparatorChar), "res")); } } if (LibraryProjectJars != null) { foreach (var jar in LibraryProjectJars) { cmd.AppendSwitchIfNotNull("-j ", jar); } } cmd.AppendSwitchIfNotNull("-I ", JavaPlatformJarPath); // Add asset directory if it exists if (!string.IsNullOrWhiteSpace(AssetDirectory) && Directory.Exists(AssetDirectory)) { cmd.AppendSwitchIfNotNull("-A ", AssetDirectory.TrimEnd('\\')); } if (!string.IsNullOrWhiteSpace(UncompressedFileExtensions)) { foreach (var ext in UncompressedFileExtensions.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries)) { cmd.AppendSwitchIfNotNull("-0 ", ext); } } if (!string.IsNullOrEmpty(ExtraPackages)) { cmd.AppendSwitchIfNotNull("--extra-packages ", ExtraPackages); } // TODO: handle resource names if (ExplicitCrunch) { cmd.AppendSwitch("--no-crunch"); } cmd.AppendSwitch("--auto-add-overlay"); var extraArgsExpanded = ExpandString(ExtraArgs); if (extraArgsExpanded != ExtraArgs) { Log.LogDebugMessage(" ExtraArgs expanded: {0}", extraArgsExpanded); } if (!string.IsNullOrWhiteSpace(extraArgsExpanded)) { cmd.AppendSwitch(extraArgsExpanded); } if (!AndroidUseLatestPlatformSdk) { cmd.AppendSwitchIfNotNull("--max-res-version ", ApiLevel); } return(cmd.ToString()); }
protected string GenerateCommandLineCommands(string ManifestFile, string currentAbi, string currentResourceOutputFile) { // For creating Resource.designer.cs: // Running command: C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt // "package" // "-M" "C:\Users\Jonathan\AppData\Local\Temp\ryob4gaw.way\AndroidManifest.xml" // "-J" "C:\Users\Jonathan\AppData\Local\Temp\ryob4gaw.way" // "-F" "C:\Users\Jonathan\AppData\Local\Temp\ryob4gaw.way\resources.apk" // "-S" "c:\users\jonathan\documents\visual studio 2010\Projects\MonoAndroidApplication4\MonoAndroidApplication4\obj\Debug\res" // "-I" "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-8\android.jar" // "--max-res-version" "10" // For packaging: // Running command: C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt // "package" // "-f" // "-m" // "-M" "AndroidManifest.xml" // "-J" "src" // "--custom-package" "androidmsbuildtest.androidmsbuildtest" // "-F" "bin\packaged_resources" // "-S" "C:\Users\Jonathan\Documents\Visual Studio 2010\Projects\AndroidMSBuildTest\AndroidMSBuildTest\obj\Debug\res" // "-I" "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-8\android.jar" // "--extra-packages" "com.facebook.android:my.another.library" var cmd = new CommandLineBuilder(); cmd.AppendSwitch("package"); if (MonoAndroidHelper.LogInternalExceptions) { cmd.AppendSwitch("-v"); } if (NonConstantId) { cmd.AppendSwitch("--non-constant-id"); } cmd.AppendSwitch("-f"); cmd.AppendSwitch("-m"); string manifestFile; string manifestDir = Path.Combine(Path.GetDirectoryName(ManifestFile), currentAbi != null ? currentAbi : "manifest"); Directory.CreateDirectory(manifestDir); manifestFile = Path.Combine(manifestDir, Path.GetFileName(ManifestFile)); ManifestDocument manifest = new ManifestDocument(ManifestFile); manifest.SdkVersion = AndroidSdkPlatform; if (!string.IsNullOrEmpty(VersionCodePattern)) { try { manifest.CalculateVersionCode(currentAbi, VersionCodePattern, VersionCodeProperties); } catch (ArgumentOutOfRangeException ex) { LogCodedError("XA0003", ManifestFile, 0, ex.Message); return(string.Empty); } } if (currentAbi != null && string.IsNullOrEmpty(VersionCodePattern)) { manifest.SetAbi(currentAbi); } if (!manifest.ValidateVersionCode(out string error, out string errorCode)) { LogCodedError(errorCode, ManifestFile, 0, error); return(string.Empty); } manifest.ApplicationName = ApplicationName; manifest.Save(LogCodedWarning, manifestFile); cmd.AppendSwitchIfNotNull("-M ", manifestFile); var designerDirectory = Path.IsPathRooted(JavaDesignerOutputDirectory) ? JavaDesignerOutputDirectory : Path.Combine(WorkingDirectory, JavaDesignerOutputDirectory); Directory.CreateDirectory(designerDirectory); cmd.AppendSwitchIfNotNull("-J ", JavaDesignerOutputDirectory); if (PackageName != null) { cmd.AppendSwitchIfNotNull("--custom-package ", PackageName.ToLowerInvariant()); } if (!string.IsNullOrEmpty(currentResourceOutputFile)) { cmd.AppendSwitchIfNotNull("-F ", currentResourceOutputFile + ".bk"); } // The order of -S arguments is *important*, always make sure this one comes FIRST cmd.AppendSwitchIfNotNull("-S ", resourceDirectory.TrimEnd('\\')); if (AdditionalResourceDirectories != null) { foreach (var dir in AdditionalResourceDirectories) { var resdir = dir.ItemSpec.TrimEnd('\\'); if (Directory.Exists(resdir)) { cmd.AppendSwitchIfNotNull("-S ", resdir); } } } if (AdditionalAndroidResourcePaths != null) { foreach (var dir in AdditionalAndroidResourcePaths) { var resdir = Path.Combine(dir.ItemSpec, "res"); if (Directory.Exists(resdir)) { cmd.AppendSwitchIfNotNull("-S ", resdir); } } } if (LibraryProjectJars != null) { foreach (var jar in LibraryProjectJars) { cmd.AppendSwitchIfNotNull("-j ", jar); } } cmd.AppendSwitchIfNotNull("-I ", JavaPlatformJarPath); // Add asset directory if it exists if (!string.IsNullOrWhiteSpace(AssetDirectory)) { var assetDir = AssetDirectory.TrimEnd('\\'); if (!Path.IsPathRooted(assetDir)) { assetDir = Path.Combine(WorkingDirectory, assetDir); } if (!string.IsNullOrWhiteSpace(assetDir) && Directory.Exists(assetDir)) { cmd.AppendSwitchIfNotNull("-A ", assetDir); } } if (!string.IsNullOrWhiteSpace(UncompressedFileExtensions)) { foreach (var ext in UncompressedFileExtensions.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries)) { cmd.AppendSwitchIfNotNull("-0 ", ext.StartsWith(".", StringComparison.OrdinalIgnoreCase) ? ext : $".{ext}"); } } if (!string.IsNullOrEmpty(ExtraPackages)) { cmd.AppendSwitchIfNotNull("--extra-packages ", ExtraPackages); } cmd.AppendSwitch("--auto-add-overlay"); if (!string.IsNullOrEmpty(ResourceSymbolsTextFileDirectory)) { cmd.AppendSwitchIfNotNull("--output-text-symbols ", ResourceSymbolsTextFileDirectory); } var extraArgsExpanded = ExpandString(ExtraArgs); if (extraArgsExpanded != ExtraArgs) { LogDebugMessage(" ExtraArgs expanded: {0}", extraArgsExpanded); } if (!string.IsNullOrWhiteSpace(extraArgsExpanded)) { cmd.AppendSwitch(extraArgsExpanded); } if (!AndroidUseLatestPlatformSdk) { cmd.AppendSwitchIfNotNull("--max-res-version ", ApiLevel); } return(cmd.ToString()); }