Ejemplo n.º 1
0
 private void ImportCertificateButton3_Click(object sender, EventArgs e)
 {
     ToolsHub.TryInstallingCertificate_PromptForKey(null);
     RefreshProvisionsList();
 }
Ejemplo n.º 2
0
 private void ImportProvisionButton3_Click(object sender, EventArgs e)
 {
     ToolsHub.TryInstallingMobileProvision(null);
     RefreshProvisionsList();
 }
Ejemplo n.º 3
0
        private static bool CheckArguments()
        {
            if (GameConfiguration.Length == 0)
            {
                GameConfiguration = "GameConfigurationWasNotSpecifiedToIPP";
            }

            if (GameName.Length == 0)
            {
                Error( "Invalid number of arguments" );
                return false;
            }

            if (Config.bCreateStubSet && Config.bForDistribution)
            {
                Error("-createstub and -distribution are mutually exclusive");
                return false;
            }

            // If -sign was specified, check to see if the user has configured yet.  If not, we will pop up a configuration dialog
            if (Config.bPerformResignWhenRepackaging && Config.bAllowInteractiveDialogsDuringNonInteractiveCommands)
            {
                string CWD = Directory.GetCurrentDirectory();
                if (!CodeSignatureBuilder.DoRequiredFilesExist())
                {
                    StartVisuals();

                    Form DisplayForm = new ToolsHub();
                    Application.Run(DisplayForm);
                    if (DisplayForm.DialogResult != DialogResult.OK)
                    {
                        Error("One or more files necessary for packaging are missing and configuration was cancelled");
                        return false;
                    }
                }
                Directory.SetCurrentDirectory(CWD);
            }

            return true;
        }
