コード例 #1
0
        public void PostBuildEvents(bool pDebug, Dictionary <string, string> pArguments, out string pOutput, out ICollection <Error> pErrors)
        {
            if (!pArguments.ContainsKey(@"FlexSdkPath"))
            {
                pOutput = string.Empty;
                pErrors = new Error[0];
                return;
            }

            ProcessArguments process = new ProcessArguments();

            As3ProjectBuilder builder = new As3ProjectBuilder(pArguments[@"FlexSdkPath"]);

            pArguments.Remove(@"FlexSdkPath");

            process.AddArgument(Path.Combine(_outputFolder, MainClassName.Replace(".", "\\") + ".as"));
            process.AddArgument("source-path", _outputFolder);

            if (pDebug)
            {
                process.AddArgument(@"debug", "true");
                process.AddArgument(@"omit-trace-statements", "false");
                process.AddArgument(@"verbose-stacktraces", "true");
            }

            foreach (var argument in pArguments)
            {
                process.AddArgument(argument.Key, argument.Value);
            }

            process.AddArgument("o", Path.Combine(_outputFolder, @"..\swf\file.swf"));

            pErrors = builder.Compile(_outputFolder, process.ToString(), false, out pOutput);
        }
コード例 #2
0
 public void InsertRange()
 => Assert.Equal(
     new [] { "zero", "one", "two", "three", "four" },
     ProcessArguments
     .Create("four")
     .InsertRange(0, "zero", "one")
     .InsertRange(2, new [] { "two", "three" }));
コード例 #3
0
 public void Insert()
 => Assert.Equal(
     new [] { "zero", "one", "two", "three", "four" },
     ProcessArguments
     .Create("one", "three")
     .Insert(1, "two")
     .Insert(3, "four")
     .Insert(0, "zero"));
コード例 #4
0
        private static void MainInternal(ProcessArguments args)
        {
            LoadStyles();
            var app = new Application();

            app.Initialized += (sender, e) => AppInitialized(app, args);
            app.Run();
        }
コード例 #5
0
        public void ImplicitlyExecAssemblyWithMonoOnUnix()
        {
            var exec = new Exec(ProcessArguments.Create("test.exe", "a", "b"));

            Assert.False(exec.Elevated);
            Assert.Equal(
                exec.Arguments,
                ProcessArguments.Create("mono", "test.exe", "a", "b"));
        }
コード例 #6
0
        public void CreateFromArgsFailTest()
        {
            var processArgumentsArgs = ProcessArguments.Create(new [] { "blabla" });

            Assert.IsNull(processArgumentsArgs);

            var processArgumentsArgs2 = ProcessArguments.Create(new[] { "blabla=" });

            Assert.IsNull(processArgumentsArgs2);
        }
コード例 #7
0
        public void ElevateOnMac()
        {
            var exec = new Exec(
                ProcessArguments.Create("installer"),
                ExecFlags.Elevate);

            Assert.True(exec.Elevated);
            Assert.Equal(
                exec.Arguments,
                ProcessArguments.Create("/usr/bin/sudo", "installer"));
        }
コード例 #8
0
        public void ElevateOnMacAndImplicitlyExecAssemblyWithMonoOnUnix()
        {
            var exec = new Exec(
                ProcessArguments.Create("test.exe", "a", "b"),
                ExecFlags.Elevate);

            Assert.True(exec.Elevated);
            Assert.Equal(
                exec.Arguments,
                ProcessArguments.Create("/usr/bin/sudo", "mono", "test.exe", "a", "b"));
        }
コード例 #9
0
ファイル: Tests.cs プロジェクト: rosenbjerg/Instances
        public void PublishesExitedEventOnError()
        {
            var arguments        = new ProcessArguments("dotnet", "run --project Nopes");
            var completionSource = new TaskCompletionSource <IProcessResult>();

            arguments.Exited += (_, args) => completionSource.TrySetResult(args);

            arguments.Start();
            var result = completionSource.Task.GetAwaiter().GetResult();

            Assert.NotZero(result.ExitCode);
        }
