Example #1
0
        public ActionResult CommandLineProcess(string cmd)
        {
            Server.ScriptTimeout = 3600;

            object result;

            if (string.IsNullOrEmpty(cmd))
            {
                result = new { Success = false, Message = "Missing command" }
            }
            ;
            else
            {
                var scriptResult = CommandLineUtility.Execute(cmd);
                result = new { scriptResult.Success, scriptResult.Message, scriptResult.Data };
            }

            return(Json(result));
        }
Example #2
0
        internal string GetSpatialPath()
        {
            string path;

            // The command line overrides everything.
            if (!CommandLineUtility.TryGetCommandLineValue(GetCommandLine(), SpatialPathArgument, out path))
            {
                // Then try the user-specific preferences
                path = GetUserString(SpatialRunner.CommandLocationKey, string.Empty);
            }

            // If nothing has been configured, assume it's on the system PATH, and use a sensible default of "spatial"
            if (string.IsNullOrEmpty(path))
            {
                path = DiscoverSpatialLocation(null);
            }

            return(path);
        }
Example #3
0
        public override Task ExecuteCommandAsync()
        {
            // On mono, parallel builds are broken for some reason. See https://gist.github.com/4201936 for the errors
            // That are thrown.
            DisableParallelProcessing |= RuntimeEnvironmentHelper.IsMono;

            if (DisableParallelProcessing)
            {
                HttpSourceResourceProvider.Throttle = SemaphoreSlimThrottle.CreateBinarySemaphore();
            }

            _CalculateEffectivePackageSaveModeInfo.Invoke(this, null);
            _CalculateEffectiveSettingsInfo.Invoke(this, null);
            var installPath = (string)_ResolveInstallPathInfo.Invoke(this, null);

            var configFilePath = Path.GetFullPath(Arguments.Count == 0 ? Constants.PackageReferenceFile : Arguments[0]);
            var configFileName = Path.GetFileName(configFilePath);

            // If the first argument is a packages.xxx.config file, install everything it lists
            // Otherwise, treat the first argument as a package Id
            if (CommandLineUtility.IsValidConfigFileName(configFileName))
            {
                Prerelease = true;

                // display opt-out message if needed
                if (Console != null && RequireConsent &&
                    new NuGet.PackageManagement.PackageRestoreConsent(Settings).IsGranted)
                {
                    var message = string.Format(
                        CultureInfo.CurrentCulture,
                        Local.RestoreCommandPackageRestoreOptOutMessage,
                        NuGetResources.PackageRestoreConsentCheckBoxText.Replace("&", ""));
                    Console.WriteLine(message);
                }

                return(PerformV2RestoreAsync(configFilePath, installPath));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
        private void InstallPackagesFromConfigFile(IFileSystem fileSystem, PackageReferenceFile configFile)
        {
            // display opt-out message if needed
            if (Console != null && RequireConsent && new PackageRestoreConsent(Settings).IsGranted)
            {
                string message = String.Format(
                    CultureInfo.CurrentCulture,
                    LocalizedResourceManager.GetString("RestoreCommandPackageRestoreOptOutMessage"),
                    NuGet.Resources.NuGetResources.PackageRestoreConsentCheckBoxText.Replace("&", ""));
                Console.WriteLine(message);
            }

            var packageReferences = CommandLineUtility.GetPackageReferences(configFile, requireVersion: true);

            bool installedAny = ExecuteInParallel(fileSystem, packageReferences);
            if (!installedAny && packageReferences.Any())
            {
                Console.WriteLine(LocalizedResourceManager.GetString("InstallCommandNothingToInstall"), Constants.PackageReferenceFile);
            }
        }
Example #5
0
        private void PushPackageCore(string source, string apiKey, PackageServer packageServer, string packageToPush, TimeSpan timeout)
        {
            // Push the package to the server
            var package = new ZipPackage(packageToPush);

            string sourceName = CommandLineUtility.GetSourceDisplayName(source);

            Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), sourceName);

            using (Stream stream = package.GetStream())
            {
                packageServer.PushPackage(apiKey, stream, Convert.ToInt32(timeout.TotalMilliseconds));
            }

            if (CreateOnly)
            {
                Console.WriteWarning(NuGetResources.Warning_PublishPackageDeprecated);
            }
            Console.WriteLine(NuGetResources.PushCommandPackagePushed);
        }
        private static ICollection <PackageReference> GetPackageReferencesInDirectory(string directory)
        {
            var packageReferences = new HashSet <PackageReference>();
            var configFiles       = Directory.GetFiles(directory, "packages*.config", SearchOption.AllDirectories)
                                    .Where(f => Path.GetFileName(f).StartsWith("packages.", StringComparison.OrdinalIgnoreCase));

            foreach (var configFile in configFiles)
            {
                PackageReferenceFile file = new PackageReferenceFile(configFile);
                try
                {
                    packageReferences.AddRange(CommandLineUtility.GetPackageReferences(file, requireVersion: true));
                }
                catch (InvalidOperationException)
                {
                    // Skip the file if it is not a valid xml file.
                }
            }

            return(packageReferences);
        }