Ejemplo n.º 4
0
        static int Main(string[] args)
        {
            // remember the working directory at start, as the game path could be relative to this path
            string InitialCurrentDirectory = Environment.CurrentDirectory;

            // set the working directory to the location of the application (so relative paths always work)
            Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            // A simple, top-level try-catch block
            try
            {
                if (!ParseCommandLine(ref args))
                {
                    Log("Usage: iPhonePackager <Command> <GameName> [RPCCommand &| Switch]");
                    Log("");
                    Log("Common commands:");
                    Log(" ... RepackageIPA GameName");
                    Log(" ... PackageIPA GameName");
                    Log(" ... PackageApp GameName");
                    Log(" ... Deploy PathToIPA");
                    Log(" ... RepackageFromStage GameName");
                    Log(" ... Devices");
                    Log(" ... Validate");
                    Log(" ... Install");
                    Log("");
                    Log("Configuration switches:");
                    Log("	 -stagedir <path>		  sets the directory to copy staged files from (defaults to none)");
                    Log("	 -project <path>		  path to the project being packaged");
                    Log("	 -compress=fast|best|none  packaging compression level (defaults to none)");
                    Log("	 -strip					strip symbols during packaging");
                    Log("	 -config				   game configuration (e.g., Shipping, Development, etc...)");
                    Log("	 -distribution			 packaging for final distribution");
                    Log("	 -createstub			   packaging stub IPA for later repackaging");
                    Log("	 -mac <MacName>			overrides the machine to use for any Mac operations");
                    Log("	 -arch <Architecture>	  sets the architecture to use (blank for default, -simulator for simulator builds)");
                    Log("	 -device <DeviceID>		sets the device to install the IPA on");
                    Log("");
                    Log("Commands: RPC, Clean");
                    Log("  StageMacFiles, GetIPA, Deploy, Install, Uninstall");
                    Log("");
                    Log("RPC Commands: SetExec, InstallProvision, MakeApp, DeleteIPA, Copy, Kill, Strip, Zip, GenDSYM");
                    Log("");
                    Log("Sample commandlines:");
                    Log(" ... iPhonePackager Deploy UDKGame Release");
                    Log(" ... iPhonePackager RPC SwordGame Shipping MakeApp");
                    return((int)ErrorCodes.Error_Arguments);
                }

                Log("Executing iPhonePackager " + String.Join(" ", args));
                Log("CWD: " + Directory.GetCurrentDirectory());
                Log("Initial Dir: " + InitialCurrentDirectory);
                Log("Env CWD: " + Environment.CurrentDirectory);

                // Ensure shipping configuration for final distributions
                if (Config.bForDistribution && (GameConfiguration != "Shipping"))
                {
                    Program.Warning("Distribution builds should be made in the Shipping configuration!");
                }

                // process the GamePath (if could be ..\Samples\MyDemo\ or ..\Samples\MyDemo\MyDemo.uproject
                GameName = Path.GetFileNameWithoutExtension(GamePath);
                if (GameName.Equals("UE4", StringComparison.InvariantCultureIgnoreCase) || GameName.Equals("Engine", StringComparison.InvariantCultureIgnoreCase))
                {
                    GameName = "UE4Game";
                }

                // setup configuration
                if (!Config.Initialize(InitialCurrentDirectory, GamePath))
                {
                    return((int)ErrorCodes.Error_Arguments);
                }

                switch (MainCommand.ToLowerInvariant())
                {
                case "validate":
                    // check to see if iTunes is installed
                    string dllPath = "";
                    if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        dllPath = "/Applications/Xcode.app/Contents/MacOS/Xcode";
                    }
                    else
                    {
                        dllPath = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Apple Inc.\\Apple Mobile Device Support\\Shared", "iTunesMobileDeviceDLL", null) as string;
                        if (String.IsNullOrEmpty(dllPath) || !File.Exists(dllPath))
                        {
                            dllPath = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Apple Inc.\\Apple Mobile Device Support\\Shared", "MobileDeviceDLL", null) as string;
                        }
                    }
                    if (String.IsNullOrEmpty(dllPath) || !File.Exists(dllPath))
                    {
                        Error("iTunes Not Found!!", (int)ErrorCodes.Error_SDKNotFound);
                    }
                    else
                    {
                        // validate there is a useable provision and cert
                        MobileProvision  Provision;
                        X509Certificate2 Cert;
                        bool             bHasOverrides;
                        bool             bNameMatch;
                        bool             foundPlist = CodeSignatureBuilder.FindRequiredFiles(out Provision, out Cert, out bHasOverrides, out bNameMatch);
                        if (!foundPlist)
                        {
                            Error("Could not find a valid plist file!!", (int)ErrorCodes.Error_InfoPListNotFound);
                        }
                        else if (Provision == null && Cert == null)
                        {
                            Error("No Provision or cert found!!", (int)ErrorCodes.Error_ProvisionAndCertificateNotFound);
                        }
                        else if (Provision == null)
                        {
                            Error("No Provision found!!", (int)ErrorCodes.Error_ProvisionNotFound);
                        }
                        else if (Cert == null)
                        {
                            Error("No Signing Certificate found!!", (int)ErrorCodes.Error_CertificateNotFound);
                        }
                    }
                    break;

                case "packageapp":
                    if (CheckArguments())
                    {
                        if (Config.bCreateStubSet)
                        {
                            Error("packageapp cannot be used with the -createstub switch");
                            Program.ReturnCode = (int)ErrorCodes.Error_Arguments;
                        }
                        else
                        {
                            // Create the .app on the Mac
                            CompileTime.CreateApplicationDirOnMac();
                        }
                    }
                    break;

                case "repackagefromstage":
                    if (CheckArguments())
                    {
                        if (Config.bCreateStubSet)
                        {
                            Error("repackagefromstage cannot be used with the -createstub switches");
                            Program.ReturnCode = (int)ErrorCodes.Error_Arguments;
                        }
                        else
                        {
                            bool bProbablyCreatedStub = Utilities.GetEnvironmentVariable("ue.IOSCreateStubIPA", true);
                            if (!bProbablyCreatedStub)
                            {
                                Warning("ue.IOSCreateStubIPA is currently FALSE, which means you may be repackaging with an out of date stub IPA!");
                            }

                            CookTime.RepackageIPAFromStub();
                        }
                    }
                    break;

                // this is the "super fast just move executable" mode for quick programmer iteration
                case "dangerouslyfast":
                    if (CheckArguments())
                    {
                        CompileTime.DangerouslyFastMode();
                    }
                    break;

                case "packageipa":
                    if (CheckArguments())
                    {
                        CompileTime.PackageIPAOnMac();
                    }
                    break;

                case "install":
                    GameName = "";
                    if (Config.bProvision)
                    {
                        ToolsHub.TryInstallingMobileProvision(Config.Provision, false);
                    }
                    if (Config.bCert)
                    {
                        ToolsHub.TryInstallingCertificate_PromptForKey(Config.Certificate, false);
                    }
                    CodeSignatureBuilder.FindCertificates();
                    CodeSignatureBuilder.FindProvisions(Config.OverrideBundleName);
                    break;

                case "certificates":
                {
                    CodeSignatureBuilder.FindCertificates();
                    CodeSignatureBuilder.FindProvisions(Config.OverrideBundleName);
                }
                break;

                case "resigntool":
                    RunInVisualMode(delegate { return(new GraphicalResignTool()); });
                    break;

                case "certrequest":
                    RunInVisualMode(delegate { return(new GenerateSigningRequestDialog()); });
                    break;

                case "gui":
                    RunInVisualMode(delegate { return(ToolsHub.CreateShowingTools()); });
                    break;

                case "devices":
                    ListDevices();
                    break;

                case "signing_match":
                {
                    MobileProvision  Provision;
                    X509Certificate2 Cert;
                    bool             bNameMatch;
                    bool             bHasOverrideFile;
                    if (CodeSignatureBuilder.FindRequiredFiles(out Provision, out Cert, out bHasOverrideFile, out bNameMatch))
                    {
                        // print out the provision and cert name
                        Program.LogVerbose("CERTIFICATE-{0},PROVISION-{1}", Cert.FriendlyName, Path.GetFileName(Provision.FileName));
                    }
                    else
                    {
                        Program.LogVerbose("No matching Signing Data found!");
                    }
                }
                break;

                default:
                    // Commands by themself default to packaging for the device
                    if (CheckArguments())
                    {
                        ExecuteCommand(MainCommand, MainRPCCommand);
                    }
                    break;
                }
            }
            catch (Exception Ex)
            {
                Error("Application exception: " + Ex.ToString());
                if (ReturnCode == 0)
                {
                    Program.ReturnCode = (int)ErrorCodes.Error_Unknown;
                }
            }
            finally
            {
                if (DeploymentHelper.DeploymentServerProcess != null)
                {
                    DeploymentHelper.DeploymentServerProcess.Close();
                }
            }

            Environment.ExitCode = ReturnCode;
            return(ReturnCode);
        }