コード例 #10
0
        private static void AppInitialized(Application app, ProcessArguments args)
        {
            var splash = ShowSplash(args.SplashPath);
            var duplex = PlatformCommon.CreateClientDuplex(args.ParentProcessId, () => new BrowserHost());
            var form   = new MainForm(duplex, splash);

            form.Show();
            SettingsApplier.CenterForm(form);
            form.Visible     = false;
            BrowserHost.Form = form;
            form.Closed     += (sender, eventArgs) => app.Quit();
        }
コード例 #11
0
        public void CreateFromNameTest()
        {
            const string ipcName          = "TestMe";
            var          processArguments = ProcessArguments.Create(ipcName, typeof(ProcessArgumentsTest));

            Assert.IsTrue(processArguments.IsValid);
            Assert.AreEqual(processArguments.IpcClientName, ProcessArguments.CreateIpcClientName(ipcName));
            Assert.AreEqual(processArguments.IpcProcessName, ProcessArguments.CreateIpcProcessName(ipcName));
            Assert.AreEqual(processArguments.IpcServerName, ProcessArguments.CreateIpcServerName(ipcName));
            Assert.AreEqual(processArguments.IpcParentProgramPid, Process.GetCurrentProcess().Id);
            Assert.AreEqual(typeof(ProcessArgumentsTest).Assembly, processArguments.IpcAssembly);
            Assert.AreEqual(typeof(ProcessArgumentsTest), processArguments.IpcRemoteType);
        }
コード例 #12
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="processArguments"></param>
        internal MultiProcessWorkerRunner(ProcessArguments processArguments)
        {
            m_ProcessArguments = processArguments;
            m_HostedType       = processArguments.IpcRemoteType;

            AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainUnhandledException;

            m_ParentProcess = Process.GetProcessById(processArguments.IpcParentProgramPid);
            m_ParentProcess.EnableRaisingEvents = true;
            m_ParentProcess.Exited += OnParentProcessExited;

            m_WorkCommands = new Queue <WorkCommand>();
        }
コード例 #13
0
        private static void MainInternal(ProcessArguments args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ApplicationExit += Application_ApplicationExit;

            var duplex = PlatformCommon.CreateClientDuplex(args.ParentProcessId, () => new BrowserHost());
            var splash = ShowSplash(args.SplashPath);

            InitializeCef();
            var form = new MainForm(duplex, splash);

            BrowserHost.Form = form;
            Application.Run(form);
        }
コード例 #14
0
 public void IgnoreElevateOnUnix()
 {
     // On VSTS the hosted Linux pool runs as root (sigh, but we can take
     // advantage of that fact to test that we are _not_ wrapping with
     // sudo if we already are root).
     if (Environment.GetEnvironmentVariable("TF_BUILD") == "True")
     {
         var exec = new Exec(
             ProcessArguments.Create("installer"),
             ExecFlags.Elevate);
         Assert.False(exec.Elevated);
         Assert.Equal(
             exec.Arguments,
             ProcessArguments.Create("installer"));
     }
 }
コード例 #15
0
        public void CreateFromArgsTest()
        {
            const string ipcName          = "TestMe";
            var          processArguments = ProcessArguments.Create(ipcName, typeof(ProcessArgumentsTest));

            var args = processArguments.ToStringArray();
            var processArgumentsArgs = ProcessArguments.Create(args);

            Assert.IsTrue(processArgumentsArgs.IsValid);
            Assert.AreEqual(processArguments.IpcClientName, processArgumentsArgs.IpcClientName);
            Assert.AreEqual(processArgumentsArgs.IpcProcessName, processArgumentsArgs.IpcProcessName);
            Assert.AreEqual(processArguments.IpcServerName, processArgumentsArgs.IpcServerName);
            Assert.AreEqual(processArguments.IpcParentProgramPid, processArgumentsArgs.IpcParentProgramPid);
            Assert.AreEqual(processArguments.IpcAssembly, processArgumentsArgs.IpcAssembly);
            Assert.AreEqual(processArguments.IpcRemoteType, processArgumentsArgs.IpcRemoteType);
        }
