Beispiel #1
0
        public static void InstallCustomPackage(string name, string url, string version = null)
        {
            // TODO: verify this version exists
            // TODO: verify not already installed

            var relativeInstallDirectory = Settings.RelativePackagesDirectoryPath + name;
            var absoluteInstallDirectory = Settings.AbsolutePackagesDirectoryPath + name;
            var args = new InstallPackageArgs(name, url, version);

            Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_STARTED, args);

            var operation = new AsyncOperation();

            operation.Add(new AddSubmoduleTask(url, relativeInstallDirectory));

            if (!string.IsNullOrEmpty(version))
            {
                operation.Add(new CheckoutSubmoduleTask(absoluteInstallDirectory, version));
            }

            operation.Execute(result =>
            {
                if (result.IsError)
                {
                    Debug.LogError("Error installing package");
                    Debug.LogError(result.Error.Message);

                    Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_FAILED);
                }
                else
                {
                    Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_COMPLETE, args);
                }
            });
        }
Beispiel #2
0
        public static void InstallPackage(AvailablePackage package, string version)
        {
            // TODO: verify this version exists
            // TODO: verify not already installed

            var relativeInstallDirectory = Settings.RelativePackagesDirectoryPath + package.Name;
            var absoluteInstallDirectory = Settings.AbsolutePackagesDirectoryPath + package.Name;
            var args = new InstallPackageArgs(package, version);

            var operation = new AsyncOperation();

            operation.AddSync(() => { Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_STARTED, args); });

            operation.Add(new AddSubmoduleTask(package.GitUrl, relativeInstallDirectory));

            operation.Add(new CheckoutSubmoduleTask(absoluteInstallDirectory, version));

            operation.Execute(result =>
            {
                if (result.IsError)
                {
                    Debug.LogError("Error installing package");
                    Debug.LogError(result.Error.Message);

                    Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_FAILED);
                }
                else
                {
                    Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_COMPLETE, args);
                }
            });
        }