Ejemplo n.º 5
0
        static private bool ParseCommandLine(ref string[] Arguments)
        {
            if (Arguments.Length == 0)
            {
                StartVisuals();

                // we NEED a project, so show a uproject picker
                string UProjectFile;
                string StartingDir = "";
                if (ToolsHub.ShowOpenFileDialog("Unreal Project Files (*.uproject)|*.uproject;", "IPhonePackager now requires a .uproject file for certificate/provisioning setup", "mobileprovision", "", ref StartingDir, out UProjectFile))
                {
                    Arguments = new string[] { UProjectFile };
                }
                else
                {
                    Arguments = new string[] { "gui" };
                }
            }

            if (Arguments.Length == 1)
            {
                // if the only argument is a uproject, then assume gui mode, with the uproject as the project
                if (Arguments[0].EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath = Arguments[0];

                    MainCommand = "gui";
                }
                else
                {
                    MainCommand = Arguments[0];
                }
            }
            else if (Arguments.Length == 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];
                if (GamePath.EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath;
                }
            }
            else if (Arguments.Length >= 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];
                if (GamePath.EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath;
                }

                for (int ArgIndex = 2; ArgIndex < Arguments.Length; ArgIndex++)
                {
                    string Arg = Arguments[ArgIndex].ToLowerInvariant();

                    if (Arg.StartsWith("-"))
                    {
                        // Behavior switches
                        switch (Arg)
                        {
                        case "-verbose":
                            Config.bVerbose = true;
                            break;

                        case "-strip":
                            Config.bForceStripSymbols = true;
                            break;

                        case "-compress=best":
                            Config.RecompressionSetting = (int)CompressionLevel.BestCompression;
                            break;

                        case "-compress=fast":
                            Config.RecompressionSetting = (int)CompressionLevel.BestSpeed;
                            break;

                        case "-compress=none":
                            Config.RecompressionSetting = (int)CompressionLevel.None;
                            break;

                        case "-distribution":
                            Config.bForDistribution = true;
                            break;

                        case "-createstub":
                            Config.bCreateStubSet = true;
                            break;

                        case "-sign":
                            Config.bPerformResignWhenRepackaging = true;
                            break;

                        case "-cookonthefly":
                            Config.bCookOnTheFly = true;
                            break;

                        case "-iterate":
                            Config.bIterate = true;
                            break;

                        case "-tvos":
                            Config.OSString = "TVOS";
                            break;
                        }

                        // get the stage dir path
                        if (Arg == "-stagedir")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.RepackageStagingDirectory = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-manifest")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeltaManifest = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-backup")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.FilesForBackup.Add(Arguments[++ArgIndex]);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-config")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                GameConfiguration = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        // append a name to the bungle identifier and display name
                        else if (Arg == "-bundlename")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                string projectName = "[PROJECT_NAME]";
                                string bundleId    = Arguments[++ArgIndex];

                                // Check for an illegal bundle id
                                for (int i = 0; i < bundleId.Length; ++i)
                                {
                                    char c = bundleId[i];

                                    if (c == '[')
                                    {
                                        if (bundleId.IndexOf(projectName, i) != i)
                                        {
                                            Error("Illegal character in bundle ID");
                                            return(false);
                                        }
                                        i += projectName.Length;
                                    }
                                    else if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '.' && c != '-')
                                    {
                                        Error("Illegal character in bundle ID");
                                        return(false);
                                    }
                                }

                                // Save the verified bundle id
                                Config.OverrideBundleName = bundleId;
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-schemename")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                SchemeName = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-schemeconfig")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                SchemeConfiguration = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-mac")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.OverrideMacName = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-architecture" || Arg == "-arch")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Architecture = "-" + Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-project")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.ProjectFile = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-device")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeviceId = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-additionalcommandline")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                AdditionalCommandline = Arguments [++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-provision")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.Provision  = Arguments [++ArgIndex];
                                Config.bProvision = !String.IsNullOrEmpty(Config.Provision);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-certificate")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.Certificate = Arguments [++ArgIndex];
                                Config.bCert       = !String.IsNullOrEmpty(Config.Certificate);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        // RPC command
                        MainRPCCommand = Arguments[ArgIndex];
                    }
                }

                if (!SSHCommandHelper.ParseSSHProperties(Arguments))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 6