コード例 #16
0
        /// <summary>
        /// Create a remote worker
        /// </summary>
        /// <param name="processArguments"></param>
        private MultiProcessWorkerClientBase(ProcessArguments processArguments)
        {
            HostedObjecType = processArguments.IpcRemoteType;

            m_WorkCommandResults = new ConcurrentDictionary <Guid, WorkResult>();

            m_IpcCommunication = IpcCommunication <WorkCommand, WorkResult> .CreateServer(processArguments.IpcServerName, processArguments.IpcClientName);

            m_IpcCommunication.MessageRecived += OnIpcCommunicationMessageRecived;

            m_ProcessEventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, processArguments.IpcProcessName);

            m_WorkerProcess           = CreateProcess(processArguments.ToString());
            m_WorkerProcess.Exited   += OnWorkerProcessExited;
            m_WorkerProcess.Disposed += OnWorkerProcessDisposed;
            m_WorkerProcess.Start();
        }
コード例 #17
0
        public void ToStringTest()
        {
            const string ipcName          = "TestMe";
            var          processArguments = ProcessArguments.Create(ipcName, typeof(ProcessArgumentsTest));

            var argsString = processArguments.ToString();

            var args = argsString.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var processArgumentsArgs = ProcessArguments.Create(args);

            Assert.IsTrue(processArgumentsArgs.IsValid);
            Assert.AreEqual(processArguments.IpcClientName, processArgumentsArgs.IpcClientName);
            Assert.AreEqual(processArgumentsArgs.IpcProcessName, processArgumentsArgs.IpcProcessName);
            Assert.AreEqual(processArguments.IpcServerName, processArgumentsArgs.IpcServerName);
            Assert.AreEqual(processArguments.IpcParentProgramPid, processArgumentsArgs.IpcParentProgramPid);
            Assert.AreEqual(processArguments.IpcAssembly, processArgumentsArgs.IpcAssembly);
            Assert.AreEqual(processArguments.IpcRemoteType, processArgumentsArgs.IpcRemoteType);
        }
コード例 #18
0
ファイル: StealthProcess.cs プロジェクト: h0wXD/h0wXD
        public ProcessOutput Execute(ProcessArguments processArguments)
        {
            using (var process = new Process())
            {
                process.StartInfo = new ProcessStartInfo
                {
                    FileName               = processArguments.File,
                    Arguments              = processArguments.Arguments,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    ErrorDialog            = false,
                };

                var outputBuilder      = new StringBuilder(1024);
                var errorOutputBuilder = new StringBuilder(1024);

                process.OutputDataReceived += (server, e) =>
                {
                    outputBuilder.Append(e.Data);
                };

                process.ErrorDataReceived += (sender, e) =>
                {
                    errorOutputBuilder.Append(e.Data);
                };

                process.Start();
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                process.WaitForExit();

                return(new ProcessOutput
                {
                    Arguments = processArguments.Arguments,
                    File = processArguments.File,
                    ExitCode = process.ExitCode,
                    Output = outputBuilder.ToString(),
                    ErrorOutput = errorOutputBuilder.ToString()
                });
            }
        }
コード例 #19
0
        static WorkbookPackageTests()
        {
            void Git(string dir, params string [] args)
            => new Exec(
                ProcessArguments.FromCommandAndArguments("git", args),
                outputRedirection: null,
                workingDirectory: dir).RunAsync().GetAwaiter().GetResult();

            if (PathToExternalWorkbooks.DirectoryExists)
            {
                Git(PathToExternalWorkbooks, "pull", "--rebase");
                Git(PathToExternalWorkbooks, "submodule", "sync");
                Git(PathToExternalWorkbooks, "submodule", "update", "--recursive", "--init");
            }
            else
            {
                Git(
                    PathToExternalWorkbooks.ParentDirectory,
                    "clone",
                    "--recursive",
                    "https://github.com/xamarin/workbooks",
                    PathToExternalWorkbooks.Name);
            }
        }