Example #7
0
        public override void ExecuteCommand()
        {
            //Frist argument should be the ApiKey
            string apiKey = Arguments[0];

            bool setSymbolServerKey = false;

            //If the user passed a source use it for the gallery location
            string galleryServerUrl;

            if (String.IsNullOrEmpty(Source))
            {
                galleryServerUrl = GalleryServer.DefaultGalleryServerUrl;
                // If no source was specified, set the default symbol server key to be the same
                setSymbolServerKey = true;
            }
            else
            {
                CommandLineUtility.ValidateSource(Source);
                galleryServerUrl = Source;
            }

            var settings = Settings.UserSettings;

            settings.SetEncryptedValue(CommandLineUtility.ApiKeysSectionName, galleryServerUrl, apiKey);

            // Setup the symbol server key
            if (setSymbolServerKey)
            {
                settings.SetEncryptedValue(CommandLineUtility.ApiKeysSectionName, GalleryServer.DefaultSymbolServerUrl, apiKey);
                Console.WriteLine(NuGetResources.SetApiKeyCommandDefaultApiKeysSaved,
                                  apiKey,
                                  CommandLineUtility.GetSourceDisplayName(galleryServerUrl),
                                  CommandLineUtility.GetSourceDisplayName(GalleryServer.DefaultSymbolServerUrl));
            }
            else
            {
                Console.WriteLine(NuGetResources.SetApiKeyCommandApiKeySaved, apiKey, CommandLineUtility.GetSourceDisplayName(galleryServerUrl));
            }
        }
Example #8
0
        private string GetApiKey(string source)
        {
            if (!String.IsNullOrEmpty(ApiKey))
            {
                return(ApiKey);
            }

            string apiKey = null;

            // Second argument, if present, should be the API Key
            if (Arguments.Count > 1)
            {
                apiKey = Arguments[1];
            }

            // If the user did not pass an API Key look in the config file
            if (String.IsNullOrEmpty(apiKey))
            {
                apiKey = CommandLineUtility.GetApiKey(Settings, source);
            }

            return(apiKey);
        }
Example #9
0
        public override void ExecuteCommand()
        {
            if (NoPrompt)
            {
                Console.WriteWarning(NuGetResources.Warning_NoPromptDeprecated);
                NonInteractive = true;
            }

            //First argument should be the package ID
            string packageId = Arguments[0];
            //Second argument should be the package Version
            string packageVersion = Arguments[1];

            //If the user passed a source use it for the gallery location
            string source  = SourceProvider.ResolveAndValidateSource(Source) ?? NuGetConstants.DefaultGalleryServerUrl;
            var    gallery = new PackageServer(source, CommandLineConstants.UserAgent);

            //If the user did not pass an API Key look in the config file
            string apiKey            = GetApiKey(source);
            string sourceDisplayName = CommandLineUtility.GetSourceDisplayName(source);

            if (String.IsNullOrEmpty(apiKey))
            {
                Console.WriteWarning(NuGetResources.NoApiKeyFound, sourceDisplayName);
            }

            if (NonInteractive || Console.Confirm(String.Format(CultureInfo.CurrentCulture, NuGetResources.DeleteCommandConfirm, packageId, packageVersion, sourceDisplayName)))
            {
                Console.WriteLine(NuGetResources.DeleteCommandDeletingPackage, packageId, packageVersion, sourceDisplayName);
                gallery.DeletePackage(apiKey, packageId, packageVersion);
                Console.WriteLine(NuGetResources.DeleteCommandDeletedPackage, packageId, packageVersion);
            }
            else
            {
                Console.WriteLine(NuGetResources.DeleteCommandCanceled);
            }
        }