0
		public static ToolsHub CreateShowingTools()
		{
			ToolsHub Result = new ToolsHub();
			Result.tabControl1.SelectTab(Result.tabPage1);
			return Result;
		}
Ejemplo n.º 7
0
        static private bool ParseCommandLine(ref string[] Arguments)
        {
            if (Arguments.Length == 0)
            {
                StartVisuals();

                // we NEED a project, so show a uproject picker
                string UProjectFile;
                string StartingDir = "";
                if (ToolsHub.ShowOpenFileDialog("Unreal Project Files (*.uproject)|*.uproject;", "IPhonePackager now requires a .uproject file for certificate/provisioning setup", "mobileprovision", "", ref StartingDir, out UProjectFile))
                {
                    Arguments = new string[] { UProjectFile };
                }
                else
                {
                    Arguments = new string[] { "gui" };
                }
            }

            if (Arguments.Length == 1)
            {
                // if the only argument is a uproject, then assume gui mode, with the uproject as the project
                if (Arguments[0].EndsWith(".uproject"))
                {
                    Config.ProjectFile = GamePath = Arguments[0];

                    MainCommand = "gui";
                }
                else
                {
                    MainCommand = Arguments[0];
                }
            }
            else if (Arguments.Length == 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];
            }
            else if (Arguments.Length >= 2)
            {
                MainCommand = Arguments[0];
                GamePath    = Arguments[1];

                for (int ArgIndex = 2; ArgIndex < Arguments.Length; ArgIndex++)
                {
                    string Arg = Arguments[ArgIndex].ToLowerInvariant();

                    if (Arg.StartsWith("-"))
                    {
                        // Behavior switches
                        switch (Arg)
                        {
                        case "-verbose":
                            Config.bVerbose = true;
                            break;

                        case "-strip":
                            Config.bForceStripSymbols = true;
                            break;

                        case "-compress=best":
                            Config.RecompressionSetting = (int)CompressionLevel.BestCompression;
                            break;

                        case "-compress=fast":
                            Config.RecompressionSetting = (int)CompressionLevel.BestSpeed;
                            break;

                        case "-compress=none":
                            Config.RecompressionSetting = (int)CompressionLevel.None;
                            break;

                        case "-distribution":
                            Config.bForDistribution = true;
                            break;

                        case "-createstub":
                            Config.bCreateStubSet = true;
                            break;

                        case "-sign":
                            Config.bPerformResignWhenRepackaging = true;
                            break;

                        case "-cookonthefly":
                            Config.bCookOnTheFly = true;
                            break;
                        }

                        // get the stage dir path
                        if (Arg == "-stagedir")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.RepackageStagingDirectory = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-config")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                GameConfiguration = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        // append a name to the bungle identifier and display name
                        else if (Arg == "-bundlename")
                        {
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.OverrideBundleName = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-mac")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.OverrideMacName = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-architecture" || Arg == "-arch")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Architecture = "-" + Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-project")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.ProjectFile = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-device")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                Config.DeviceId = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (Arg == "-additionalcommandline")
                        {
                            // make sure there's at least one more arg
                            if (Arguments.Length > ArgIndex + 1)
                            {
                                AdditionalCommandline = Arguments[++ArgIndex];
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        // RPC command
                        MainRPCCommand = Arguments[ArgIndex];
                    }
                }
            }

            return(true);
        }