コード例 #20
0
        public static async Task <int> RunAsync(
            CancellationToken cancellationToken,
            Action <TimeSpan>?progressHandler,
            params string[] arguments)
        {
            var commandLine = ProcessArguments.FromCommandAndArguments(Path, arguments);

            Log.Debug("Exec {Path} {Arguments}", Path, arguments);

            TimeSpan progress = default;

            progressHandler?.Invoke(progress);

            return((await Exec.RunAsync(output =>
            {
                switch (output.FileDescriptor)
                {
                case ConsoleRedirection.FileDescriptor.Output:
                    Log.Debug("ffmpeg: {stdout}", output.Data.TrimEnd('\r', '\n'));
                    break;

                case ConsoleRedirection.FileDescriptor.Error:
                    Log.Debug("ffmpeg: {stderr}", output.Data.TrimEnd('\r', '\n'));
                    var match = timespanRegex.Match(output.Data);
                    if (match.Success &&
                        match.Groups.TryGetValue("timespan", out var timespanGroup) &&
                        TimeSpan.TryParse(timespanGroup.Value, out var timespan) &&
                        timespan != progress)
                    {
                        progress = timespan;
                        progressHandler?.Invoke(progress);
                    }
                    break;
                }
            }, Path, arguments).ConfigureAwait(false)).ExitCode ?? -1);
        }
コード例 #21
0
		public void PostBuildEvents(bool pDebug, Dictionary<string, string> pArguments, out string pOutput, out ICollection<Error> pErrors) {
			if (!pArguments.ContainsKey(@"FlexSdkPath")) {
				pOutput = string.Empty;
				pErrors = new List<Error>();
				return;
			}

			ProcessArguments process = new ProcessArguments();

			JsProjectBuilder builder = new JsProjectBuilder(pArguments[@"FlexSdkPath"]);
			pArguments.Remove(@"FlexSdkPath");

			process.AddArgument(Path.Combine(_outputFolder, MainClassName.Replace(".", "\\")+".as"));
			process.AddArgument("source-path", _outputFolder);

			if (pDebug) {
				process.AddArgument(@"debug", "true");
				process.AddArgument(@"omit-trace-statements", "false");
				process.AddArgument(@"verbose-stacktraces", "true");
			}

			foreach (var argument in pArguments) {
				process.AddArgument(argument.Key, argument.Value);
			}

			process.AddArgument("o", Path.Combine(_outputFolder, @"..\swf\file.swf"));

			pErrors = builder.Compile(_outputFolder, process.ToString(), false, out pOutput);
		}
