Ejemplo n.º 1
0
        public async Task TestInstallAsync()
        {
            var snapAppsReleases = new SnapAppsReleases();
            var genesisSnapApp   = _baseFixture.BuildSnapApp();

            Assert.True(genesisSnapApp.Channels.Count >= 2);

            using var testDirectory             = new DisposableDirectory(_baseFixture.WorkingDirectory, _snapFilesystem);
            using var genesisSnapReleaseBuilder = _baseFixture.WithSnapReleaseBuilder(testDirectory, snapAppsReleases, genesisSnapApp, _snapReleaseBuilderContext);
            var mainAssemblyDefinition = _baseFixture.BuildSnapExecutable(genesisSnapApp);

            genesisSnapReleaseBuilder
            .AddNuspecItem(mainAssemblyDefinition)
            .AddNuspecItem(mainAssemblyDefinition.BuildRuntimeConfigFilename(_snapFilesystem), mainAssemblyDefinition.BuildRuntimeConfig())
            .AddNuspecItem(_baseFixture.BuildLibrary("test1"))
            .AddSnapDll();

            using var genesisPackageContext = await _baseFixture.BuildPackageAsync(genesisSnapReleaseBuilder);

            var anyOs = SnapOs.AnyOs;

            Assert.NotNull(anyOs);

            var loggerMock = new Mock <ILog>();

            var progressSource = new Mock <ISnapProgressSource>();

            progressSource.
            Setup(x => x.Raise(It.IsAny <int>()));

            var failedRunAsyncReturnValues = new List <(int exitCode, string stdOut)>();

            var snapOsProcessManager = new Mock <ISnapOsProcessManager>();

            snapOsProcessManager
            .Setup(x => x.RunAsync(It.IsAny <ProcessStartInfoBuilder>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync((ProcessStartInfoBuilder builder, CancellationToken cancellationToken) =>
            {
                var result = _snapOsProcessManager.RunAsync(builder, cancellationToken).GetAwaiter().GetResult();
                if (result.exitCode != 0)
                {
                    failedRunAsyncReturnValues.Add(result);
                }
                return(result);
            });
            snapOsProcessManager
            .Setup(x => x.StartNonBlocking(It.IsAny <ProcessStartInfoBuilder>()))
            .Returns((ProcessStartInfoBuilder builder) => _snapOsProcessManager.StartNonBlocking(builder));
            snapOsProcessManager
            .Setup(x => x.ChmodExecuteAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns((string filename, CancellationToken cancellationToken) => _snapOsProcessManager.ChmodExecuteAsync(filename, cancellationToken));
            _snapOsMock
            .Setup(x => x.Filesystem)
            .Returns(_snapFilesystem);
            _snapOsMock
            .Setup(x => x.ProcessManager)
            .Returns(snapOsProcessManager.Object);
            _snapOsMock
            .Setup(x => x.CreateShortcutsForExecutableAsync(
                       It.IsAny <SnapOsShortcutDescription>(),
                       It.IsAny <ILog>(),
                       It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);

            using var baseDirectory = _baseFixture.WithDisposableTempDirectory(_snapFilesystem);
            using var installCts    = new CancellationTokenSource();
            var snapCurrentChannel = genesisPackageContext.FullPackageSnapApp.GetCurrentChannelOrThrow();

            await _snapInstaller.InstallAsync(
                genesisPackageContext.FullPackageAbsolutePath,
                baseDirectory.WorkingDirectory,
                genesisPackageContext.FullPackageSnapRelease,
                snapCurrentChannel,
                progressSource.Object,
                loggerMock.Object,
                installCts.Token);

            var appDirectory          = _snapFilesystem.PathCombine(baseDirectory.WorkingDirectory, $"app-{genesisPackageContext.FullPackageSnapApp.Version}");
            var snapAppUpdated        = appDirectory.GetSnapAppFromDirectory(_snapFilesystem, _snapAppReader);
            var snapAppUpdatedChannel = snapAppUpdated.GetCurrentChannelOrThrow();

            Assert.Equal(snapCurrentChannel.Name, snapAppUpdatedChannel.Name);

#if !PLATFORM_WINDOWS || NETFULLFRAMEWORK
            // TODO: ENABLE ME! Unable to run a dotnet 2.2 (shared) executable on Windows.
            Assert.Empty(failedRunAsyncReturnValues);
#endif

            var coreRunExe = _snapFilesystem.PathCombine(baseDirectory.WorkingDirectory,
                                                         _snapEmbeddedResources.GetCoreRunExeFilenameForSnapApp(genesisPackageContext.FullPackageSnapApp));
            var appExe = _snapFilesystem.PathCombine(baseDirectory.WorkingDirectory,
                                                     $"app-{genesisSnapReleaseBuilder.SnapApp.Version}", genesisSnapReleaseBuilder.CoreRunExe);
            var snapInstalledArguments = $"--snapx-installed {genesisPackageContext.FullPackageSnapApp.Version.ToNormalizedString()}";
            var snapFirstRunArguments  = $"--snapx-first-run {genesisPackageContext.FullPackageSnapApp.Version.ToNormalizedString()}";

            progressSource.Verify(x => x.Raise(It.Is <int>(v => v == 100)), Times.Once);

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                snapOsProcessManager.Verify(x => x.ChmodExecuteAsync(
                                                It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Exactly(2));
                snapOsProcessManager.Verify(x => x.ChmodExecuteAsync(
                                                It.Is <string>(v => v == coreRunExe), It.Is <CancellationToken>(v => v == installCts.Token)), Times.Once);
                snapOsProcessManager.Verify(x => x.ChmodExecuteAsync(
                                                It.Is <string>(v => v == appExe), It.Is <CancellationToken>(v => v == installCts.Token)), Times.Once);
            }

            _snapOsMock.Verify(x => x.KillAllProcessesInsideDirectory(
                                   It.Is <string>(v => v == baseDirectory.WorkingDirectory)), Times.Once);

            _snapOsMock.Verify(x => x.CreateShortcutsForExecutableAsync(
                                   It.IsAny <SnapOsShortcutDescription>(), It.IsAny <ILog>(),
                                   It.IsAny <CancellationToken>()), Times.Once);

            _snapOsMock.Verify(x => x.CreateShortcutsForExecutableAsync(
                                   It.Is <SnapOsShortcutDescription>(v => v.ExeAbsolutePath == coreRunExe),
                                   It.Is <ILog>(v => v != null), It.Is <CancellationToken>(v => v == installCts.Token)), Times.Once);

            snapOsProcessManager.Verify(x => x.RunAsync(
                                            It.IsAny <ProcessStartInfoBuilder>(), It.IsAny <CancellationToken>()), Times.Once);

            snapOsProcessManager.Verify(x => x.RunAsync(
                                            It.Is <ProcessStartInfoBuilder>(v => v.Filename == appExe &&
                                                                            v.Arguments == snapInstalledArguments),
                                            It.Is <CancellationToken>(v => v == installCts.Token)), Times.Once);

            snapOsProcessManager.Verify(x => x.StartNonBlocking(
                                            It.Is <ProcessStartInfoBuilder>(v => v.Filename == appExe
                                                                            & v.Arguments == snapFirstRunArguments)), Times.Once);
            snapOsProcessManager.Verify(x => x.StartNonBlocking(
                                            It.IsAny <ProcessStartInfoBuilder>()), Times.Once);
        }
Ejemplo n.º 2
0
        static int Install([NotNull] ISnapInstallerEnvironment environment,
                           [NotNull] ISnapInstallerEmbeddedResources snapInstallerEmbeddedResources, [NotNull] ISnapInstaller snapInstaller,
                           [NotNull] ISnapFilesystem snapFilesystem, [NotNull] ISnapPack snapPack, [NotNull] ISnapOs snapOs,
                           [NotNull] CoreRunLib coreRunLib, [NotNull] ISnapAppReader snapAppReader, [NotNull] ISnapAppWriter snapAppWriter,
                           [NotNull] INugetService nugetService, [NotNull] ISnapPackageManager snapPackageManager,
                           [NotNull] ISnapExtractor snapExtractor, [NotNull] ILog diskLogger,
                           bool headless)
        {
            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }
            if (snapInstallerEmbeddedResources == null)
            {
                throw new ArgumentNullException(nameof(snapInstallerEmbeddedResources));
            }
            if (snapInstaller == null)
            {
                throw new ArgumentNullException(nameof(snapInstaller));
            }
            if (snapFilesystem == null)
            {
                throw new ArgumentNullException(nameof(snapFilesystem));
            }
            if (snapPack == null)
            {
                throw new ArgumentNullException(nameof(snapPack));
            }
            if (snapOs == null)
            {
                throw new ArgumentNullException(nameof(snapOs));
            }
            if (coreRunLib == null)
            {
                throw new ArgumentNullException(nameof(coreRunLib));
            }
            if (snapAppReader == null)
            {
                throw new ArgumentNullException(nameof(snapAppReader));
            }
            if (snapAppWriter == null)
            {
                throw new ArgumentNullException(nameof(snapAppWriter));
            }
            if (nugetService == null)
            {
                throw new ArgumentNullException(nameof(nugetService));
            }
            if (snapPackageManager == null)
            {
                throw new ArgumentNullException(nameof(snapPackageManager));
            }
            if (snapExtractor == null)
            {
                throw new ArgumentNullException(nameof(snapExtractor));
            }
            if (diskLogger == null)
            {
                throw new ArgumentNullException(nameof(diskLogger));
            }

            // NB! All filesystem operations has to be readonly until check that verifies
            // current user is not elevated to root has run.

            var cancellationToken             = environment.CancellationToken;
            var installerProgressSource       = new SnapProgressSource();
            var onFirstAnimationRenderedEvent = new ManualResetEventSlim(false);
            var exitCode = 1;

            // ReSharper disable once ImplicitlyCapturedClosure

            async Task InstallInBackgroundAsync(IMainWindowViewModel mainWindowViewModel)
            {
                if (mainWindowViewModel == null)
                {
                    throw new ArgumentNullException(nameof(mainWindowViewModel));
                }

                if (mainWindowViewModel.Headless)
                {
                    diskLogger.Info("Headless install.");
                    onFirstAnimationRenderedEvent.Dispose();
                }
                else
                {
                    diskLogger.Info("Waiting for main window to become visible.");
                    onFirstAnimationRenderedEvent.Wait(cancellationToken);
                    onFirstAnimationRenderedEvent.Dispose();
                    diskLogger.Info("Main window should now be visible.");
                }

                var mainWindowLogger = new LogForwarder(LogLevel.Info, diskLogger, (level, func, exception, parameters) =>
                {
                    var message = func?.Invoke();
                    if (message == null)
                    {
                        return;
                    }

                    SetStatusText(mainWindowViewModel, message);
                });

                if (coreRunLib.IsElevated())
                {
                    var rootUserText = snapOs.OsPlatform == OSPlatform.Windows ? "Administrator" : "root";
                    mainWindowLogger.Error($"Error! Installer cannot run in an elevated user context: {rootUserText}");
                    goto done;
                }

                diskLogger.Debug($"{nameof(environment.Io.WorkingDirectory)}: {environment.Io.WorkingDirectory}");
                diskLogger.Debug($"{nameof(environment.Io.ThisExeWorkingDirectory)}: {environment.Io.ThisExeWorkingDirectory}");

                var snapAppDllAbsolutePath = snapFilesystem.PathCombine(environment.Io.ThisExeWorkingDirectory, SnapConstants.SnapAppDllFilename);

                diskLogger.Debug($"{nameof(snapAppDllAbsolutePath)}: {snapAppDllAbsolutePath}.");

                if (!snapFilesystem.FileExists(snapAppDllAbsolutePath))
                {
                    mainWindowLogger.Info($"Unable to find: {snapFilesystem.PathGetFileName(snapAppDllAbsolutePath)}");
                    goto done;
                }

                SnapApp     snapApp;
                SnapChannel snapChannel;

                try
                {
                    snapApp     = environment.Io.ThisExeWorkingDirectory.GetSnapAppFromDirectory(snapFilesystem, snapAppReader);
                    snapChannel = snapApp.GetCurrentChannelOrThrow();
                }
                catch (Exception ex)
                {
                    mainWindowLogger.ErrorException($"Error reading {SnapConstants.SnapAppDllFilename}", ex);
                    goto done;
                }

                var nupkgAbsolutePath         = snapFilesystem.PathCombine(environment.Io.ThisExeWorkingDirectory, "Setup.nupkg");
                var nupkgReleasesAbsolutePath = snapFilesystem.PathCombine(environment.Io.ThisExeWorkingDirectory, snapApp.BuildNugetReleasesFilename());
                var offlineInstaller          = false;

                using (var webInstallerDir = new DisposableDirectory(snapOs.SpecialFolders.NugetCacheDirectory, snapFilesystem))
                {
                    ISnapAppChannelReleases snapAppChannelReleases;
                    SnapRelease             snapReleaseToInstall;

                    // Offline installer
                    if (snapFilesystem.FileExists(nupkgAbsolutePath))
                    {
                        mainWindowLogger.Info("Offline installer is loading releases nupkg");

                        try
                        {
                            var releasesFileStream = snapFilesystem.FileRead(nupkgReleasesAbsolutePath);
                            using var packageArchiveReader = new PackageArchiveReader(releasesFileStream);
                            var snapAppsReleases = await snapExtractor.GetSnapAppsReleasesAsync(packageArchiveReader, snapAppReader, cancellationToken);

                            snapAppChannelReleases = snapAppsReleases.GetReleases(snapApp, snapChannel);
                            var isGenesis = !snapAppChannelReleases.HasDeltaReleases();
                            snapReleaseToInstall = snapAppChannelReleases.GetMostRecentRelease().AsFullRelease(isGenesis);
                        }
                        catch (Exception e)
                        {
                            mainWindowLogger.ErrorException($"Error reading {nupkgAbsolutePath}", e);
                            goto done;
                        }

                        offlineInstaller = true;
                    }
                    // Web installer
                    else if (snapFilesystem.FileExists(snapAppDllAbsolutePath))
                    {
                        mainWindowLogger.Info("Web installer is downloading releases nupkg");

                        try
                        {
                            var(snapAppsReleases, packageSource, releasesMemoryStream) =
                                await snapPackageManager.GetSnapsReleasesAsync(snapApp, mainWindowLogger, cancellationToken);

                            releasesMemoryStream?.Dispose();
                            if (snapAppsReleases == null)
                            {
                                mainWindowLogger.Error("Failed to download releases nupkg. Try rerunning the installer.");
                                goto done;
                            }

                            var snapAppsReleasesBytes = snapAppWriter.ToSnapAppsReleases(snapAppsReleases);
                            await snapFilesystem.FileWriteAsync(snapAppsReleasesBytes, nupkgReleasesAbsolutePath, cancellationToken);

                            snapAppChannelReleases = snapAppsReleases.GetReleases(snapApp, snapApp.GetCurrentChannelOrThrow());
                            if (!snapAppChannelReleases.Any())
                            {
                                mainWindowLogger.Error($"Unable to find any releases in channel: {snapAppChannelReleases.Channel.Name}.");
                                goto done;
                            }

                            var isGenesis = snapAppChannelReleases.Count() == 1;
                            snapReleaseToInstall = snapAppChannelReleases.GetMostRecentRelease().AsFullRelease(isGenesis);
                            snapApp.Version      = snapReleaseToInstall.Version;

                            mainWindowLogger.Info($"Current version: {snapApp.Version}. Channel: {snapAppChannelReleases.Channel.Name}.");

                            // ReSharper disable once MethodSupportsCancellation
                            await Task.Delay(TimeSpan.FromSeconds(3));

                            mainWindowLogger.Info("Downloading required assets");

                            void UpdateProgress(string type, int totalPercentage,
                                                long releasesChecksummed  = 0, long releasesToChecksum   = 0,
                                                long releasesDownloaded   = 0, long releasesToDownload   = 0,
                                                long filesRestored        = 0, long filesToRestore       = 0,
                                                long totalBytesDownloaded = 0, long totalBytesToDownload = 0)
                            {
                                void SetProgressText(long current, long total, string defaultText, string pluralText)
                                {
                                    var outputText = total > 1 ? pluralText : defaultText;

                                    switch (type)
                                    {
                                    case "Download":
                                        if (total > 1)
                                        {
                                            SetStatusText(mainWindowViewModel,
                                                          $"{outputText} ({totalPercentage}%): {current} of {total}. " +
                                                          $"Downloaded so far: {totalBytesDownloaded.BytesAsHumanReadable()}. " +
                                                          $"Total: {totalBytesToDownload.BytesAsHumanReadable()}");

                                            goto incrementProgress;
                                        }

                                        SetStatusText(mainWindowViewModel,
                                                      $"{outputText} ({totalPercentage}%): " +
                                                      $"Downloaded so far: {totalBytesDownloaded.BytesAsHumanReadable()}. " +
                                                      $"Total: {totalBytesToDownload.BytesAsHumanReadable()}");

                                        goto incrementProgress;

                                    default:
                                        if (total > 1)
                                        {
                                            SetStatusText(mainWindowViewModel, $"{outputText} ({totalPercentage}%): {current} of {total}.");
                                            goto incrementProgress;
                                        }

                                        SetStatusText(mainWindowViewModel, $"{outputText}: {totalPercentage}%");
                                        goto incrementProgress;
                                    }

incrementProgress:
                                    installerProgressSource.Raise(totalPercentage);
                                }

                                switch (type)
                                {
                                case "Checksum":
                                    SetProgressText(releasesChecksummed, releasesToChecksum, "Validating payload", "Validating payloads");
                                    break;

                                case "Download":
                                    SetProgressText(releasesDownloaded, releasesToDownload, "Downloading payload", "Downloading payloads");
                                    break;

                                case "Restore":
                                    SetProgressText(filesRestored, filesToRestore, "Restoring file", "Restoring files");
                                    break;

                                default:
                                    diskLogger.Warn($"Unknown progress type: {type}");
                                    break;
                                }
                            }

                            var snapPackageManagerProgressSource = new SnapPackageManagerProgressSource
                            {
                                ChecksumProgress = x => UpdateProgress("Checksum",
                                                                       x.progressPercentage,
                                                                       x.releasesChecksummed,
                                                                       x.releasesToChecksum),
                                DownloadProgress = x => UpdateProgress("Download",
                                                                       x.progressPercentage,
                                                                       releasesDownloaded: x.releasesDownloaded,
                                                                       releasesToDownload: x.releasesToDownload,
                                                                       totalBytesDownloaded: x.totalBytesDownloaded,
                                                                       totalBytesToDownload: x.totalBytesToDownload),
                                RestoreProgress = x => UpdateProgress("Restore",
                                                                      x.progressPercentage,
                                                                      filesRestored: x.filesRestored,
                                                                      filesToRestore: x.filesToRestore)
                            };

                            var restoreSummary = await snapPackageManager.RestoreAsync(webInstallerDir.WorkingDirectory, snapAppChannelReleases,
                                                                                       packageSource, SnapPackageManagerRestoreType.Default, snapPackageManagerProgressSource, diskLogger, cancellationToken);

                            if (!restoreSummary.Success)
                            {
                                mainWindowLogger.Info("Unknown error while restoring assets.");
                                goto done;
                            }

                            mainWindowLogger.Info("Preparing to install payload");

                            var setupNupkgAbsolutePath = snapOs.Filesystem.PathCombine(webInstallerDir.WorkingDirectory, snapReleaseToInstall.Filename);
                            if (!snapFilesystem.FileExists(setupNupkgAbsolutePath))
                            {
                                mainWindowLogger.Error($"Payload does not exist on disk: {setupNupkgAbsolutePath}.");
                                goto done;
                            }

                            nupkgAbsolutePath = snapFilesystem.PathCombine(environment.Io.ThisExeWorkingDirectory, "Setup.nupkg");

                            mainWindowLogger.Info("Copying payload to installer directory");

                            snapOs.Filesystem.FileDeleteIfExists(nupkgAbsolutePath);
                            await snapOs.Filesystem.FileCopyAsync(setupNupkgAbsolutePath, nupkgAbsolutePath, cancellationToken);

                            mainWindowLogger.Info("Successfully copied payload");

                            installerProgressSource.Reset();
                        }
                        catch (Exception e)
                        {
                            mainWindowLogger.ErrorException("Unknown error while restoring assets", e);
                            goto done;
                        }
                    }
                    else
                    {
                        mainWindowLogger.Error("Unknown error. Could not find offline or web installer payload.");
                        goto done;
                    }

                    diskLogger.Trace($"Offline installer: {offlineInstaller}");
                    diskLogger.Trace($"{nameof(nupkgAbsolutePath)}: {nupkgAbsolutePath}");
                    diskLogger.Trace($"{nameof(nupkgReleasesAbsolutePath)}: {nupkgReleasesAbsolutePath}");

                    if (!snapFilesystem.FileExists(nupkgAbsolutePath))
                    {
                        mainWindowLogger.Error($"Unable to find installer payload: {snapFilesystem.PathGetFileName(nupkgAbsolutePath)}");
                        goto done;
                    }

                    mainWindowLogger.Info("Attempting to read payload release details");

                    if (!snapFilesystem.FileExists(nupkgReleasesAbsolutePath))
                    {
                        mainWindowLogger.Error($"Unable to find releases nupkg: {snapFilesystem.PathGetFileName(nupkgReleasesAbsolutePath)}");
                        goto done;
                    }

                    var baseDirectory = snapFilesystem.PathCombine(snapOs.SpecialFolders.LocalApplicationData, snapApp.Id);

                    mainWindowLogger.Info($"Installing {snapApp.Id}. Channel name: {snapChannel.Name}");

                    try
                    {
                        var snapAppInstalled = await snapInstaller.InstallAsync(nupkgAbsolutePath, baseDirectory,
                                                                                snapReleaseToInstall, snapChannel, installerProgressSource, mainWindowLogger, cancellationToken, offlineInstaller);

                        if (snapAppInstalled == null)
                        {
                            goto done;
                        }

                        if (!offlineInstaller &&
                            snapAppChannelReleases.HasDeltaReleases())
                        {
                            var snapReleasesToCopy = new List <SnapRelease>
                            {
                                snapAppChannelReleases.GetGenesisRelease()
                            };

                            snapReleasesToCopy.AddRange(snapAppChannelReleases.GetDeltaReleases());

                            if (snapReleasesToCopy.Any())
                            {
                                var totalSnapReleasesToCopyCount = snapReleasesToCopy.Count;

                                mainWindowLogger.Info($"Copying 1 of {totalSnapReleasesToCopyCount} payloads to application directory.");

                                var packagesDirectory  = snapFilesystem.PathCombine(baseDirectory, "packages");
                                var snapReleasesCopied = 1;
                                foreach (var snapRelease in snapReleasesToCopy)
                                {
                                    var nupkgPackageWebInstallerDirectoryAbsolutePath = snapFilesystem.PathCombine(
                                        webInstallerDir.WorkingDirectory, snapRelease.Filename);

                                    var nupkgPackagePackagesDirectoryAbsolutePath = snapFilesystem.PathCombine(
                                        packagesDirectory, snapRelease.Filename);

                                    await snapFilesystem.FileCopyAsync(
                                        nupkgPackageWebInstallerDirectoryAbsolutePath,
                                        nupkgPackagePackagesDirectoryAbsolutePath, cancellationToken);

                                    mainWindowLogger.Info($"Copied {snapReleasesCopied} of {totalSnapReleasesToCopyCount} payloads to application directory.");
                                    ++snapReleasesCopied;
                                }

                                mainWindowLogger.Info("Successfully copied all payloads.");
                            }

                            snapFilesystem.FileDeleteIfExists(nupkgAbsolutePath);
                        }

                        mainWindowLogger.Info($"Successfully installed {snapApp.Id}.");

                        exitCode = 0;
                    }
                    catch (Exception e)
                    {
                        mainWindowLogger.ErrorException("Unknown error during install", e);
                    }
                }

done:
                // Give user enough time to read final log message.
                Thread.Sleep(exitCode == 0 ? 3000 : 10000);
                environment.Shutdown();
            }

            if (headless)
            {
                try
                {
                    InstallInBackgroundAsync(new ConsoleMainViewModel()).Wait(cancellationToken);
                }
                catch (OperationCanceledException)
                {
                    // ignore
                }
                return(exitCode);
            }

            var avaloniaApp = BuildAvaloniaApp <App>()
                              .AfterSetup(builder =>
            {
                MainWindow.Environment = environment;
                MainWindow.ViewModel   = new AvaloniaMainWindowViewModel(snapInstallerEmbeddedResources,
                                                                         installerProgressSource, () => onFirstAnimationRenderedEvent.Set(), cancellationToken);

                Task.Factory.StartNew(() => InstallInBackgroundAsync(MainWindow.ViewModel), TaskCreationOptions.LongRunning);
            });

            avaloniaApp.StartWithClassicDesktopLifetime(null);

            return(exitCode);
        }