Exemple #1
0
        public TempOutputFixture()
        {
            DirPath = Path.Combine(
                Path.GetDirectoryName(typeof(TempOutputFixture).Assembly.Location) !,
                "Temp",
                Interlocked.Increment(ref _instanceCount).ToString()
                );

            DirectoryEx.Reset(DirPath);
        }
Exemple #2
0
        /// <inheritdoc />
        public async Task PrepareUpdateAsync(Version version,
                                             IProgress <double> progress = null, CancellationToken cancellationToken = default)
        {
            version.GuardNotNull(nameof(version));

            // Ensure that the current state is valid for this operation
            EnsureNotDisposed();
            EnsureLockFileAcquired();
            EnsureUpdaterNotLaunched();

            // Set up progress mixer
            var progressMixer = progress != null ? new ProgressMixer(progress) : null;

            // Get package file path and content directory path
            var packageFilePath       = GetPackageFilePath(version);
            var packageContentDirPath = GetPackageContentDirPath(version);

            // Ensure storage directory exists
            Directory.CreateDirectory(_storageDirPath);

            // Download package
            await _resolver.DownloadPackageAsync(version, packageFilePath,
                                                 progressMixer?.Split(0.9), // 0% -> 90%
                                                 cancellationToken);

            // Ensure package content directory exists and is empty
            DirectoryEx.Reset(packageContentDirPath);

            // Extract package contents
            await _extractor.ExtractPackageAsync(packageFilePath, packageContentDirPath,
                                                 progressMixer?.Split(0.1), // 90% -> 100%
                                                 cancellationToken);

            // Delete package
            File.Delete(packageFilePath);

            //Extract runtimeconfig.json
            await Assembly.GetExecutingAssembly().ExtractManifestResourceAsync(UpdaterRuntimeConfigResourceName, _runtimeconfigFilePath);

            // Extract updater
            await Assembly.GetExecutingAssembly().ExtractManifestResourceAsync(UpdaterResourceName, _updaterFilePath);
        }
Exemple #3
0
        /// <inheritdoc />
        public async Task PrepareUpdateAsync(Version version,
                                             IProgress <double> progress         = null,
                                             CancellationToken cancellationToken = default(CancellationToken))
        {
            version.GuardNotNull(nameof(version));

            // Set up progress mixer
            var progressMixer = progress != null ? new ProgressMixer(progress) : null;

            // Get package file path and content directory path
            var packageFilePath       = GetPackageFilePath(version);
            var packageContentDirPath = GetPackageContentDirPath(version);

            // Create storage directory
            Directory.CreateDirectory(_storageDirPath);

            // Download package
            await _resolver.DownloadAsync(version, packageFilePath,
                                          progressMixer?.Split(0.9), // 0% -> 90%
                                          cancellationToken).ConfigureAwait(false);

            // Create directory for package contents
            DirectoryEx.Reset(packageContentDirPath);

            // Extract package contents
            await _extractor.ExtractAsync(packageFilePath, packageContentDirPath,
                                          progressMixer?.Split(0.1), // 90% -> 100%
                                          cancellationToken).ConfigureAwait(false);

            // Delete package
            File.Delete(packageFilePath);

            // Extract updater
            await Assembly.GetExecutingAssembly().ExtractManifestResourceAsync(UpdaterResourceName, _updaterFilePath)
            .ConfigureAwait(false);
        }
Exemple #4
0
 public void Setup()
 {
     // Create temp directory
     DirectoryEx.Reset(TempDirPath);
 }
 public void Setup()
 {
     // Ensure temp directory exists and is empty
     DirectoryEx.Reset(TempDirPath);
 }