コード例 #22
0
        protected override string GenerateCommandLineCommands()
        {
            ProcessArguments arguments = null;

            if (!InvokeLinkerUsingMono)
            {
                arguments = ProcessArguments.Create("--verbose");
            }
            else
            {
                var toolsPath = GetPathToMonoLinker();
                Log.LogMessage(MessageImportance.High, $"Running monolinker from {toolsPath}.");
                arguments = ProcessArguments.Create(toolsPath);
                arguments = arguments.Add("--verbose");
            }

            arguments = arguments.AddRange("--deterministic");

            // add exclude features
            arguments = arguments.AddRange("--exclude-feature", "remoting", "--exclude-feature", "com", "--exclude-feature", "etw");

            string coremode, usermode;

            switch ((WasmLinkMode)Enum.Parse(typeof(WasmLinkMode), LinkMode))
            {
            case WasmLinkMode.SdkOnly:
                coremode = "link";
                usermode = "copy";
                break;

            case WasmLinkMode.Full:
                coremode = "link";
                usermode = "link";
                break;

            default:
                coremode = "copyused";
                usermode = "copy";
                break;
            }

            arguments = arguments.AddRange("-c", coremode, "-u", usermode);

            //the linker doesn't consider these core by default
            foreach (var bn in bindingNames)
            {
                arguments = arguments.AddRange("-p", coremode, bn);
            }

            if (!string.IsNullOrEmpty(LinkSkip))
            {
                var skips = LinkSkip.Split(new[] { ';', ',', ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var s in skips)
                {
                    arguments = arguments.AddRange("-p", "copy", s);
                }
            }

            arguments = arguments.AddRange("-out", OutputDir);

            arguments = arguments.AddRange("-d", FrameworkDir);

            arguments = arguments.AddRange("-d", Path.Combine(FrameworkDir, "Facades"));

            arguments = arguments.AddRange("-b", Debug.ToString());
            arguments = arguments.AddRange("-v", Debug.ToString());

            // add custom link descriptions
            // to ensure the type, methods and/or fields are not eliminated from your application.
            if (LinkDescriptions != null)
            {
                foreach (var desc in LinkDescriptions)
                {
                    var l = desc.GetMetadata("FullPath");
                    arguments = arguments.AddRange("-x", l);
                }
            }

            arguments = arguments.AddRange("-a", RootAssembly[0].GetMetadata("FullPath"));

            //we'll normally have to check most of the files because the SDK references most framework asm by default
            //so let's enumerate upfront
            var frameworkAssemblies = new HashSet <string> (StringComparer.OrdinalIgnoreCase);

            foreach (var f in Directory.EnumerateFiles(FrameworkDir))
            {
                frameworkAssemblies.Add(Path.GetFileNameWithoutExtension(f));
            }
            foreach (var f in Directory.EnumerateFiles(Path.Combine(FrameworkDir, "Facades")))
            {
                frameworkAssemblies.Add(Path.GetFileNameWithoutExtension(f));
            }

            // Load the runtime assemblies to be replaced in the references below
            var runtimeCopyLocal = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase);

            if (RuntimeCopyLocalAssemblies != null)
            {
                foreach (var copyAsm in RuntimeCopyLocalAssemblies)
                {
                    var p = copyAsm.GetMetadata("FullPath");

                    if (frameworkAssemblies.Contains(Path.GetFileNameWithoutExtension(p)))
                    {
                        continue;
                    }
                    runtimeCopyLocal.Add(Path.GetFileNameWithoutExtension(p), p);
                }
            }

            //add references for non-framework assemblies
            if (Assemblies != null)
            {
                foreach (var asm in Assemblies)
                {
                    var p = asm.GetMetadata("FullPath");

                    if (frameworkAssemblies.Contains(Path.GetFileNameWithoutExtension(p)))
                    {
                        continue;
                    }

                    if (runtimeCopyLocal.TryGetValue(Path.GetFileNameWithoutExtension(p), out var runtimePath))
                    {
                        if (!string.IsNullOrEmpty(BindingsDir) && bindingNames.Contains(Path.GetFileNameWithoutExtension(p)))
                        {
                            runtimePath = Path.Combine(BindingsDir, Path.GetFileName(p));
                        }
                        // Just in case
                        if (File.Exists(runtimePath))
                        {
                            p = runtimePath;
                        }
                    }
                    arguments = arguments.AddRange("-r", p);
                }
            }

            if (string.IsNullOrEmpty(I18n))
            {
                arguments = arguments.AddRange("-l", "none");
            }
            else
            {
                var vals = I18n.Split(new[] { ',', ';', ' ', '\r', '\n', '\t' });
                arguments = arguments.AddRange("-l", string.Join(",", vals));
            }
            return(arguments.ToString());
        }
コード例 #23
0
 public void ParseWithoutGlobs(string commandLine, params string [] expectedArguments)
 => Assert.Equal(
     expectedArguments,
     ProcessArguments.Parse(commandLine));
