-
Notifications
You must be signed in to change notification settings - Fork 2
/
vs2017_offline_clean.cs
69 lines (65 loc) · 2.02 KB
/
vs2017_offline_clean.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
class Program
{
static void Main(string[] args)
{
string path = string.Empty;
if (args.Length == 0)
{
path = Directory.GetCurrentDirectory();
}
else
{
path = args[0];
}
if (path.EndsWith("\\") == false) path += "\\";
string catalog = path + "catalog.json";
if (File.Exists(catalog) == false)
{
Console.WriteLine("Please copy this program to the VS2017 offline folder.");
return;
}
Console.WriteLine(path);
string old = Directory.CreateDirectory(path + "- old -").FullName;
var o = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(catalog));
var folders = Directory.GetDirectories(path);
var packages = o["packages"];
foreach (var folder in folders)
{
var foldername = Path.GetFileName(folder);
var splitstring = foldername.Split(',');
bool found = false;
if (splitstring.Length > 1)
{
foreach (var package in packages)
{
if (package["id"].ToString() == splitstring[0] &&
package["version"] == splitstring[1].Split('=')[1].Trim())
{
found = true;
break;
}
}
}
else
{
found = true;
Console.WriteLine("not found in packages : " + foldername);
}
if (found == false)
{
// move directory
Console.WriteLine("moving folder : " + foldername);
Directory.Move(folder, old + "\\" + foldername);
}
}
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}