Example #10
0
 public void ParseArguments(string[] args)
 {
     MbUnit.Core.Monitoring.ConsoleMonitor consoleMonitor = new MbUnit.Core.Monitoring.ConsoleMonitor();
     consoleMonitor.Start();
     try
     {
         this.arguments = new MbUnitFormArguments();
         if (args.Length == 0)
         {
             this.noArgs = true;
         }
         CommandLineUtility.ParseCommandLineArguments(args, arguments);
     }
     catch (Exception)
     {
         consoleMonitor.Stop();
         MessageBox.Show(consoleMonitor.Out + consoleMonitor.Error);
         return;
     }
     finally
     {
         consoleMonitor.Stop();
     }
 }
 public void GetLocalizedString_ThrowsArgumentExceptionForEmptyName()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNullOrEmpty(() => CommandLineUtility.GetLocalizedString(typeof(string), ""), "resourceName");
 }
Example #12
0
        public void ExecuteArguments()
        {
            if (this.arguments == null)
            {
                return;
            }
            System.Threading.Thread.Sleep(500);

            try
            {
                if (this.arguments.Help)
                {
                    MessageBox.Show(
                        CommandLineUtility.CommandLineArgumentsUsage(typeof(MbUnitFormArguments))
                        );
                }

                // load files or project if possible
                if (this.arguments.Files != null)
                {
                    foreach (string fileName in arguments.Files)
                    {
                        if (fileName.ToLower().EndsWith(".mbunit"))
                        {
                            this.Invoke(new LoadProjectDelegate(this.LoadProjectInvoker),
                                        new object[] { fileName, false });
                            break;
                        }
                        this.treeView.AddAssembly(fileName);
                    }
                }

                // load last settings
                if (ConfigurationSettings.AppSettings["restorePreviousState"] == "true" && this.noArgs)
                {
                    this.Invoke(new LoadProjectDelegate(this.LoadProjectInvoker),
                                new object[] { previousSettings, true });
                    return;
                }

                // populate tree
                this.treeView.ThreadedPopulateTree(false);
                while (treeView.WorkerThreadAlive)
                {
                    System.Threading.Thread.Sleep(100);
                }

                // run
                if (this.arguments.Run)
                {
                    this.treeView.ThreadedRunTests();
                    while (treeView.WorkerThreadAlive)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                }

                // generate report
                foreach (ReportType reportType in this.arguments.ReportTypes)
                {
                    switch (reportType)
                    {
                    case ReportType.Html:
                        this.treeView.GenerateHtmlReport(); break;

                    case ReportType.Text:
                        this.treeView.GenerateTextReport(); break;

                    case ReportType.Dox:
                        this.treeView.GenerateDoxReport(); break;

                    case ReportType.Xml:
                        this.treeView.GenerateXmlReport(); break;
                    }
                }

                // exit
                if (this.arguments.Close)
                {
                    System.Threading.Thread.Sleep(1000);
                    while (treeView.WorkerThreadAlive)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failure while executing arguments");
                Console.WriteLine(ex.ToString());
                throw new ApplicationException("Failure while executing arguments", ex);
            }
        }
Example #13
0
        public override void ExecuteCommand()
        {
            var    manifest    = new Manifest();
            string projectFile = null;
            string fileName    = null;

            if (!String.IsNullOrEmpty(AssemblyPath))
            {
                // Extract metadata from the assembly
                string           path     = Path.Combine(Directory.GetCurrentDirectory(), AssemblyPath);
                AssemblyMetadata metadata = AssemblyMetadataExtractor.GetMetadata(path);
                manifest.Metadata.Id          = metadata.Name;
                manifest.Metadata.Version     = metadata.Version.ToString();
                manifest.Metadata.Authors     = metadata.Company;
                manifest.Metadata.Description = metadata.Description;
            }
            else
            {
                if (!CommandLineUtility.TryGetProjectFile(out projectFile))
                {
                    manifest.Metadata.Id      = Arguments.Any() ? Arguments[0] : "Package";
                    manifest.Metadata.Version = "1.0";
                }
                else
                {
                    fileName                      = Path.GetFileNameWithoutExtension(projectFile);
                    manifest.Metadata.Id          = "$id$";
                    manifest.Metadata.Version     = "$version$";
                    manifest.Metadata.Description = "$description$";
                    manifest.Metadata.Authors     = "$author$";
                }
            }

            // Get the file name from the id or the project file
            fileName = fileName ?? manifest.Metadata.Id;

            // If we're using a project file then we want the a minimal nuspec
            if (String.IsNullOrEmpty(projectFile))
            {
                manifest.Metadata.Description = manifest.Metadata.Description ?? "Package description";
                if (String.IsNullOrEmpty(manifest.Metadata.Authors))
                {
                    manifest.Metadata.Authors = Environment.UserName;
                }
                manifest.Metadata.Dependencies = new List <ManifestDependency>();
                manifest.Metadata.Dependencies.Add(new ManifestDependency {
                    Id = "SampleDependency", Version = "1.0"
                });
            }

            manifest.Metadata.ProjectUrl = "http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE";
            manifest.Metadata.LicenseUrl = "http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE";
            manifest.Metadata.IconUrl    = "http://ICON_URL_HERE_OR_DELETE_THIS_LINE";
            manifest.Metadata.Tags       = "Tag1 Tag2";

            string nuspecFile = fileName + Constants.ManifestExtension;

            // Skip the creation if the file exists and force wasn't specified
            if (File.Exists(nuspecFile) && !Force)
            {
                Console.WriteLine(NuGetResources.SpecCommandFileExists, nuspecFile);
            }
            else
            {
                try {
                    using (Stream stream = File.Create(nuspecFile)) {
                        manifest.Save(stream, validate: false);
                    }

                    Console.WriteLine(NuGetResources.SpecCommandCreatedNuSpec, nuspecFile);
                }
                catch {
                    // Cleanup the file if it fails to save for some reason
                    File.Delete(nuspecFile);
                    throw;
                }
            }
        }
 public void ChangeType_ThrowsIfTypeIsNull()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNull(() => CommandLineUtility.ChangeType(new object(), null), "type");
 }
 public void GetLocalizedString_ThrowsArgumentExceptionForNullType()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNull(() => CommandLineUtility.GetLocalizedString(null, "foo"), "resourceType");
 }
