Beispiel #1
0
        public async Task Run(ScoopBoxOptions options)
        {
            string wsb = $"{options.UserFilesPath}\\{Constants.SandboxScriptName}";

            Process cmd = new Process()
            {
                StartInfo = new ProcessStartInfo()
                {
                    FileName = "cmd.exe",
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = false,
                    WindowStyle            = ProcessWindowStyle.Hidden,
                    UseShellExecute        = false,
                }
            };

            cmd.Start();

            await cmd.StandardInput.WriteLineAsync($"\"{wsb}\"");

            await cmd.StandardInput.FlushAsync();

            cmd.StandardInput.Close();
            cmd.WaitForExit();
        }
Beispiel #2
0
        public async Task Generate(ScoopBoxOptions scoopBoxOptions)
        {
            string script = this.sandboxScriptBuilder.Build(scoopBoxOptions);

            using (StreamWriter writer = File.CreateText($@"{scoopBoxOptions.UserFilesPath}\{Constants.SandboxScriptName}"))
            {
                await writer.WriteAsync(script);
            }
        }
Beispiel #3
0
        public Configuration Build(ScoopBoxOptions options)
        {
            List <string> commands      = this.commandBuilder.Build(options);
            MappedFolders mappedFolders = this.mappedFoldersBuilder.Build(options);

            Configuration configuration = new Configuration(options, commands, mappedFolders);

            return(configuration);
        }
Beispiel #4
0
        public Configuration(
            ScoopBoxOptions options,
            List <string> commands,
            MappedFolders mappedFolders)
        {
            LogonCommand = new LogonCommand();

            VGpu = Enum.GetName(typeof(VGpuOptions), options.VGpu);
            LogonCommand.Command = commands;
            this.MappedFolders   = mappedFolders;
        }
Beispiel #5
0
        public List <string> Build(ScoopBoxOptions options)
        {
            string executionPolicyBuilder = this.executionPolicyBuilder.Build(options);
            string executionScriptBuilder = this.executionScriptCommandBuilder.Build();

            return(new List <string>()
            {
                executionPolicyBuilder,
                executionScriptBuilder
            });
        }
Beispiel #6
0
        public string Build(ScoopBoxOptions scoopBoxOptions)
        {
            StringBuilder installerBuilder = new StringBuilder();

            installerBuilder.AppendLine(scoopInstaller.Build());
            installerBuilder.AppendLine(appInstaller.Build("git"));
            installerBuilder.AppendLine(scoopBuckets.Build("extras"));
            installerBuilder.AppendLine(appInstaller.Build(scoopBoxOptions.Apps));

            return(installerBuilder.ToString());
        }
        public string Build(ScoopBoxOptions options)
        {
            StringBuilder executionPolicy = new StringBuilder();

            executionPolicy.Append("powershell.exe ");
            executionPolicy.Append("-ExecutionPolicy ");
            executionPolicy.Append("Bypass ");
            executionPolicy.Append("-File ");
            executionPolicy.Append(Constants.SandboxInstallerLocation);

            executionPolicy.AppendLine();
            return(executionPolicy.ToString());
        }
        public MappedFolders Build(ScoopBoxOptions options)
        {
            MappedFolders mappedFolders = new MappedFolders
            {
                MappedFolder = new List <MappedFolder>()
            };

            mappedFolders.MappedFolder.Add(new MappedFolder()
            {
                HostFolder = options.UserFilesPath,
                ReadOnly   = Enum.GetName(typeof(ReadOnly), ReadOnly.False).ToLower()
            });

            return(mappedFolders);
        }
Beispiel #9
0
        public string Build(ScoopBoxOptions options)
        {
            Configuration configuration = this.configurationBuilder.Build(options);

            XmlSerializer           configurationSerializer = new XmlSerializer(typeof(Configuration));
            XmlSerializerNamespaces emptyNamespaces         = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
            var settings = new XmlWriterSettings
            {
                Indent             = true,
                OmitXmlDeclaration = true
            };

            using (var configStringWriter = new StringWriter())
            {
                using (XmlWriter configXmlWriter = XmlWriter.Create(configStringWriter, settings))
                {
                    configurationSerializer.Serialize(configXmlWriter, configuration, emptyNamespaces);
                    return(configStringWriter.ToString());
                }
            }
        }
Beispiel #10
0
        static async Task Main(string[] args)
        {
            ServiceProvider serviceProvider = new ServiceCollection()
                                              .UseScoopBox()
                                              .BuildServiceProvider();

            var scoopScriptGenerator   = serviceProvider.GetService <IScoopScript>();
            var sandboxScriptGenerator = serviceProvider.GetService <ISandboxScript>();
            var scoopBoxProcess        = serviceProvider.GetService <IScoopBoxProcess>();

            var apps = new List <string>()
            {
                "git", "curl", "openssh", "vscode", "fiddler"
            };
            ScoopBoxOptions options = new ScoopBoxOptions(apps);

            await scoopScriptGenerator.Generate(options);

            await sandboxScriptGenerator.Generate(options);

            await scoopBoxProcess.Run(options);
        }