コード例 #24
0
        private void OnExit(object state)
        {
            if (restart)
            {
                Reset();
                ProcessCallback(this);
                return;
            }

            bool isError;

            try
            {
                // An error occurred!
                if (gitCommand != null && gitCommand.ExitCode != 0)
                {
                    isError = true;

                    // TODO: This Plink stuff here seems misplaced. Is there a better
                    // home for all of this stuff? For example, if I had a label called pull,
                    // we could end up in this code incorrectly.
                    if (Plink)
                    {
                        if (ProcessArguments.ToLower().Contains("pull") || ProcessArguments.ToLower().Contains("push") || ProcessArguments.ToLower().Contains("plink") || ProcessArguments.ToLower().Contains("tortoiseplink") || ProcessArguments.ToLower().Contains("remote") || ProcessString.ToLower().Contains("clone") || ProcessArguments.ToLower().Contains("clone"))
                        {
                            if (OutputString.ToString().Contains("successfully authenticated"))
                            {
                                isError = false;
                            }

                            if (OutputString.ToString().Contains("FATAL ERROR") && OutputString.ToString().Contains("authentication"))
                            {
                                var puttyError = new FormPuttyError();
                                puttyError.ShowDialog();
                                if (puttyError.RetryProcess)
                                {
                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                            if (OutputString.ToString().ToLower().Contains("the server's host key is not cached in the registry") && !string.IsNullOrEmpty(UrlTryingToConnect))
                            {
                                if (MessageBox.Show("The server's host key is not cached in the registry.\n\nDo you want to trust this host key and then try again?", "SSH", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    GitCommandHelpers.RunRealCmdDetached(
                                        "cmd.exe",
                                        string.Format("/k \"\"{0}\" -T \"{1}\"\"", Settings.Plink, UrlTryingToConnect));

                                    Reset();
                                    ProcessCallback(this);
                                    return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    isError = false;
                }
            }
            catch
            {
                isError = true;
            }

            Done(!isError);
        }
コード例 #25
0
 public void Create(params string [] args)
 => Assert.Equal(args, ProcessArguments.Create(args));
コード例 #26
0
 public void ParseAndToStringRoundTrip(string commandLine, string expectedToString)
 => Assert.Equal(
     expectedToString,
     ProcessArguments.Parse(commandLine).ToString());
コード例 #27
0
        public override TaskStatus Run()
        {
            Info("Launching process...");

            if (GeneratesFiles && !(ProcessArguments.Contains(VarFileName) && (ProcessArguments.Contains(VarOutput) && (ProcessArguments.Contains(VarFileName) || ProcessArguments.Contains(VarFileNameWithoutExtension)))))
            {
                Error("Error in process command. Please read the documentation.");
                return(TaskStatus.Failed);
            }

            if (!GeneratesFiles)
            {
                var startSuccessful = StartProcess(ProcessPath, ProcessArguments, HideGui);
                return(startSuccessful ? TaskStatus.Completed : TaskStatus.Failed);
            }

            foreach (FileInf file in SelectFiles())
            {
                string cmd;
                string outputFilePath;

                try
                {
                    cmd = ProcessArguments.Replace(string.Format("{{{0}}}", VarFilePath), string.Format("\"{0}\"", file.Path));

                    const string outputRegexPattern = @"{\$output:(?:\$fileNameWithoutExtension|\$fileName)(?:[a-zA-Z0-9._-]*})";
                    var          outputRegex        = new Regex(outputRegexPattern);
                    var          m = outputRegex.Match(cmd);

                    if (m.Success)
                    {
                        string val = m.Value;
                        outputFilePath = val;
                        if (outputFilePath.Contains(VarFileNameWithoutExtension))
                        {
                            outputFilePath = outputFilePath.Replace(VarFileNameWithoutExtension, Path.GetFileNameWithoutExtension(file.FileName));
                        }
                        else if (outputFilePath.Contains(VarFileName))
                        {
                            outputFilePath = outputFilePath.Replace(VarFileName, file.FileName);
                        }
                        outputFilePath = outputFilePath.Replace("{" + VarOutput + ":", Workflow.WorkflowTempFolder.Trim('\\') + "\\");
                        outputFilePath = outputFilePath.Trim('}');

                        cmd = cmd.Replace(val, "\"" + outputFilePath + "\"");
                    }
                    else
                    {
                        Error("Error in process command. Please read the documentation.");
                        return(TaskStatus.Failed);
                    }
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    ErrorFormat("Error in process command. Please read the documentation. Error: {0}", e.Message);
                    return(TaskStatus.Failed);
                }

                if (StartProcess(ProcessPath, cmd, HideGui))
                {
                    Files.Add(new FileInf(outputFilePath, Id));

                    if (LoadAllFiles)
                    {
                        var files = Directory.GetFiles(Workflow.WorkflowTempFolder, "*.*", SearchOption.AllDirectories);

                        foreach (var f in files)
                        {
                            if (f != outputFilePath)
                            {
                                Files.Add(new FileInf(f, Id));
                            }
                        }
                    }
                }
            }

            Info("Task finished.");

            return(TaskStatus.Completed);
        }
コード例 #28
0
        static void Main(string[] args)
        {
            var parameters = ProcessArguments.Parse(args);

            MainInternal(parameters);
        }
コード例 #29
0
 public void Empty()
 {
     Assert.Same(ProcessArguments.Empty, ProcessArguments.Create());
     Assert.Same(ProcessArguments.Empty, ProcessArguments.Parse(string.Empty));
 }
コード例 #30
0
ファイル: WasmLinkAssemblies.cs プロジェクト: yangruihan/mono
        protected override string GenerateCommandLineCommands()
        {
            ProcessArguments arguments = null;

            if (!InvokeLinkerUsingMono)
            {
                arguments = ProcessArguments.Create("--verbose");
            }
            else
            {
                var toolsPath = GetPathToMonoLinker();
                Log.LogMessage(MessageImportance.High, $"Running monolinker from {toolsPath}.");
                arguments = ProcessArguments.Create(toolsPath);
                arguments = arguments.Add("--verbose");
            }

            // add exclude features
            arguments = arguments.AddRange("--exclude-feature", "remoting", "--exclude-feature", "com", "--exclude-feature", "etw");

            string coremode, usermode;

            switch ((WasmLinkMode)Enum.Parse(typeof(WasmLinkMode), LinkMode))
            {
            case WasmLinkMode.SdkOnly:
                coremode = "link";
                usermode = "copy";
                break;

            case WasmLinkMode.Full:
                coremode = "link";
                usermode = "link";
                break;

            default:
                coremode = "copyused";
                usermode = "copy";
                break;
            }

            arguments = arguments.AddRange("-c", coremode, "-u", usermode);

            //the linker doesn't consider these core by default
            arguments = arguments.AddRange("-p", coremode, "WebAssembly.Bindings");
            arguments = arguments.AddRange("-p", coremode, "WebAssembly.Net.Http");
            arguments = arguments.AddRange("-p", coremode, "WebAssembly.Net.WebSockets");

            if (!string.IsNullOrEmpty(LinkSkip))
            {
                var skips = LinkSkip.Split(new[] { ';', ',', ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var s in skips)
                {
                    arguments = arguments.AddRange("-p", "copy", s);
                }
            }

            arguments = arguments.AddRange("-out", OutputDir);

            arguments = arguments.AddRange("-d", FrameworkDir);

            arguments = arguments.AddRange("-d", Path.Combine(FrameworkDir, "Facades"));

            arguments = arguments.AddRange("-b", Debug.ToString());
            arguments = arguments.AddRange("-v", Debug.ToString());

            arguments = arguments.AddRange("-a", RootAssembly[0].GetMetadata("FullPath"));

            //we'll normally have to check most of the because the SDK references most framework asm by default
            //so let's enumerate upfront
            var frameworkAssemblies = new HashSet <string> (StringComparer.OrdinalIgnoreCase);

            foreach (var f in Directory.EnumerateFiles(FrameworkDir))
            {
                frameworkAssemblies.Add(Path.GetFileNameWithoutExtension(f));
            }
            foreach (var f in Directory.EnumerateFiles(Path.Combine(FrameworkDir, "Facades")))
            {
                frameworkAssemblies.Add(Path.GetFileNameWithoutExtension(f));
            }

            //add references for non-framework assemblies
            if (Assemblies != null)
            {
                foreach (var asm in Assemblies)
                {
                    var p = asm.GetMetadata("FullPath");
                    if (frameworkAssemblies.Contains(Path.GetFileNameWithoutExtension(p)))
                    {
                        continue;
                    }
                    arguments = arguments.AddRange("-r", p);
                }
            }

            if (string.IsNullOrEmpty(I18n))
            {
                arguments = arguments.AddRange("-l", "none");
            }
            else
            {
                var vals = I18n.Split(new[] { ',', ';', ' ', '\r', '\n', '\t' });
                arguments = arguments.AddRange("-l", string.Join(",", vals));
            }
            return(arguments.ToString());
        }
コード例 #31
0
 public void Quote(string unquoted, string quoted)
 => Assert.Equal(quoted, ProcessArguments.Quote(unquoted));