Example #16
0
        public void Awake()
        {
            InitializeWorkerTypes();
            // Taken from DefaultWorldInitalization.cs
            SetupInjectionHooks();                                               // Register hybrid injection hooks
            PlayerLoopManager.RegisterDomainUnload(DomainUnloadShutdown, 10000); // Clean up worlds and player loop

            Application.targetFrameRate = TargetFrameRate;
            if (Application.isEditor)
            {
#if UNITY_EDITOR
                var workerConfigurations =
                    AssetDatabase.LoadAssetAtPath <ScriptableWorkerConfiguration>(ScriptableWorkerConfiguration
                                                                                  .AssetPath);
                foreach (var workerConfig in workerConfigurations.WorkerConfigurations)
                {
                    if (!workerConfig.IsEnabled)
                    {
                        continue;
                    }

                    var worker = WorkerRegistry.CreateWorker(workerConfig.Type, $"{workerConfig.Type}-{Guid.NewGuid()}",
                                                             workerConfig.Origin);
                    Workers.Add(worker);
                }

                connectionConfig = new ReceptionistConfig();
                connectionConfig.UseExternalIp = workerConfigurations.UseExternalIp;
#endif
            }
            else
            {
                var commandLineArguments = System.Environment.GetCommandLineArgs();
                Debug.LogFormat("Command line {0}", string.Join(" ", commandLineArguments.ToArray()));
                var commandLineArgs = CommandLineUtility.ParseCommandLineArgs(commandLineArguments);
                var workerType      =
                    CommandLineUtility.GetCommandLineValue(commandLineArgs, RuntimeConfigNames.WorkerType,
                                                           string.Empty);
                var workerId =
                    CommandLineUtility.GetCommandLineValue(commandLineArgs, RuntimeConfigNames.WorkerId,
                                                           string.Empty);

                // because the launcher does not pass in the worker type as an argument
                var worker = workerType.Equals(string.Empty)
                    ? WorkerRegistry.CreateWorker <UnityClient>(
                    workerId: null,     // The worker id for the UnityClient will be auto-generated.
                    origin: new Vector3(0, 0, 0))
                    : WorkerRegistry.CreateWorker(workerType, workerId, new Vector3(0, 0, 0));

                Workers.Add(worker);

                connectionConfig = ConnectionUtility.CreateConnectionConfigFromCommandLine(commandLineArgs);
            }

            if (World.AllWorlds.Count <= 0)
            {
                throw new InvalidConfigurationException(
                          "No worlds have been created, due to invalid worker types being specified. Check the config in" +
                          "Improbable -> Configure editor workers.");
            }

            var worlds = World.AllWorlds.ToArray();
            ScriptBehaviourUpdateOrder.UpdatePlayerLoop(worlds);
            // Systems don't tick if World.Active isn't set
            World.Active = worlds[0];
        }
