Ejemplo n.º 1
0
 public void ParseDirectoryNamesTest()
 {
     foreach (var f in directoryNames)
     {
         if (DirectoryNameSturcture.IsValidPackageDir(f))
         {
             var d = new DirectoryNameSturcture(f);
             Assert.IsNotNull(d);
             Assert.IsNotNull(d.FullPath);
             Assert.IsNotNull(d.PackageName);
             Assert.IsNotNull(d.Version);
         }
         else
         {
             System.Console.WriteLine("Not a valid dir: " + f);
             Assert.ThrowsException <ArgumentException>(
                 () => new DirectoryNameSturcture(f));
         }
     }
 }
        static void Main(string[] argv)
        {
            if (argv.Length != 1)
            {
                System.Console.WriteLine(
                    "\nUsage: dotnet CleanupOfflineInstallDirectory c:\\offlineinstalldir\n\n");
                return;
            }
            System.Console.WriteLine($"\nCleanup: {argv[0]}\n\n");

            var VSOfflineInstallPath = argv[0];

            var dirNames = Directory.GetDirectories(VSOfflineInstallPath)
                           .Where(s => DirectoryNameSturcture.IsValidPackageDir(s));

            var DNStruct = new PackageList(dirNames);

            foreach (var p in DNStruct.OldVersions)
            {
                System.Console.WriteLine($"Deleing:  \"{p.FullPath}\"");
                Directory.Delete(p.FullPath, true);
            }
        }