static private BuildRunStub ( |
||
target | 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 | |
command | [ | The command argument to be passed to the the "0install run" command; can be |
Résultat | void |
/// <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); }
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); }
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); }