Example #17
0
        /// <summary>
        ///     Build method that is invoked by commandline
        /// </summary>
        // ReSharper disable once UnusedMember.Global
        public static void Build()
        {
            try
            {
                var commandLine    = Environment.GetCommandLineArgs();
                var buildTargetArg = CommandLineUtility.GetCommandLineValue(commandLine, "buildTarget", "local");

                BuildEnvironment buildEnvironment;
                switch (buildTargetArg.ToLower())
                {
                case "cloud":
                    buildEnvironment = BuildEnvironment.Cloud;
                    break;

                case "local":
                    buildEnvironment = BuildEnvironment.Local;
                    break;

                default:
                    throw new BuildFailedException("Unknown build target value: " + buildTargetArg);
                }

                var workerTypesArg =
                    CommandLineUtility.GetCommandLineValue(commandLine, BuildWorkerTypes,
                                                           "UnityClient,UnityGameLogic");

                var wantedWorkerTypes = workerTypesArg.Split(',');
                foreach (var wantedWorkerType in wantedWorkerTypes)
                {
                    var buildTargetsForWorker           = GetBuildTargetsForWorkerForEnvironment(wantedWorkerType, buildEnvironment);
                    var buildTargetsMissingBuildSupport = BuildSupportChecker.GetBuildTargetsMissingBuildSupport(buildTargetsForWorker);

                    if (buildTargetsMissingBuildSupport.Length > 0)
                    {
                        throw new BuildFailedException(BuildSupportChecker.ConstructMissingSupportMessage(wantedWorkerType, buildEnvironment, buildTargetsMissingBuildSupport));
                    }
                }

                ScriptingImplementation scriptingBackend;
                var wantedScriptingBackend = CommandLineUtility.GetCommandLineValue(commandLine, "scriptingBackend", "mono");
                switch (wantedScriptingBackend)
                {
                case "mono":
                    scriptingBackend = ScriptingImplementation.Mono2x;
                    break;

                case "il2cpp":
                    scriptingBackend = ScriptingImplementation.IL2CPP;
                    break;

                default:
                    throw new BuildFailedException("Unknown scripting backend value: " + wantedScriptingBackend);
                }

                LocalLaunch.BuildConfig();

                foreach (var wantedWorkerType in wantedWorkerTypes)
                {
                    BuildWorkerForEnvironment(wantedWorkerType, buildEnvironment, scriptingBackend);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
        }
Example #18
0
        private void PushPackage(string packagePath, string source, string apiKey = null)
        {
            var gallery = new GalleryServer(source);

            // Use the specified api key or fall back to default behavior
            apiKey = apiKey ?? GetApiKey(source);

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(source));

            using (Stream stream = package.GetStream()) {
                gallery.CreatePackage(apiKey, stream);
            }

            // Publish the package on the server
            if (!CreateOnly)
            {
                var cmd = new PublishCommand();
                cmd.Console   = Console;
                cmd.Source    = source;
                cmd.Arguments = new List <string> {
                    package.Id, package.Version.ToString(), apiKey
                };
                cmd.Execute();
            }
            else
            {
                Console.WriteLine(NuGetResources.PushCommandPackageCreated, source);
            }
        }
Example #19
0
        public override void ExecuteCommand()
        {
            //Frist argument should be the package ID
            string packageId = Arguments[0];
            //Second argument should be the package Version
            string packageVersion = Arguments[1];
            //Third argument if present should be the API Key
            string userSetApiKey = null;

            if (Arguments.Count > 2)
            {
                userSetApiKey = Arguments[2];
            }

            //If the user passed a source use it for the gallery location
            string galleryServerUrl = String.IsNullOrEmpty(Source) ? GalleryServer.DefaultGalleryServerUrl : Source;
            var    gallery          = new GalleryServer(galleryServerUrl);

            //If the user did not pass an API Key look in the config file
            string apiKey = String.IsNullOrEmpty(userSetApiKey) ? CommandLineUtility.GetApiKey(Settings.UserSettings, galleryServerUrl) : userSetApiKey;

            Console.WriteLine(NuGetResources.PublishCommandPublishingPackage, packageId, packageVersion, CommandLineUtility.GetSourceDisplayName(Source));
            gallery.PublishPackage(apiKey, packageId, packageVersion);
            Console.WriteLine(NuGetResources.PublishCommandPackagePublished);
        }
Example #20
0
        /// <summary>
        ///     Build method that is invoked by commandline
        /// </summary>
        // ReSharper disable once UnusedMember.Global
        public static void Build()
        {
            try
            {
                var commandLine    = Environment.GetCommandLineArgs();
                var buildTargetArg = CommandLineUtility.GetCommandLineValue(commandLine, "buildTarget", "local");

                BuildEnvironment buildEnvironment;
                switch (buildTargetArg.ToLower())
                {
                case "cloud":
                    buildEnvironment = BuildEnvironment.Cloud;
                    break;

                case "local":
                    buildEnvironment = BuildEnvironment.Local;
                    break;

                default:
                    throw new BuildFailedException("Unknown build target value: " + buildTargetArg);
                }

                var workerTypesArg =
                    CommandLineUtility.GetCommandLineValue(commandLine, BuildWorkerTypes,
                                                           "UnityClient,UnityGameLogic");
                var wantedWorkerTypes = workerTypesArg.Split(',');

                ScriptingImplementation scriptingBackend;
                var wantedScriptingBackend =
                    CommandLineUtility.GetCommandLineValue(commandLine, "scriptingBackend", "mono");
                switch (wantedScriptingBackend)
                {
                case "mono":
                    scriptingBackend = ScriptingImplementation.Mono2x;
                    break;

                case "il2cpp":
                    scriptingBackend = ScriptingImplementation.IL2CPP;
                    break;

                default:
                    throw new BuildFailedException("Unknown scripting backend value: " + wantedScriptingBackend);
                }

                var buildsSucceeded = BuildWorkers(wantedWorkerTypes, buildEnvironment, scriptingBackend);

                if (!buildsSucceeded)
                {
                    throw new BuildFailedException("Not all builds were completed successfully. See the log for more information.");
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
        }
Example #21
0
        private static void Update()
        {
            if (SUGARManager.client != null && SUGARManager.account != null && !_accountSet)
            {
                var sugarAccount = SUGARManager.account;
                foreach (var autoLoginOption in AutoLoginOptions)
                {
                    if (autoLoginOption.GetType() == typeof(BoolValue))
                    {
                        var boolValue = (BoolValue)autoLoginOption;
                        boolValue.Value = !EditorPrefs.HasKey($"{Application.productName}_{boolValue.Key}") || EditorPrefs.GetBool($"{Application.productName}_{boolValue.Key}");

                        var prop = sugarAccount.GetType().GetField(boolValue.SugarRefName, BindingFlags.Instance | BindingFlags.NonPublic);
                        prop?.SetValue(sugarAccount, boolValue.Value);
                    }
                    if (autoLoginOption.GetType() == typeof(StringValue))
                    {
                        var stringValue = (StringValue)autoLoginOption;
                        stringValue.Value = EditorPrefs.HasKey($"{Application.productName}_{stringValue.Key}") ? EditorPrefs.GetString($"{Application.productName}_{stringValue.Key}") : string.Empty;

                        var prop = sugarAccount.GetType().GetField(stringValue.SugarRefName, BindingFlags.Instance | BindingFlags.NonPublic);
                        prop?.SetValue(sugarAccount, stringValue.Value);

                        if (autoLoginOption.Required)
                        {
                            if (stringValue.Value == string.Empty)
                            {
                                Debug.LogError($"Auto Log-in Tool Error: {stringValue.Label} not provided");
                            }
                        }
                    }
                }

                var args = new List <string>();
                foreach (var autoLoginOption in AutoLoginOptions)
                {
                    if (autoLoginOption.GetType() == typeof(BoolValue))
                    {
                        var boolValue = (BoolValue)autoLoginOption;

                        if (!string.IsNullOrEmpty(boolValue.AutoLoginPrefix) && boolValue.Value)
                        {
                            args.Add(boolValue.AutoLoginPrefix);
                        }
                    }
                    if (autoLoginOption.GetType() == typeof(StringValue))
                    {
                        var stringValue = (StringValue)autoLoginOption;
                        if (!string.IsNullOrEmpty(stringValue.DependsOnValue))
                        {
                            // this value is only used if the value it depends on is true
                            if (DependentValue(stringValue.DependsOnValue) && !string.IsNullOrEmpty(stringValue.AutoLoginPrefix) && !string.IsNullOrEmpty(stringValue.Value))
                            {
                                args.Add(stringValue.AutoLoginPrefix + stringValue.Value);
                            }
                        }
                        else if (!string.IsNullOrEmpty(stringValue.AutoLoginPrefix) && !string.IsNullOrEmpty(stringValue.Value))
                        {
                            args.Add(stringValue.AutoLoginPrefix + stringValue.Value);
                        }
                    }
                }
                SUGARManager.account.options = CommandLineUtility.ParseArgs(args.ToArray());

                _accountSet = true;
            }
            else if (SUGARManager.client == null && _accountSet)
            {
                _accountSet = false;
            }
        }
 public void ChangeType_ThrowsIfTypeDoesNotAllowNulls()
 {
     // Act & Assert
     ExceptionAssert.Throws <InvalidCastException>(() => CommandLineUtility.ChangeType(null, typeof(int)));
 }
Example #23
0
        public static void Run()
        {
            var doValidateProjectAssets = false;
            var doValidateCrossScenes   = false;
            var sceneValidationMode     = SceneValidationMode.None;
            var outputMode = OutputFormat.None;
            var fileName   = "";
            var argsDict   = CommandLineUtility.GetNamedCommandlineArguments(':');

            // Parse whether or not to validate assets in the project
            if (argsDict.ContainsKey(VALIDATE_PROJECT_ASSETS))
            {
                if (!bool.TryParse(argsDict[VALIDATE_PROJECT_ASSETS], out doValidateProjectAssets))
                {
                    LogArgumentError(VALIDATE_PROJECT_ASSETS, argsDict[VALIDATE_PROJECT_ASSETS]);
                }
            }

            // Parse whether or not to validate across scenes in the project
            if (argsDict.ContainsKey(VALIDATE_CROSS_SCENES))
            {
                if (!bool.TryParse(argsDict[VALIDATE_CROSS_SCENES], out doValidateCrossScenes))
                {
                    LogArgumentError(VALIDATE_CROSS_SCENES, argsDict[VALIDATE_CROSS_SCENES]);
                }
            }

            // Parse Scene Validation Mode
            if (argsDict.ContainsKey(SCENE_VALIDATE_MODE_KEY))
            {
                try
                {
                    sceneValidationMode = (SceneValidationMode)Enum.Parse(typeof(SceneValidationMode), argsDict[SCENE_VALIDATE_MODE_KEY], true);
                }
                catch (Exception)
                {
                    LogArgumentError(argsDict[SCENE_VALIDATE_MODE_KEY], SCENE_VALIDATE_MODE_KEY);
                    return;
                }
            }

            // Parse Output Format
            if (argsDict.ContainsKey(OUTPUT_FORMAT_KEY))
            {
                try
                {
                    outputMode = (OutputFormat)Enum.Parse(typeof(OutputFormat), argsDict[OUTPUT_FORMAT_KEY], true);
                }
                catch (Exception)
                {
                    LogArgumentError(argsDict[SCENE_VALIDATE_MODE_KEY], SCENE_VALIDATE_MODE_KEY);
                    return;
                }
            }
            else
            {
                Debug.LogWarning("No OutputFormat has been specified and so none will be written/displayed.");
            }

            // Parse OutputFilename
            if (argsDict.ContainsKey(FILENAME_MODE_KEY))
            {
                fileName = argsDict[FILENAME_MODE_KEY];
                // TODO Fix This
                //if (!FileUtility.IsValidFilename(fileName))
                //{
                //    Debug.LogFormat("{0} is not a valid filename, please check for any illegal characters for this operating system", fileName);
                //    return;
                //}
            }

            Debug.LogFormat("SceneValidationMode: [{0}], OutputMode: [{1}], DoValidateProjectAssets: [{2}], DoValidateCrossScenes: [{3}], Filename: [{4}]",
                            sceneValidationMode, outputMode, doValidateProjectAssets, doValidateCrossScenes, fileName);

            RunValidation(sceneValidationMode,
                          outputMode,
                          doValidateProjectAssets,
                          doValidateCrossScenes,
                          fileName);
        }
 public List <CommandLineUtility.ParamCommand> GetFixedCommandList()
 {
     return(CommandLineUtility.GetParamCommandList(UserConnection));
 }
Example #25
0
        public override void ExecuteCommand()
        {
            // First argument should be the package
            string packagePath = Arguments[0];

            // Don't push symbols by default
            string source = ResolveSource(packagePath, ConfigurationDefaults.Instance.DefaultPushSource);

            var apiKey = GetApiKey(source);

            if (String.IsNullOrEmpty(apiKey) && !IsFileSource(source))
            {
                Console.WriteWarning(LocalizedResourceManager.GetString("NoApiKeyFound"), CommandLineUtility.GetSourceDisplayName(source));
            }

            var timeout = TimeSpan.FromSeconds(Math.Abs(Timeout));

            if (timeout.Seconds <= 0)
            {
                timeout = TimeSpan.FromMinutes(5); // Default to 5 minutes
            }

            PushPackage(packagePath, source, apiKey, timeout);

            if (source.Equals(NuGetConstants.DefaultGalleryServerUrl, StringComparison.OrdinalIgnoreCase))
            {
                PushSymbols(packagePath, timeout);
            }
        }
 public void CreateParamCommands()
 {
     CommandLineUtility.CheckRegisteredSections(UserConnection);
 }
Example #27
0
 public void Parse(String[] args)
 {
     CommandLineUtility.ParseCommandLineArguments(args, arguments);
 }
Example #28
0
        /// <summary>
        ///     Build method that is invoked by commandline
        /// </summary>
        // ReSharper disable once UnusedMember.Global
        public static void Build()
        {
            try
            {
                var commandLine    = Environment.GetCommandLineArgs();
                var buildTargetArg = CommandLineUtility.GetCommandLineValue(commandLine, "buildTarget", "local");

                BuildEnvironment buildEnvironment;
                switch (buildTargetArg.ToLower())
                {
                case "cloud":
                    buildEnvironment = BuildEnvironment.Cloud;
                    break;

                case "local":
                    buildEnvironment = BuildEnvironment.Local;
                    break;

                default:
                    throw new BuildFailedException("Unknown build target value: " + buildTargetArg);
                }

                var workerTypesArg =
                    CommandLineUtility.GetCommandLineValue(commandLine, BuildWorkerTypes,
                                                           "UnityClient,UnityGameLogic");

                var desiredWorkerTypes  = workerTypesArg.Split(',');
                var filteredWorkerTypes = BuildSupportChecker.FilterWorkerTypes(buildEnvironment, desiredWorkerTypes);

                if (desiredWorkerTypes.Length != filteredWorkerTypes.Length)
                {
                    throw new BuildFailedException(
                              "Unable to complete build. Missing build support. Check logs for specific errors.");
                }

                ScriptingImplementation scriptingBackend;
                var wantedScriptingBackend =
                    CommandLineUtility.GetCommandLineValue(commandLine, "scriptingBackend", "mono");
                switch (wantedScriptingBackend)
                {
                case "mono":
                    scriptingBackend = ScriptingImplementation.Mono2x;
                    break;

                case "il2cpp":
                    scriptingBackend = ScriptingImplementation.IL2CPP;
                    break;

                default:
                    throw new BuildFailedException("Unknown scripting backend value: " + wantedScriptingBackend);
                }

                LocalLaunch.BuildConfig();

                foreach (var wantedWorkerType in filteredWorkerTypes)
                {
                    BuildWorkerForEnvironment(wantedWorkerType, buildEnvironment, scriptingBackend);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
        }
 private string GetApiKey(string source)
 {
     return(String.IsNullOrEmpty(ApiKey) ? CommandLineUtility.GetApiKey(Settings, source) : ApiKey);
 }
 public void AddPackage(IPackage package)
 {
     _logger.Log(MessageLevel.Info, NuGetResources.MirrorCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(_destination.Source));
     _destination.PushPackage(_apiKey, package, (int)_timeout.TotalMilliseconds);
     _logger.Log(MessageLevel.Info, NuGetResources.MirrorCommandPackagePushed);
 }