コード例 #1
0
        private static async Task UninstallPackage(NugetStore store, NugetPackage package, ProgressReport progressReport)
        {
            await store.UninstallPackage(package, progressReport);

            // If package is GameStudio, then recursively delete its Stride/Xenko dependencies to save more disk space
            if (store.MainPackageIds.Contains(package.Id))
            {
                await UninstallDependencies(store, package);
            }
        }
コード例 #2
0
 // Uninstall a package
 public void UninstallPackage(IPackage package, Action onComplete = null)
 {
     downloadThreads.Add(RunThread(() =>
     {
         if (!isSafeToProcess())
         {
             return;
         }
         Info("Preparing Uninstallation");
         OnProcessing();
         store.UninstallPackage(package);
         SdkVersionManager.synchronizeData();
         OnSDKVersionsUpdated();
         Info("");
         OnIdle();
         if (onComplete != null)
         {
             onComplete();
         }
     }));
 }
コード例 #3
0
        private static async Task UninstallDependencies(NugetStore store, NugetPackage package)
        {
            foreach (var dependency in package.Dependencies)
            {
                string dependencyId       = dependency.Item1;
                string dependencyIdPrefix = dependencyId.Split('.').First();
                PackageVersionRange dependencyVersionRange = dependency.Item2;

                // Dependency must be from Stride/Xenko and package version must match exactly
                if (((dependencyIdPrefix == "Stride") || (dependencyIdPrefix == "Xenko")) && (dependencyVersionRange.Contains(package.Version)))
                {
                    NugetPackage dependencyPackage = store.FindLocalPackage(dependencyId, package.Version);
                    if (dependencyPackage != null)
                    {
                        await store.UninstallPackage(dependencyPackage, null);
                        await UninstallDependencies(store, dependencyPackage);
                    }
                }
            }
        }
コード例 #4
0
        private static LauncherErrorCode Uninstall()
        {
            try
            {
                // Kill all running processes
                var path = new UFile(Assembly.GetEntryAssembly().Location).GetFullDirectory().ToWindowsPath();
                if (!UninstallHelper.CloseProcessesInPath(DisplayMessage, "Stride", path))
                {
                    return(LauncherErrorCode.UninstallCancelled); // User cancelled
                }
                // Uninstall packages (they might have uninstall actions)
                var store = new NugetStore(path);
                foreach (var package in store.MainPackageIds.SelectMany(store.GetLocalPackages).FilterStrideMainPackages().ToList())
                {
                    store.UninstallPackage(package, null).Wait();
                }

                foreach (var remainingFiles in Directory.GetFiles(path, "*.lock").Concat(Directory.GetFiles(path, "*.old")))
                {
                    try
                    {
                        File.Delete(remainingFiles);
                    }
                    catch (Exception e)
                    {
                        e.Ignore();
                    }
                }

                PrivacyPolicyHelper.RevokeAllPrivacyPolicy();

                return(LauncherErrorCode.Success);
            }
            catch (Exception)
            {
                return(LauncherErrorCode.ErrorWhileUninstalling);
            }
        }
コード例 #5
0
        public async Task CheckDeveloperTargetRedirects(string id, PackageVersion version, string realPath)
        {
            var nupkgFile = Path.Combine(Environment.ExpandEnvironmentVariables(store.DevSource), $"{id}.{version}.nupkg");

            var isRedirectToCurrentPath = false;
            var installedPackage        = store.GetLocalPackages(id).FirstOrDefault(x => x.Version == version);

            if (installedPackage != null)
            {
                var redirectFile = Path.Combine(installedPackage.Path, $@"{id}.redirect");
                if (File.Exists(redirectFile) && String.Compare(File.ReadAllText(redirectFile), realPath, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    isRedirectToCurrentPath = true;
                }
            }

            // Note: later, we could do better and check existing package contents and scan for differences?
            // We could also delete older packages using same path
            if (File.Exists(nupkgFile) && isRedirectToCurrentPath)
            {
                return;
            }

            Directory.CreateDirectory(Path.GetDirectoryName(nupkgFile));

            var builder = new NugetPackageBuilder();
            var meta    = new PackageMeta
            {
                Name        = id,
                Version     = version,
                Authors     = { $"{id} developers" },
                Description = $"{id} developer package using {realPath}",
            };
            var nugetMeta = new ManifestMetadata();

            ToNugetManifest(meta, nugetMeta);

            builder.Populate(nugetMeta);
            // Note: path must exist (created in NugetStore ctor)
            using (var tempDirectory = new TemporaryDirectory())
            {
                // Generate fake files
                Directory.CreateDirectory(Path.Combine(tempDirectory.DirectoryPath, "build"));
                var files = new List <ManifestFile>();
                foreach (var buildFileExtension in new[] { "targets", "props" })
                {
                    var source = Path.Combine(tempDirectory.DirectoryPath, $@"build\{id}.{buildFileExtension}");
                    File.WriteAllText(source, $@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" >
  <Import Project=""{realPath}\Targets\Xenko.{buildFileExtension}"" />
</Project>
");
                    files.Add(new ManifestFile {
                        Source = source, Target = $@"build\{id}.{buildFileExtension}"
                    });
                }

                var redirectFile = Path.Combine(tempDirectory.DirectoryPath, $"{id}.redirect");
                File.WriteAllText(redirectFile, realPath);
                files.Add(new ManifestFile {
                    Source = redirectFile, Target = $@"{id}.redirect"
                });

                builder.PopulateFiles(".", files);
                using (var nupkgStream = File.OpenWrite(nupkgFile))
                {
                    builder.Save(nupkgStream);
                }
            }

            // If package is already installed in cache so that it will force reinstallation.
            if (installedPackage != null)
            {
                await store.UninstallPackage(installedPackage, null);
            }

            await store.InstallPackage(id, version, null);
        }