BuildRunStub() static private method

Builds a stub EXE that executes the "0install run" command.
The user canceled the task. There was a compilation error while generating the stub EXE. A problem occurs while writing to the filesystem. A problem occured while downloading additional data (such as icons). Write access to the filesystem is not permitted.
static private BuildRunStub ( FeedTarget target, [ path, [ handler, bool needsTerminal, [ command = null ) : void
target ZeroInstall.Store.FeedTarget The application to be launched via the stub.
path [ The target path to store the generated EXE file.
handler [ A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.
needsTerminal bool true to build a CLI stub, false to build a GUI stub.
command [ The command argument to be passed to the the "0install run" command; can be null.
return void
Exemplo n.º 1
0
        /// <summary>
        /// Creates an application alias in the current system.
        /// </summary>
        /// <param name="target">The application being integrated.</param>
        /// <param name="command">The command within <paramref name="target"/> the alias shall point to; can be <c>null</c>.</param>
        /// <param name="aliasName">The name of the alias to be created.</param>
        /// <param name="machineWide">Create the alias machine-wide instead of just for the current user.</param>
        /// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param>
        /// <exception cref="OperationCanceledException">The user canceled the task.</exception>
        /// <exception cref="IOException">A problem occurs while writing to the filesystem or registry.</exception>
        /// <exception cref="WebException">A problem occured while downloading additional data (such as icons).</exception>
        /// <exception cref="UnauthorizedAccessException">Write access to the filesystem or registry is not permitted.</exception>
        public static void Create(FeedTarget target, [CanBeNull] string command, [NotNull] string aliasName, bool machineWide, [NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(aliasName))
            {
                throw new ArgumentNullException(nameof(aliasName));
            }
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }
            #endregion

            if (string.IsNullOrEmpty(aliasName) || aliasName.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
            {
                throw new IOException(string.Format(Resources.NameInvalidChars, aliasName));
            }

            string stubDirPath = GetStubDir(machineWide);
            PathEnv.AddDir(stubDirPath, machineWide);

            string stubFilePath = Path.Combine(stubDirPath, aliasName + ".exe");
            StubBuilder.BuildRunStub(target, stubFilePath, handler, needsTerminal: true, command: command);
            AddToAppPaths(aliasName + ".exe", stubFilePath, machineWide);
        }
Exemplo n.º 2
0
        public void TestBuildStubNeedsTerminal()
        {
            Skip.IfNot(WindowsUtils.IsWindows, "StubBuilder is only used on Windows");

            var target = new FeedTarget(FeedTest.Test1Uri, FeedTest.CreateTestFeed());

            using var tempFile = new TemporaryFile("0install-unit-tests");
            StubBuilder.BuildRunStub(target, tempFile, _iconStoreMock.Object, needsTerminal: true);
        }
Exemplo n.º 3
0
        public void TestBuildStubNeedsTerminal()
        {
            if (!WindowsUtils.IsWindows)
            {
                Assert.Ignore("StubBuilder is only used on Windows");
            }

            var target = new FeedTarget(FeedTest.Test1Uri, FeedTest.CreateTestFeed());

            using (var tempFile = new TemporaryFile("0install-unit-tests"))
                StubBuilder.BuildRunStub(target, tempFile, new SilentTaskHandler(), needsTerminal: true);
        }