├── .editorconfig ├── .gitignore ├── BuildTools.sln ├── BuildTools ├── App.config ├── BuildTools.Designer.cs ├── BuildTools.cs ├── BuildTools.csproj ├── BuildTools.resx ├── ILMerge.props ├── ILMergeOrder.txt ├── JobObject.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ ├── Settings.settings │ └── app.manifest ├── Runner.cs ├── icon.ico └── packages.config ├── LICENSE.txt ├── Packages.dgml ├── UninstallJava ├── App.config ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Settings.Designer.cs │ ├── Settings.settings │ └── app.manifest └── UninstallJava.csproj ├── readme.md └── web └── buildtools.json /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CA1031: Do not catch general exception types 4 | dotnet_diagnostic.CA1031.severity = none 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | 154 | # Windows Azure Build Output 155 | csx/ 156 | *.build.csdef 157 | 158 | # Windows Store app package directory 159 | AppPackages/ 160 | 161 | # Visual Studio cache files 162 | # files ending in .cache can be ignored 163 | *.[Cc]ache 164 | # but keep track of directories ending in .cache 165 | !*.[Cc]ache/ 166 | 167 | # Others 168 | ClientBin/ 169 | [Ss]tyle[Cc]op.* 170 | ~$* 171 | *~ 172 | *.dbmdl 173 | *.dbproj.schemaview 174 | *.pfx 175 | *.publishsettings 176 | node_modules/ 177 | orleans.codegen.cs 178 | 179 | # RIA/Silverlight projects 180 | Generated_Code/ 181 | 182 | # Backup & report files from converting an old project file 183 | # to a newer Visual Studio version. Backup files are not needed, 184 | # because we have git ;-) 185 | _UpgradeReport_Files/ 186 | Backup*/ 187 | UpgradeLog*.XML 188 | UpgradeLog*.htm 189 | 190 | # SQL Server files 191 | *.mdf 192 | *.ldf 193 | 194 | # Business Intelligence projects 195 | *.rdl.data 196 | *.bim.layout 197 | *.bim_*.settings 198 | 199 | # Microsoft Fakes 200 | FakesAssemblies/ 201 | 202 | # Node.js Tools for Visual Studio 203 | .ntvs_analysis.dat 204 | 205 | # Visual Studio 6 build log 206 | *.plg 207 | 208 | # Visual Studio 6 workspace options file 209 | *.opt 210 | 211 | # Visual Studio LightSwitch build output 212 | **/*.HTMLClient/GeneratedArtifacts 213 | **/*.DesktopClient/GeneratedArtifacts 214 | **/*.DesktopClient/ModelManifest.xml 215 | **/*.Server/GeneratedArtifacts 216 | **/*.Server/ModelManifest.xml 217 | _Pvt_Extensions -------------------------------------------------------------------------------- /BuildTools.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29613.14 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildTools", "BuildTools\BuildTools.csproj", "{8899E123-EC11-441D-B805-3C227B2704E6}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UninstallJava", "UninstallJava\UninstallJava.csproj", "{87A0AD87-774D-40B8-B9F3-03512357BC5C}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6ED77B62-39F9-47D6-8279-D591F42E5A67}" 11 | ProjectSection(SolutionItems) = preProject 12 | .editorconfig = .editorconfig 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {8899E123-EC11-441D-B805-3C227B2704E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {8899E123-EC11-441D-B805-3C227B2704E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {8899E123-EC11-441D-B805-3C227B2704E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {8899E123-EC11-441D-B805-3C227B2704E6}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {87A0AD87-774D-40B8-B9F3-03512357BC5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {87A0AD87-774D-40B8-B9F3-03512357BC5C}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {87A0AD87-774D-40B8-B9F3-03512357BC5C}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {87A0AD87-774D-40B8-B9F3-03512357BC5C}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {46F958E3-D2E3-4B97-8A22-DA8DB5715BA0} 35 | BuildVersion_StartDate = 2000/1/1 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /BuildTools/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BuildTools/BuildTools.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BuildTools 2 | { 3 | partial class BuildTools 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BuildTools)); 32 | this.runBT = new System.Windows.Forms.Button(); 33 | this.updateBT = new System.Windows.Forms.Button(); 34 | this.autoUpdateCB = new System.Windows.Forms.CheckBox(); 35 | this.outputTB = new System.Windows.Forms.RichTextBox(); 36 | this.clearBT = new System.Windows.Forms.Button(); 37 | this.undoBT = new System.Windows.Forms.Button(); 38 | this.progress = new System.Windows.Forms.ProgressBar(); 39 | this.linkLabel = new System.Windows.Forms.LinkLabel(); 40 | this.versionBox = new System.Windows.Forms.ComboBox(); 41 | this.checkRemapped = new System.Windows.Forms.CheckBox(); 42 | this.SuspendLayout(); 43 | // 44 | // runBT 45 | // 46 | this.runBT.FlatStyle = System.Windows.Forms.FlatStyle.System; 47 | this.runBT.Location = new System.Drawing.Point(0, 17); 48 | this.runBT.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 49 | this.runBT.Name = "runBT"; 50 | this.runBT.Size = new System.Drawing.Size(160, 35); 51 | this.runBT.TabIndex = 0; 52 | this.runBT.Text = "Run BuildTools"; 53 | this.runBT.UseVisualStyleBackColor = true; 54 | this.runBT.Click += new System.EventHandler(this.RunBT_Click); 55 | // 56 | // updateBT 57 | // 58 | this.updateBT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 59 | this.updateBT.FlatStyle = System.Windows.Forms.FlatStyle.System; 60 | this.updateBT.Location = new System.Drawing.Point(765, 17); 61 | this.updateBT.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 62 | this.updateBT.Name = "updateBT"; 63 | this.updateBT.Size = new System.Drawing.Size(186, 35); 64 | this.updateBT.TabIndex = 1; 65 | this.updateBT.Text = "Update BuildTools"; 66 | this.updateBT.UseVisualStyleBackColor = true; 67 | this.updateBT.Click += new System.EventHandler(this.UpdateBT_Click); 68 | // 69 | // autoUpdateCB 70 | // 71 | this.autoUpdateCB.Checked = true; 72 | this.autoUpdateCB.CheckState = System.Windows.Forms.CheckState.Checked; 73 | this.autoUpdateCB.FlatStyle = System.Windows.Forms.FlatStyle.System; 74 | this.autoUpdateCB.Location = new System.Drawing.Point(170, 17); 75 | this.autoUpdateCB.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 76 | this.autoUpdateCB.Name = "autoUpdateCB"; 77 | this.autoUpdateCB.Size = new System.Drawing.Size(166, 37); 78 | this.autoUpdateCB.TabIndex = 2; 79 | this.autoUpdateCB.Text = "check for updates"; 80 | this.autoUpdateCB.UseVisualStyleBackColor = true; 81 | this.autoUpdateCB.Click += new System.EventHandler(this.AutoUpdateCB_Click); 82 | // 83 | // outputTB 84 | // 85 | this.outputTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 86 | | System.Windows.Forms.AnchorStyles.Left) 87 | | System.Windows.Forms.AnchorStyles.Right))); 88 | this.outputTB.BackColor = System.Drawing.SystemColors.ControlLightLight; 89 | this.outputTB.BorderStyle = System.Windows.Forms.BorderStyle.None; 90 | this.outputTB.ForeColor = System.Drawing.SystemColors.WindowText; 91 | this.outputTB.Location = new System.Drawing.Point(0, 62); 92 | this.outputTB.Margin = new System.Windows.Forms.Padding(0); 93 | this.outputTB.Name = "outputTB"; 94 | this.outputTB.ReadOnly = true; 95 | this.outputTB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth; 96 | this.outputTB.Size = new System.Drawing.Size(950, 734); 97 | this.outputTB.TabIndex = 3; 98 | this.outputTB.Text = ""; 99 | this.outputTB.WordWrap = false; 100 | // 101 | // clearBT 102 | // 103 | this.clearBT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 104 | this.clearBT.FlatStyle = System.Windows.Forms.FlatStyle.System; 105 | this.clearBT.Location = new System.Drawing.Point(838, 809); 106 | this.clearBT.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 107 | this.clearBT.Name = "clearBT"; 108 | this.clearBT.Size = new System.Drawing.Size(112, 35); 109 | this.clearBT.TabIndex = 4; 110 | this.clearBT.Text = "Clear Log"; 111 | this.clearBT.UseVisualStyleBackColor = true; 112 | this.clearBT.Click += new System.EventHandler(this.ClearBT_Click); 113 | // 114 | // undoBT 115 | // 116 | this.undoBT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 117 | this.undoBT.FlatStyle = System.Windows.Forms.FlatStyle.System; 118 | this.undoBT.Location = new System.Drawing.Point(717, 809); 119 | this.undoBT.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 120 | this.undoBT.Name = "undoBT"; 121 | this.undoBT.Size = new System.Drawing.Size(112, 35); 122 | this.undoBT.TabIndex = 5; 123 | this.undoBT.Text = "Undo Clear"; 124 | this.undoBT.UseVisualStyleBackColor = true; 125 | this.undoBT.Click += new System.EventHandler(this.UndoBT_Click); 126 | // 127 | // progress 128 | // 129 | this.progress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 130 | | System.Windows.Forms.AnchorStyles.Right))); 131 | this.progress.Location = new System.Drawing.Point(0, 809); 132 | this.progress.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 133 | this.progress.Name = "progress"; 134 | this.progress.Size = new System.Drawing.Size(708, 35); 135 | this.progress.TabIndex = 6; 136 | // 137 | // linkLabel 138 | // 139 | this.linkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 140 | this.linkLabel.AutoSize = true; 141 | this.linkLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; 142 | this.linkLabel.LinkColor = System.Drawing.Color.Blue; 143 | this.linkLabel.Location = new System.Drawing.Point(526, 25); 144 | this.linkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); 145 | this.linkLabel.Name = "linkLabel"; 146 | this.linkLabel.Size = new System.Drawing.Size(98, 20); 147 | this.linkLabel.TabIndex = 7; 148 | this.linkLabel.TabStop = true; 149 | this.linkLabel.Text = "View Source"; 150 | this.linkLabel.VisitedLinkColor = System.Drawing.Color.Blue; 151 | this.linkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel_Click); 152 | // 153 | // versionBox 154 | // 155 | this.versionBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 156 | this.versionBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 157 | this.versionBox.FlatStyle = System.Windows.Forms.FlatStyle.System; 158 | this.versionBox.FormattingEnabled = true; 159 | this.versionBox.Items.AddRange(new object[] { 160 | "Latest"}); 161 | this.versionBox.Location = new System.Drawing.Point(636, 20); 162 | this.versionBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 163 | this.versionBox.Name = "versionBox"; 164 | this.versionBox.Size = new System.Drawing.Size(118, 28); 165 | this.versionBox.TabIndex = 8; 166 | // 167 | // checkRemapped 168 | // 169 | this.checkRemapped.FlatStyle = System.Windows.Forms.FlatStyle.System; 170 | this.checkRemapped.Location = new System.Drawing.Point(344, 15); 171 | this.checkRemapped.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 172 | this.checkRemapped.Name = "checkRemapped"; 173 | this.checkRemapped.Size = new System.Drawing.Size(166, 37); 174 | this.checkRemapped.TabIndex = 9; 175 | this.checkRemapped.Text = "create remapped"; 176 | this.checkRemapped.UseVisualStyleBackColor = true; 177 | // 178 | // BuildTools 179 | // 180 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 181 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 182 | this.ClientSize = new System.Drawing.Size(951, 863); 183 | this.Controls.Add(this.checkRemapped); 184 | this.Controls.Add(this.versionBox); 185 | this.Controls.Add(this.linkLabel); 186 | this.Controls.Add(this.progress); 187 | this.Controls.Add(this.undoBT); 188 | this.Controls.Add(this.clearBT); 189 | this.Controls.Add(this.outputTB); 190 | this.Controls.Add(this.autoUpdateCB); 191 | this.Controls.Add(this.updateBT); 192 | this.Controls.Add(this.runBT); 193 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 194 | this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 195 | this.MinimumSize = new System.Drawing.Size(961, 91); 196 | this.Name = "BuildTools"; 197 | this.Text = "BuildTools"; 198 | this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.BuildTools_FormClosed); 199 | this.ResumeLayout(false); 200 | this.PerformLayout(); 201 | 202 | } 203 | 204 | #endregion 205 | 206 | private System.Windows.Forms.Button runBT; 207 | private System.Windows.Forms.Button updateBT; 208 | private System.Windows.Forms.CheckBox autoUpdateCB; 209 | private System.Windows.Forms.RichTextBox outputTB; 210 | private System.Windows.Forms.Button clearBT; 211 | private System.Windows.Forms.Button undoBT; 212 | private System.Windows.Forms.ProgressBar progress; 213 | private System.Windows.Forms.LinkLabel linkLabel; 214 | private System.Windows.Forms.ComboBox versionBox; 215 | private System.Windows.Forms.CheckBox checkRemapped; 216 | } 217 | } 218 | 219 | -------------------------------------------------------------------------------- /BuildTools/BuildTools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Windows.Forms; 8 | using HtmlAgilityPack; 9 | 10 | namespace BuildTools { 11 | using System.Runtime.InteropServices; 12 | 13 | public partial class BuildTools : Form { 14 | // Delegates 15 | private delegate void AppendTextDelegate(string text); 16 | private readonly AppendTextDelegate _appendDelegate; 17 | private delegate void AppendRawTextDelegat(string text); 18 | private readonly AppendRawTextDelegat _appendRawDelegate; 19 | private delegate void DisableDelegate(); 20 | private readonly DisableDelegate _disableDelegate; 21 | private delegate void EnableDelegate(); 22 | private readonly EnableDelegate _enableDelegate; 23 | private delegate void ShowProgressDelegate(); 24 | private readonly ShowProgressDelegate _showProgressDelegate; 25 | private delegate void HideProgressDelegate(); 26 | private readonly HideProgressDelegate _hideProgressDelegate; 27 | private delegate void IndeterminateProgressDelegate(); 28 | private readonly IndeterminateProgressDelegate _indeterminateProgressDelegate; 29 | private delegate void ProgressPercentDelegate(int place, int total); 30 | private readonly ProgressPercentDelegate _progressPercentDelegate; 31 | private delegate void UpdateVersionsDelegate(); 32 | private readonly UpdateVersionsDelegate _updateVersionsDelegate; 33 | 34 | // Stuff 35 | private readonly Runner _runner; 36 | private string _lastLog = ""; 37 | private readonly List _versions = new List(); 38 | private readonly Job _job; 39 | 40 | [DllImport("user32.dll", SetLastError = true)] 41 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); 42 | 43 | /// 44 | /// Constructor for the form 45 | /// 46 | public BuildTools(Guid guid, Job job) { 47 | InitializeComponent(); 48 | _job = job; 49 | _runner = new Runner(this, _job); 50 | undoBT.Visible = false; 51 | progress.Visible = false; 52 | 53 | versionBox.SelectedIndex = 0; 54 | GetVersions(); 55 | 56 | // delegates 57 | _appendDelegate = AppendText; 58 | _appendRawDelegate = AppendRawText; 59 | _disableDelegate = Disable; 60 | _enableDelegate = Enable; 61 | _showProgressDelegate = ProgressShow; 62 | _hideProgressDelegate = ProgressHide; 63 | _indeterminateProgressDelegate = ProgressIndeterminate; 64 | _progressPercentDelegate = Progress; 65 | _updateVersionsDelegate = UpdateVersions; 66 | 67 | if (File.Exists(Program.CheckUpdate)) { 68 | string text = File.ReadAllText(Program.CheckUpdate); 69 | if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { 70 | autoUpdateCB.Checked = false; 71 | } 72 | } 73 | 74 | Console.WriteLine(guid.ToString()); 75 | } 76 | 77 | // Run BuildTools Button Clicked 78 | private void RunBT_Click(object sender, EventArgs e) { 79 | bool update = autoUpdateCB.Checked; 80 | bool remapped = checkRemapped.Checked; 81 | string version; 82 | if (versionBox.SelectedIndex == 0) { 83 | version = "latest"; 84 | } else { 85 | version = _versions[versionBox.SelectedIndex - 1]; 86 | } 87 | 88 | Thread thread = new Thread(delegate() { 89 | _runner.RunBuildTools(update, version, remapped); 90 | Enable(); 91 | ProgressHide(); 92 | }); 93 | Disable(); 94 | thread.Start(); 95 | } 96 | 97 | // Update BuildTools Button Clicked 98 | private void UpdateBT_Click(object sender, EventArgs e) { 99 | 100 | Thread thread = new Thread(delegate() { 101 | _runner.UpdateJar(); 102 | Enable(); 103 | ProgressHide(); 104 | }); 105 | Disable(); 106 | thread.Start(); 107 | } 108 | 109 | // Clear Log Button Clicked 110 | private void ClearBT_Click(object sender, EventArgs e) { 111 | _lastLog += outputTB.Text; 112 | outputTB.Text = ""; 113 | undoBT.Visible = true; 114 | } 115 | 116 | // Undo Button Clicked 117 | private void UndoBT_Click(object sender, EventArgs e) { 118 | outputTB.Text = _lastLog + outputTB.Text; 119 | _lastLog = ""; 120 | undoBT.Visible = false; 121 | } 122 | 123 | /// 124 | /// Append text to the output textbox. This method will ensure thread safety on the AppendText method call. 125 | /// This will also prefix a "--- " before the given text and automatically append the given text with a new-line character. 126 | /// 127 | /// Text to append to the output textbox. 128 | public void AppendText(string text) { 129 | if (InvokeRequired) { 130 | Invoke(_appendDelegate, text); 131 | } else { 132 | outputTB.AppendText("--- " + text + "\n"); 133 | outputTB.ScrollToCaret(); 134 | } 135 | } 136 | 137 | /// 138 | /// Send one line of text to the output textbox, with no "---" prefix. A newline will be added to the end of the line. 139 | /// 140 | /// Text to append to the output textbox. 141 | public void AppendRawText(string text) { 142 | if (InvokeRequired) { 143 | Invoke(_appendRawDelegate, text); 144 | } else { 145 | outputTB.AppendText(text + "\n"); 146 | outputTB.ScrollToCaret(); 147 | } 148 | } 149 | 150 | /// 151 | /// Disable the run buttons so they can't be pressed while work is being done. 152 | /// 153 | private void Disable() { 154 | if (InvokeRequired) { 155 | Invoke(_disableDelegate); 156 | } else { 157 | updateBT.Enabled = false; 158 | runBT.Enabled = false; 159 | versionBox.Enabled = false; 160 | } 161 | } 162 | 163 | /// 164 | /// Enable the run buttons so they will work after work has completed 165 | /// 166 | private void Enable() { 167 | if (InvokeRequired) { 168 | Invoke(_enableDelegate); 169 | } else { 170 | updateBT.Enabled = true; 171 | runBT.Enabled = true; 172 | versionBox.Enabled = true; 173 | } 174 | } 175 | 176 | /// 177 | /// Show the progress bar. 178 | /// This needs to be done before other calls are made to it. 179 | /// 180 | public void ProgressShow() { 181 | if (InvokeRequired) { 182 | Invoke(_showProgressDelegate); 183 | } else { 184 | progress.Visible = true; 185 | } 186 | } 187 | 188 | /// 189 | /// Hide the progress bar so it won't be visible 190 | /// 191 | public void ProgressHide() { 192 | if (InvokeRequired) { 193 | Invoke(_hideProgressDelegate); 194 | } else { 195 | progress.Visible = false; 196 | } 197 | } 198 | 199 | /// 200 | /// Set the progress bar's state to indeterminate. 201 | /// 202 | public void ProgressIndeterminate() { 203 | if (InvokeRequired) { 204 | Invoke(_indeterminateProgressDelegate); 205 | } else { 206 | progress.Style = ProgressBarStyle.Marquee; 207 | } 208 | } 209 | 210 | /// 211 | /// Set the progress bar to the specified place. 212 | /// 213 | /// Current progress to this point 214 | /// Total progress to completion 215 | public void Progress(int place, int total) { 216 | if (InvokeRequired) { 217 | Invoke(_progressPercentDelegate, place, total); 218 | } else { 219 | progress.Style = ProgressBarStyle.Continuous; 220 | progress.Minimum = 0; 221 | progress.Maximum = total; 222 | progress.Value = place; 223 | } 224 | } 225 | 226 | // Exit button pressed 227 | private void BuildTools_FormClosed(object sender, FormClosedEventArgs e) { 228 | _runner.CleanUp(); 229 | _job.Dispose(); 230 | Application.Exit(); 231 | Environment.Exit(0); 232 | } 233 | 234 | // Source link clicked 235 | private void LinkLabel_Click(object sender, LinkLabelLinkClickedEventArgs e) { 236 | System.Diagnostics.Process.Start("https://github.com/0uti/BuildToolsGUI"); 237 | } 238 | 239 | private void GetVersions() { 240 | new Thread(delegate () { 241 | string versionsHtml = GetHtml("https://hub.spigotmc.org/versions/"); 242 | if (string.IsNullOrEmpty(versionsHtml)) 243 | { 244 | return; 245 | } 246 | 247 | // Convert the HTML to XHTML to use an XML parser 248 | HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); 249 | doc.LoadHtml(versionsHtml); 250 | if (doc.ParseErrors != null) { 251 | while (doc.ParseErrors.GetEnumerator().MoveNext()) { 252 | Console.Write(doc.ParseErrors.GetEnumerator().Current); 253 | } 254 | } 255 | HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//a"); 256 | foreach (HtmlNode node in nodes) { 257 | if (node.InnerText.EndsWith(".json") && node.InnerText.StartsWith("1.")) { 258 | _versions.Add(node.InnerText.Remove(node.InnerText.Length - 5)); 259 | } 260 | } 261 | 262 | UpdateVersions(); 263 | }).Start(); 264 | } 265 | 266 | private static string GetHtml(string url) { 267 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 268 | try { 269 | request.UserAgent = "BuildToolsGui"; 270 | HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 271 | 272 | if (response.StatusCode == HttpStatusCode.OK) { 273 | Stream receiveStream = response.GetResponseStream(); 274 | StreamReader readStream = null; 275 | 276 | if (response.CharacterSet == null) { 277 | if (receiveStream != null) { 278 | readStream = new StreamReader(receiveStream); 279 | } 280 | } else { 281 | if (receiveStream != null) { 282 | readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); 283 | } 284 | } 285 | 286 | string data = readStream.ReadToEnd(); 287 | 288 | response.Close(); 289 | readStream.Close(); 290 | 291 | return data; 292 | } 293 | } catch (Exception) { 294 | 295 | } 296 | return ""; 297 | } 298 | 299 | private void UpdateVersions() { 300 | if (InvokeRequired) { 301 | Invoke(_updateVersionsDelegate); 302 | } else { 303 | ComboBox.ObjectCollection items = versionBox.Items; 304 | items.Clear(); 305 | items.Add("Latest"); 306 | _versions.Sort(); 307 | _versions.Reverse(); 308 | foreach (string s in _versions) { 309 | items.Add(s); 310 | } 311 | versionBox.SelectedIndex = 0; 312 | } 313 | } 314 | 315 | private void AutoUpdateCB_Click(object sender, EventArgs e) { 316 | if (autoUpdateCB.Checked) { 317 | File.WriteAllText(Program.CheckUpdate, "true"); 318 | } else { 319 | File.WriteAllText(Program.CheckUpdate, "false"); 320 | } 321 | } 322 | } 323 | } 324 | -------------------------------------------------------------------------------- /BuildTools/BuildTools.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | AnyCPU 9 | {8899E123-EC11-441D-B805-3C227B2704E6} 10 | WinExe 11 | Properties 12 | BuildTools 13 | BuildToolsGUI 14 | v4.7.2 15 | 512 16 | false 17 | 18 | 19 | 20 | C:\Users\demon\Desktop\ 21 | true 22 | Disk 23 | false 24 | Foreground 25 | 7 26 | Days 27 | false 28 | false 29 | true 30 | publish.htm 31 | true 32 | 1 33 | 1.0.0.%2a 34 | false 35 | true 36 | true 37 | 38 | 39 | AnyCPU 40 | true 41 | full 42 | false 43 | bin\Debug\ 44 | DEBUG;TRACE 45 | prompt 46 | 4 47 | 48 | 49 | AnyCPU 50 | pdbonly 51 | true 52 | bin\Release\ 53 | TRACE 54 | prompt 55 | 4 56 | false 57 | 58 | 59 | icon.ico 60 | 61 | 62 | E822F04BCE9A78713B01D4E485B33E074C395128 63 | 64 | 65 | BuildTools_TemporaryKey.pfx 66 | 67 | 68 | false 69 | 70 | 71 | LocalIntranet 72 | 73 | 74 | Properties\app.manifest 75 | 76 | 77 | false 78 | 79 | 80 | BuildTools.Program 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | ..\packages\HtmlAgilityPack.1.11.38\lib\Net45\HtmlAgilityPack.dll 92 | 93 | 94 | ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Form 112 | 113 | 114 | BuildTools.cs 115 | 116 | 117 | 118 | 119 | 120 | 121 | BuildTools.cs 122 | 123 | 124 | ResXFileCodeGenerator 125 | Resources.Designer.cs 126 | Designer 127 | 128 | 129 | True 130 | Resources.resx 131 | True 132 | 133 | 134 | .editorconfig 135 | 136 | 137 | 138 | 139 | 140 | SettingsSingleFileGenerator 141 | Settings.Designer.cs 142 | 143 | 144 | True 145 | Settings.settings 146 | True 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | False 159 | Microsoft .NET Framework 4.5 %28x86 and x64%29 160 | true 161 | 162 | 163 | False 164 | .NET Framework 3.5 SP1 Client Profile 165 | false 166 | 167 | 168 | False 169 | .NET Framework 3.5 SP1 170 | false 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". 182 | 183 | 184 | 185 | 186 | 187 | 188 | 195 | -------------------------------------------------------------------------------- /BuildTools/BuildTools.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | 123 | AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 124 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6EY6/+hG 125 | Ov8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOhG 126 | Ov/oRjr/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 127 | AADoRjr/6EY6/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 128 | AAAAAAD/AAAA/wAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/wAAAP8AAAD/AAAA/wAA 129 | AAAAAAAAAAAA/wDQ//8A0P//AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAD/P+ji/z/o4v8/6OL/AND//wAA 130 | AP8AAAAAAAAA/wDQ//8A0P//AND//wAAAP8AAAD/AAAA/wAAAP8AAAD/AND//wDQ//8/6OL/P+ji/z/o 131 | 4v8A0P//AAAA/wDQ//8A0P//AND//wDQ//8AAAD/AND//wDQ//8A0P//AND//wDQ//8A0P//AND//z/o 132 | 4v8/6OL/P+ji/wDQ//8A0P//AND//wDQ//8AAAD/AAAAAAAAAP8AAAD/AAAA/wAAAP8AAAD/AND//wDQ 133 | //8/6OL/P+ji/z/o4v8A0P//AAAA/wAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAA 134 | AP8A0P//AND//z/o4v8/6OL/P+ji/wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 135 | AAAAAAAAAAAA/wDQ//8A0P//P+ji/wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 136 | AAAAAAAAAAAAAAAAAP8A0P//AND//wDQ//8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 137 | AAAAAAAAAAAAAAAAAAAAAAD/AAAA/wDQ//8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 138 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8A0P//AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 139 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA 140 | AAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAAAAAA 141 | AAAAAAAA//kAAP/5AAD/+QAA//AAAPgwAADwIAAAAAAAAAABAAAAAwAA8A8AAPwfAAD8HwAA/B8AAP4/ 142 | AAD+PwAA8AcAAA== 143 | 144 | 145 | -------------------------------------------------------------------------------- /BuildTools/ILMerge.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | true 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 | -------------------------------------------------------------------------------- /BuildTools/ILMergeOrder.txt: -------------------------------------------------------------------------------- 1 | # this file contains the partial list of the merged assemblies in the merge order 2 | # you can fill it from the obj\CONFIG\PROJECT.ilmerge generated on every build 3 | # and finetune merge order to your satisfaction 4 | 5 | -------------------------------------------------------------------------------- /BuildTools/JobObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace BuildTools { 6 | 7 | public class Job : IDisposable 8 | { 9 | [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] 10 | static extern IntPtr CreateJobObject(IntPtr a, string lpName); 11 | 12 | [DllImport("kernel32.dll")] 13 | static extern bool SetInformationJobObject(IntPtr hJob, JobObjectInfoType infoType, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength); 14 | 15 | [DllImport("kernel32.dll", SetLastError = true)] 16 | static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process); 17 | 18 | private IntPtr handle; 19 | private bool disposed; 20 | 21 | public Job() 22 | { 23 | handle = CreateJobObject(IntPtr.Zero, null); 24 | 25 | var info = new JOBOBJECT_BASIC_LIMIT_INFORMATION { 26 | LimitFlags = 0x2000 27 | }; 28 | 29 | var extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION { 30 | BasicLimitInformation = info 31 | }; 32 | 33 | int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)); 34 | IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length); 35 | Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false); 36 | 37 | if (!SetInformationJobObject(handle, JobObjectInfoType.ExtendedLimitInformation, extendedInfoPtr, (uint)length)) 38 | throw new Exception(string.Format("Unable to set information. Error: {0}", Marshal.GetLastWin32Error())); 39 | } 40 | 41 | public void Dispose() 42 | { 43 | Dispose(true); 44 | GC.SuppressFinalize(this); 45 | } 46 | 47 | private void Dispose(bool disposing) 48 | { 49 | if (disposed) 50 | return; 51 | 52 | if (disposing) { } 53 | 54 | Close(); 55 | disposed = true; 56 | } 57 | 58 | [DllImport("kernel32.dll", SetLastError = true)] 59 | static extern bool CloseHandle(IntPtr hObject); 60 | 61 | public void Close() 62 | { 63 | CloseHandle(handle); 64 | handle = IntPtr.Zero; 65 | } 66 | 67 | public bool AddProcess(IntPtr processHandle) 68 | { 69 | return AssignProcessToJobObject(handle, processHandle); 70 | } 71 | 72 | public bool AddProcess(int processId) 73 | { 74 | return AddProcess(Process.GetProcessById(processId).Handle); 75 | } 76 | 77 | } 78 | 79 | #region Helper classes 80 | // ReSharper disable InconsistentNaming 81 | 82 | [StructLayout(LayoutKind.Sequential)] 83 | struct IO_COUNTERS 84 | { 85 | public ulong ReadOperationCount; 86 | public ulong WriteOperationCount; 87 | public ulong OtherOperationCount; 88 | public ulong ReadTransferCount; 89 | public ulong WriteTransferCount; 90 | public ulong OtherTransferCount; 91 | } 92 | 93 | 94 | [StructLayout(LayoutKind.Sequential)] 95 | struct JOBOBJECT_BASIC_LIMIT_INFORMATION 96 | { 97 | public long PerProcessUserTimeLimit; 98 | public long PerJobUserTimeLimit; 99 | public uint LimitFlags; 100 | public UIntPtr MinimumWorkingSetSize; 101 | public UIntPtr MaximumWorkingSetSize; 102 | public uint ActiveProcessLimit; 103 | public UIntPtr Affinity; 104 | public uint PriorityClass; 105 | public uint SchedulingClass; 106 | } 107 | 108 | [StructLayout(LayoutKind.Sequential)] 109 | public struct SECURITY_ATTRIBUTES 110 | { 111 | public uint nLength; 112 | public IntPtr lpSecurityDescriptor; 113 | public int bInheritHandle; 114 | } 115 | 116 | [StructLayout(LayoutKind.Sequential)] 117 | struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION 118 | { 119 | public JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation; 120 | public IO_COUNTERS IoInfo; 121 | public UIntPtr ProcessMemoryLimit; 122 | public UIntPtr JobMemoryLimit; 123 | public UIntPtr PeakProcessMemoryUsed; 124 | public UIntPtr PeakJobMemoryUsed; 125 | } 126 | 127 | public enum JobObjectInfoType 128 | { 129 | AssociateCompletionPortInformation = 7, 130 | BasicLimitInformation = 2, 131 | BasicUIRestrictions = 4, 132 | EndOfJobTimeInformation = 6, 133 | ExtendedLimitInformation = 9, 134 | SecurityLimitInformation = 5, 135 | GroupInformation = 11 136 | } 137 | 138 | // ReSharper restore InconsistentNaming 139 | #endregion 140 | } -------------------------------------------------------------------------------- /BuildTools/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace BuildTools { 5 | using System.IO; 6 | 7 | internal static class Program { 8 | private static readonly string appdata = Environment.GetEnvironmentVariable("APPDATA"); 9 | private static readonly string dir = appdata + "\\btgui\\"; 10 | private static readonly string file = dir + "gaclientid"; 11 | public static readonly string CheckUpdate = dir + "checkUpdate"; 12 | 13 | /// 14 | /// The main entry point for the application. 15 | /// 16 | [STAThread] 17 | private static void Main() { 18 | Guid guid; 19 | 20 | if (!Directory.Exists(dir) && File.Exists(dir)) { 21 | File.Delete(dir); 22 | } 23 | 24 | if (!Directory.Exists(dir)) { 25 | Directory.CreateDirectory(dir); 26 | } 27 | 28 | if (File.Exists(file)) { 29 | string text = File.ReadAllText(file); 30 | if (string.IsNullOrEmpty(text) || !Guid.TryParse(text, out guid)) { 31 | guid = Guid.NewGuid(); 32 | } 33 | } else { 34 | guid = Guid.NewGuid(); 35 | } 36 | 37 | File.WriteAllText(file, guid.ToString()); 38 | 39 | Job job = new Job(); 40 | 41 | Application.EnableVisualStyles(); 42 | Application.SetCompatibleTextRenderingDefault(false); 43 | Application.Run(new BuildTools(guid, job)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /BuildTools/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("BuildToolsGUI")] 8 | [assembly: AssemblyDescription("Windows GUI for the Spigot BuildTools")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("BuildToolsGUI")] 12 | [assembly: AssemblyCopyright("Copyright © Kyle Wood (DemonWav) 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("45b6e606-657d-4123-8b84-320f0fcc052c")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.6.72")] 35 | [assembly: AssemblyFileVersion("1.0.6.72")] 36 | -------------------------------------------------------------------------------- /BuildTools/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.42000 5 | // 6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn 7 | // der Code erneut generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BuildTools.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. 17 | /// 18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert 19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. 20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen 21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BuildTools.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle 51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /BuildTools/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | -------------------------------------------------------------------------------- /BuildTools/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.42000 5 | // 6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn 7 | // der Code erneut generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BuildTools.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BuildTools/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BuildTools/Properties/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 54 | -------------------------------------------------------------------------------- /BuildTools/Runner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Net; 5 | using System.IO; 6 | using System.Threading; 7 | using Microsoft.Win32; 8 | using Newtonsoft.Json.Linq; 9 | using System.IO.Compression; 10 | 11 | namespace BuildTools 12 | { 13 | 14 | /// 15 | /// General worker class 16 | /// 17 | public class Runner 18 | { 19 | /// 20 | /// Output directory for all files 21 | /// 22 | public static readonly string Dir = "BuildTools\\"; 23 | /// 24 | /// GUI part of the program 25 | /// 26 | private readonly BuildTools _form; 27 | 28 | /// 29 | /// Final directory for the portable Git extract 30 | /// 31 | private const string GitDir = "BuildTools/PortableGit"; 32 | 33 | /// 34 | /// Json response for the Jenkins api 35 | /// 36 | private JObject _api; 37 | 38 | /// 39 | /// Json response from my server 40 | /// 41 | private JObject _json; 42 | 43 | /// 44 | /// Json file for selected version 45 | /// 46 | private JObject _version; 47 | 48 | /// 49 | /// contains the java version. 50 | /// 51 | private string _javaVersion; 52 | 53 | /// 54 | /// path to java executable 55 | /// 56 | private string _javaPath; 57 | 58 | /// 59 | /// Keep track of current work here, so cleanup can remove them when needed 60 | /// 61 | private readonly HashSet _disposables = new HashSet(); 62 | 63 | /// 64 | /// Whether the user had gpg signing enabled 65 | /// 66 | private bool isGpg; 67 | 68 | private readonly Job _job; 69 | 70 | /// 71 | /// Constructor for the worker class 72 | /// 73 | /// The GUI 74 | /// Job Object 75 | public Runner(BuildTools form, Job job) 76 | { 77 | _form = form; 78 | _job = job; 79 | } 80 | 81 | /// 82 | /// Checks if a BuildTools.jar exists, and if it exists, which version it is. It then checks the api on jenkins to see if 83 | /// there is a newer version available. If there is, or if a BuildTools.jar does not exist, this method will return true. 84 | /// Returns false if no update is needed. 85 | /// 86 | /// True if an update is needed. 87 | public bool CheckUpdate(out bool bad) 88 | { 89 | bad = false; 90 | if (!GetJson()) 91 | { 92 | bad = true; 93 | return false; 94 | } 95 | if (File.Exists(Dir + (string)_json["buildTools"]["name"])) 96 | { 97 | int number = (int)_api["number"]; 98 | bool success = GetBuildNumberFromJar(out int currentBuildNumber); 99 | 100 | if (success) 101 | { 102 | bool update = currentBuildNumber < number; 103 | if (update) 104 | _form.AppendText("BuildTools is out of date"); 105 | 106 | return update; 107 | } 108 | } 109 | else 110 | { 111 | _form.AppendText("BuildTools does not exist"); 112 | } 113 | return true; 114 | } 115 | 116 | /// 117 | /// Get the JSON response from my server and Jenkins and save them as JObject's. 118 | /// 119 | /// True if the JSON responses were parsed successfully. 120 | private bool GetJson() 121 | { 122 | if (_json == null) 123 | { 124 | _form.AppendText("Retrieving information from the server"); 125 | 126 | _json = DownloadJson("http://uglylauncher.de/buildtools.json"); 127 | 128 | if (_json == null) 129 | { 130 | _form.AppendText("Error retrieving data, canceling"); 131 | return false; 132 | } 133 | } 134 | if (_api == null) 135 | { 136 | _api = DownloadJson((string)_json["buildTools"]["api"]); 137 | 138 | if (_api == null) 139 | { 140 | _form.AppendText("Error retrieving data, canceling"); 141 | return false; 142 | } 143 | } 144 | return true; 145 | } 146 | 147 | /// 148 | /// Given a URL, retrieve the JSON response from that URL and return it as a JObject 149 | /// 150 | /// URL to get JSON response from 151 | /// JObject formed by the parsed JSON 152 | private JObject DownloadJson(string url) 153 | { 154 | try 155 | { 156 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 157 | request.UserAgent = "BuildToolsGui"; 158 | using (Stream stream = request.GetResponse().GetResponseStream()) 159 | { 160 | try 161 | { 162 | _disposables.Add(stream); 163 | if (stream != null) 164 | { 165 | StreamReader reader = new StreamReader(stream); 166 | 167 | string line; 168 | string finalOutput = ""; 169 | while ((line = reader.ReadLine()) != null) 170 | { 171 | finalOutput += line + "\n"; 172 | } 173 | 174 | return JObject.Parse(finalOutput); 175 | } 176 | } 177 | catch (Exception) 178 | { 179 | _form.AppendText("There was an error while trying to receive data from the server"); 180 | return null; 181 | } 182 | finally 183 | { 184 | _disposables.Remove(stream); 185 | } 186 | return null; 187 | } 188 | } 189 | catch (Exception) 190 | { 191 | _form.AppendText("There was an error while trying to receive data from the server"); 192 | return null; 193 | } 194 | } 195 | 196 | /// 197 | /// Check the build number of the BuildTools.jar. Set the given parameter to the build number of the BuildTools.jar. 198 | /// Returns whether the BuildTools.jar is valid. If this method returns false, the parameter means nothing (and will be 0). 199 | /// 200 | /// The build number of the jar 201 | /// Whether the jar file is valid. 202 | private bool GetBuildNumberFromJar(out int i) 203 | { 204 | _form.AppendText("Checking downloaded BuildTools"); 205 | try 206 | { 207 | using (ZipArchive zip = ZipFile.OpenRead(Dir + (string)_json["buildTools"]["name"])) 208 | { 209 | ZipArchiveEntry entry = zip.GetEntry("META-INF/MANIFEST.MF"); 210 | using (StreamReader reader = new StreamReader(entry.Open())) 211 | { 212 | string line; 213 | while ((line = reader.ReadLine()) != null) 214 | { 215 | if (line.StartsWith("Implementation-Version: ")) 216 | { 217 | string version = line.Replace("Implementation-Version: ", ""); 218 | string[] split = version.Split('-'); 219 | 220 | // at least put some effort into making sure this is a BuildTools jar 221 | if (!"git".Equals(split[0]) || !"BuildTools".Equals(split[1])) 222 | { 223 | _form.AppendText("Jar is invalid"); 224 | i = 0; 225 | return false; 226 | } 227 | 228 | i = int.Parse(split[3]); 229 | return true; 230 | } 231 | } 232 | } 233 | i = 0; 234 | return false; 235 | } 236 | } 237 | catch (Exception) 238 | { 239 | _form.AppendText("Jar is invalid"); 240 | i = 0; 241 | return false; 242 | } 243 | } 244 | 245 | /// 246 | /// Download a new copy of the BuildTools jar 247 | /// 248 | /// True if the update was successful 249 | public bool UpdateJar() 250 | { 251 | if (!Directory.Exists(Dir)) 252 | { 253 | Directory.CreateDirectory(Dir); 254 | } 255 | _form.AppendText("Checking for update"); 256 | _form.ProgressShow(); 257 | _form.ProgressIndeterminate(); 258 | bool update = CheckUpdate(out bool bad); 259 | if (update) 260 | { 261 | _form.AppendText("Update needed for BuildTools"); 262 | if (!GetJson()) 263 | { 264 | return false; 265 | } 266 | 267 | if (File.Exists(Dir + (string)_json["buildTools"]["name"])) 268 | { 269 | _form.AppendText("Deleting current BuildTools"); 270 | File.Delete(Dir + (string)_json["buildTools"]["name"]); 271 | } 272 | 273 | string baseUrl = (string)_api["url"]; 274 | string relativePath = (string)_api["artifacts"][0]["relativePath"]; 275 | string fullUrl = baseUrl + "artifact/" + relativePath; 276 | 277 | _form.AppendText("Downloading BuildTools"); 278 | if (!DownloadFile(fullUrl, Dir + (string)_json["buildTools"]["name"])) 279 | { 280 | _form.AppendText("BuildTools failed to download"); 281 | return false; 282 | } 283 | _form.AppendText("Download complete"); 284 | } 285 | else 286 | { 287 | if (!bad) 288 | { 289 | _form.AppendText("BuildTools is up to date, no need to update"); 290 | } 291 | else 292 | { 293 | return false; 294 | } 295 | } 296 | return true; 297 | } 298 | 299 | /// 300 | /// Goes through the process of checking the BuildTools environment and running it. If autoUpate is 301 | /// true, it will first call . 302 | /// 303 | /// If true, this will first call Before continuing. 304 | /// Version to build. 305 | public void RunBuildTools(bool autoUpdate, string version, bool remapped) 306 | { 307 | if (!Environment.Is64BitOperatingSystem) 308 | { 309 | _form.AppendText("BuildTools does not reliably work on 32 bit systems, if you have problems please re-run this on a 64 bit system."); 310 | } 311 | 312 | if (!Directory.Exists(Dir)) 313 | { 314 | Directory.CreateDirectory(Dir); 315 | } 316 | _form.ProgressShow(); 317 | _form.ProgressIndeterminate(); 318 | if (autoUpdate) 319 | { 320 | if (!UpdateJar()) 321 | { 322 | return; 323 | } 324 | } 325 | else 326 | { 327 | // We still need to grab data even if not updating 328 | if (!GetJson()) 329 | { 330 | return; 331 | } 332 | } 333 | 334 | // get version jar from spigot 335 | _version = DownloadJson("https://hub.spigotmc.org/versions/" + version + ".json"); 336 | 337 | int javaVersion = int.Parse((string)_version["javaVersions"][0]); // the minimal java version 338 | switch(javaVersion) 339 | { 340 | case 51: { _javaVersion = "7"; break; } 341 | case 52: { _javaVersion = "8"; break; } 342 | case 53: { _javaVersion = "9"; break; } 343 | case 54: { _javaVersion = "10"; break; } 344 | case 55: { _javaVersion = "11"; break; } 345 | case 56: { _javaVersion = "12"; break; } 346 | case 57: { _javaVersion = "13"; break; } 347 | case 58: { _javaVersion = "14"; break; } 348 | case 59: { _javaVersion = "15"; break; } 349 | case 60: { _javaVersion = "16"; break; } 350 | case 61: { _javaVersion = "17"; break; } 351 | case 62: { _javaVersion = "18"; break; } 352 | default: { _javaVersion = "17"; break; } 353 | } 354 | 355 | if(!CheckJava()) 356 | { // java version not installed 357 | 358 | // download java 359 | _form.AppendText("Downloading Java " + _javaVersion); 360 | string javaFile = Dir + @"java\" + _javaVersion + ".zip"; 361 | bool success = DownloadJava(javaFile); 362 | if (!success) 363 | { 364 | _form.AppendText("Java could not be downloaded, canceling"); 365 | return; 366 | } 367 | 368 | ExtractJava(javaFile); 369 | File.Delete(javaFile); 370 | 371 | // check java again. 372 | if (!CheckJava()) 373 | { 374 | _form.AppendText("Java could not be downloaded, canceling"); 375 | return; 376 | } 377 | 378 | } 379 | 380 | // Git check 381 | if (!CheckGit()) 382 | { 383 | string gitFile = Dir + "portable_git.7z.exe"; 384 | _form.AppendText("Downloading portable Git"); 385 | 386 | bool success; 387 | if (Environment.Is64BitOperatingSystem) 388 | { 389 | success = DownloadFile((string)_json["git"]["64"], gitFile); 390 | } 391 | else 392 | { 393 | success = DownloadFile((string)_json["git"]["32"], gitFile); 394 | } 395 | if (!success) 396 | { 397 | _form.AppendText("Portable Git could not be downloaded, canceling"); 398 | return; 399 | } 400 | 401 | _form.ProgressIndeterminate(); 402 | using (Process extractProcess = new Process()) 403 | { 404 | _form.AppendText("Extracting portable Git"); 405 | _disposables.Add(extractProcess); 406 | try 407 | { 408 | extractProcess.StartInfo.FileName = gitFile; 409 | extractProcess.StartInfo.UseShellExecute = true; 410 | extractProcess.StartInfo.Arguments = "-gm1 -nr -y"; 411 | extractProcess.Start(); 412 | AddProcessToJob(extractProcess); 413 | extractProcess.WaitForExit(); 414 | if (extractProcess.ExitCode != 0) 415 | throw new Exception(); 416 | } 417 | catch (Exception) 418 | { 419 | _form.AppendText("Portable Git could not be installed, canceling"); 420 | return; 421 | } 422 | finally 423 | { 424 | _disposables.Remove(extractProcess); 425 | } 426 | } 427 | Thread.Sleep(100); 428 | File.Delete(gitFile); 429 | 430 | _form.AppendText("Checking portable Git installation (this may take a while)"); 431 | if (CheckGit()) 432 | { 433 | _form.AppendText("Portable Git installed Successfully"); 434 | } 435 | else 436 | { 437 | _form.AppendText("Portable Git could not be installed, canceling"); 438 | return; 439 | } 440 | } 441 | 442 | // Check and fix commit.gpgpsign 443 | CheckGpg(); 444 | if (isGpg) 445 | { 446 | _form.AppendText("Setting commit.gpgsign to false (needed for BuildTools, will reset once finished)"); 447 | SetGpg(false); 448 | } 449 | 450 | _form.AppendRawText(""); 451 | _form.AppendText("Running BuildTools.jar\n"); 452 | 453 | string startArgs = "--login -c \"git config --global --replace-all core.autocrlf true & " + GetBashJavaPath() + " -jar " + (string)_json["buildTools"]["name"] + " --rev " + version; 454 | if (remapped) 455 | { 456 | startArgs += " --remapped"; 457 | } 458 | startArgs += "\""; 459 | 460 | _form.AppendText("Arguments: " + startArgs); 461 | 462 | // Run Build Tools 463 | using (Process buildProcess = new Process()) 464 | { 465 | _disposables.Add(buildProcess); 466 | try 467 | { 468 | buildProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 469 | buildProcess.StartInfo.CreateNoWindow = true; 470 | buildProcess.StartInfo.FileName = GitDir + "/bin/bash.exe"; 471 | buildProcess.StartInfo.UseShellExecute = false; 472 | buildProcess.StartInfo.RedirectStandardOutput = true; 473 | buildProcess.StartInfo.RedirectStandardError = true; 474 | buildProcess.StartInfo.WorkingDirectory = Path.GetFullPath(Dir); 475 | buildProcess.StartInfo.Arguments = startArgs; 476 | buildProcess.OutputDataReceived += (sender, args) => _form.AppendRawText(args.Data); 477 | buildProcess.ErrorDataReceived += (sender, args) => _form.AppendRawText(args.Data); 478 | buildProcess.Start(); 479 | AddProcessToJob(buildProcess); 480 | buildProcess.BeginOutputReadLine(); 481 | buildProcess.BeginErrorReadLine(); 482 | buildProcess.WaitForExit(); 483 | if (buildProcess.ExitCode != 0) 484 | throw new Exception(); 485 | } 486 | catch (Exception) 487 | { 488 | _form.AppendText("There was an error while running BuildTools"); 489 | } 490 | finally 491 | { 492 | _disposables.Remove(buildProcess); 493 | } 494 | } 495 | 496 | // Reset gpg if we disabled it 497 | if (isGpg) 498 | { 499 | _form.AppendText("Resetting commit.gpgsign"); 500 | SetGpg(true); 501 | } 502 | } 503 | //******************// 504 | //** Java methods **// 505 | //******************// 506 | 507 | private bool CheckJava() 508 | { 509 | return CheckJava(out _); 510 | } 511 | 512 | private bool CheckJava(out bool javaInstalled) 513 | { 514 | if (!Directory.Exists(Dir + "java")) 515 | { 516 | Directory.CreateDirectory(Dir + "java"); 517 | javaInstalled = false; 518 | return false; 519 | } 520 | 521 | if (!Directory.Exists(Dir + @"java\" + _javaVersion)) 522 | { 523 | javaInstalled = false; 524 | return false; 525 | } 526 | _javaPath = Path.GetFullPath(Dir + @"java\" + _javaVersion + @"\bin\java.exe"); 527 | 528 | if (!File.Exists(_javaPath)) 529 | { 530 | javaInstalled = false; 531 | return false; 532 | } 533 | 534 | using (Process process = new Process()) 535 | { 536 | _disposables.Add(process); 537 | try 538 | { 539 | process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 540 | process.StartInfo.CreateNoWindow = true; 541 | process.StartInfo.FileName = _javaPath; 542 | process.StartInfo.UseShellExecute = false; 543 | if (_javaVersion == "8") 544 | { 545 | process.StartInfo.Arguments = "-d64 -version"; 546 | } 547 | else 548 | { 549 | process.StartInfo.Arguments = "-version"; // newer java versions don't support 32bit 550 | } 551 | process.Start(); 552 | AddProcessToJob(process); 553 | process.WaitForExit(); 554 | 555 | javaInstalled = true; 556 | 557 | 558 | if (process.ExitCode == 0) 559 | { 560 | return true; 561 | } 562 | return false; 563 | } 564 | catch (Exception) 565 | { 566 | javaInstalled = false; 567 | return false; 568 | } 569 | finally 570 | { 571 | _disposables.Remove(process); 572 | } 573 | } 574 | } 575 | 576 | private string GetBashJavaPath() 577 | { 578 | string bashPath = _javaPath.Replace("\\", "/"); 579 | if (bashPath.Contains(":")) 580 | { 581 | string[] parts = bashPath.Split(new char[] { ':' }); 582 | bashPath = "/" + parts[0] + parts[1]; 583 | } 584 | bashPath = bashPath.Replace(" ", "\\ "); 585 | return bashPath; 586 | } 587 | 588 | /// 589 | /// Given the output file, download Java using the data from my server. 590 | /// 591 | /// The output file name to download to. 592 | /// True if Java was downloaded correctly 593 | private bool DownloadJava(string javaFile) 594 | { 595 | bool success; 596 | if (Environment.Is64BitOperatingSystem) 597 | { 598 | success = DownloadFile((string)_json["java"][_javaVersion], javaFile); 599 | } 600 | else 601 | { 602 | success = DownloadFile((string)_json["java"][_javaVersion], javaFile); 603 | } 604 | 605 | return success; 606 | } 607 | 608 | private void ExtractJava(string javaFile) 609 | { 610 | // extract java zip file 611 | using (ZipArchive zip = ZipFile.OpenRead(javaFile)) 612 | { 613 | foreach (ZipArchiveEntry zipEntry in zip.Entries) 614 | { 615 | // ignore directories 616 | if (zipEntry.Length == 0) continue; 617 | 618 | // ignore META-INF folder 619 | if (zipEntry.FullName.Contains("META-INF")) continue; 620 | 621 | // Get the full path to ensure that relative segments are removed. 622 | string destinationPath = Path.GetFullPath(Path.Combine(Dir + "java", zipEntry.FullName)); 623 | 624 | // create directory 625 | if (!Directory.Exists(Path.GetDirectoryName(destinationPath))) Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); 626 | 627 | // Ordinal match is safest, case-sensitive volumes can be mounted within volumes that 628 | // are case-insensitive. 629 | if (destinationPath.StartsWith(Path.GetFullPath(Dir + "java"), StringComparison.Ordinal)) 630 | { 631 | zipEntry.ExtractToFile(destinationPath, true); 632 | } 633 | } 634 | } 635 | } 636 | 637 | /// 638 | /// Checks if portable Git is installed correctly. 639 | /// 640 | /// True if portable Git is installed correctly 641 | private bool CheckGit() 642 | { 643 | if (Directory.Exists(GitDir)) 644 | { 645 | using (Process process = new Process()) 646 | { 647 | _disposables.Add(process); 648 | try 649 | { 650 | process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 651 | process.StartInfo.CreateNoWindow = true; 652 | process.StartInfo.FileName = GitDir + "/bin/bash.exe"; 653 | process.StartInfo.UseShellExecute = false; 654 | process.StartInfo.RedirectStandardOutput = true; 655 | process.StartInfo.RedirectStandardError = true; 656 | process.StartInfo.Arguments = "\"--login\" \"-c\" \"exit\""; 657 | process.Start(); 658 | AddProcessToJob(process); 659 | process.WaitForExit(); 660 | if (process.ExitCode != 0) 661 | throw new Exception(); 662 | 663 | _disposables.Remove(process); 664 | return true; 665 | } 666 | catch (Exception) 667 | { 668 | _disposables.Remove(process); 669 | return false; 670 | } 671 | } 672 | } 673 | return false; 674 | } 675 | 676 | /// 677 | /// Checks if the user is using gpg signing and sets the flag accordingly 678 | /// 679 | private void CheckGpg() 680 | { 681 | using (Process process = new Process()) 682 | { 683 | _disposables.Add(process); 684 | try 685 | { 686 | process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 687 | process.StartInfo.CreateNoWindow = true; 688 | process.StartInfo.FileName = GitDir + "/bin/git.exe"; 689 | process.StartInfo.UseShellExecute = false; 690 | process.StartInfo.RedirectStandardOutput = true; 691 | process.StartInfo.Arguments = "config --global commit.gpgsign"; 692 | 693 | Console.WriteLine("CHECKING GPG"); 694 | process.Start(); 695 | AddProcessToJob(process); 696 | string stdout = process.StandardOutput.ReadToEnd(); 697 | process.WaitForExit(); 698 | Console.WriteLine(stdout); 699 | if (stdout.Trim().ToLower() == "true") 700 | { 701 | isGpg = true; 702 | } 703 | } 704 | catch (Exception) { } 705 | finally 706 | { 707 | _disposables.Remove(process); 708 | } 709 | } 710 | } 711 | 712 | /// 713 | /// If isGpg flag is true, set commit.gpgpsign to the value given 714 | /// The value to set commit.gpgsign to 715 | /// 716 | private void SetGpg(bool enable) 717 | { 718 | using (Process process = new Process()) 719 | { 720 | _disposables.Add(process); 721 | try 722 | { 723 | process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 724 | process.StartInfo.CreateNoWindow = true; 725 | process.StartInfo.FileName = GitDir + "/bin/git.exe"; 726 | process.StartInfo.UseShellExecute = false; 727 | process.StartInfo.Arguments = "config --global commit.gpgsign " + enable; 728 | process.Start(); 729 | AddProcessToJob(process); 730 | process.WaitForExit(); 731 | } 732 | catch (Exception) { } 733 | finally 734 | { 735 | _disposables.Remove(process); 736 | } 737 | } 738 | } 739 | 740 | /// 741 | /// Given a URL, download the file from that URL to a destination file. Returns whether the download 742 | /// was successful. This automatically adds the download to the list of disposables, and removes it 743 | /// when the download is completed. 744 | /// 745 | /// The URL to download the file from 746 | /// The relative or absolute path to the destination file to be saved 747 | /// True if the download is successful 748 | private bool DownloadFile(string url, string dest) 749 | { 750 | using (WebClient client = new WebClient()) 751 | { 752 | _disposables.Add(client); 753 | try 754 | { 755 | client.Headers["User-Agent"] = "BuildToolsGui"; 756 | client.DownloadProgressChanged += (sender, e) => 757 | { 758 | double bytesIn = e.BytesReceived; 759 | double totalBytes = e.TotalBytesToReceive; 760 | if (totalBytes < 0) 761 | { 762 | _form.ProgressIndeterminate(); 763 | } 764 | else 765 | { 766 | _form.Progress((int)bytesIn, (int)totalBytes); 767 | } 768 | }; 769 | 770 | client.DownloadFileAsync(new Uri(url), dest); 771 | // Make this thread wait for the download to finish 772 | while (client.IsBusy) 773 | { 774 | Thread.Sleep(50); 775 | } 776 | } 777 | catch (Exception) 778 | { 779 | return false; 780 | } 781 | finally 782 | { 783 | _disposables.Remove(client); 784 | } 785 | } 786 | return true; 787 | } 788 | 789 | /// 790 | /// If the application is closed, this will be run before exit. This will go through the list of any current 791 | /// work that may be running, and it will stop and dispose of them. 792 | /// 793 | public void CleanUp() 794 | { 795 | foreach (IDisposable disposable in _disposables) 796 | { 797 | if (disposable is Process process) 798 | { 799 | process.Kill(); 800 | } 801 | else if (disposable is WebClient client) 802 | { 803 | client.CancelAsync(); 804 | } 805 | disposable.Dispose(); 806 | } 807 | } 808 | private void AddProcessToJob(Process process) 809 | { 810 | _job.AddProcess(process.Handle); 811 | } 812 | } 813 | } -------------------------------------------------------------------------------- /BuildTools/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0uti/BuildToolsGUI/f16e79498cf0d98761e2bf951db5d8455afa7184/BuildTools/icon.ico -------------------------------------------------------------------------------- /BuildTools/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kyle Wood (DemonWav) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Packages.dgml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | -------------------------------------------------------------------------------- /UninstallJava/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /UninstallJava/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Management; 3 | 4 | namespace UninstallJava 5 | { 6 | /// 7 | /// Runner class for uninstalling Java. 8 | /// 9 | public static class Program 10 | { 11 | /// 12 | /// Takes no arguments, when this program is run it will search for Java installed on the machine and 13 | /// run the uninstallation program for it. It will exit 0 if the uninstallation was successful, and 1 14 | /// if the uninstallation was unsuccessful or it did not find Java to uninstall. 15 | /// 16 | /// 17 | public static void Main() 18 | { 19 | try 20 | { 21 | ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product"); 22 | foreach (ManagementObject mo in mos.Get()) 23 | { 24 | if (mo["Name"].ToString().ToLower().StartsWith("java ")) 25 | { 26 | try 27 | { 28 | Environment.Exit(Convert.ToInt32(mo.InvokeMethod("Uninstall", null))); 29 | } 30 | catch (Exception) 31 | { 32 | Environment.Exit(1); 33 | } 34 | } 35 | } 36 | } 37 | catch (Exception) 38 | { 39 | Environment.Exit(1); 40 | } 41 | Environment.Exit(1); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /UninstallJava/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UninstallJava")] 9 | [assembly: AssemblyDescription("Java Uninstaller for BuildTools Windows GUI by DemonWav")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UninstallJava")] 13 | [assembly: AssemblyCopyright("Copyright © Kyle Wood (DemonWav) 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5cb12816-7df6-4448-a914-7a083b2d655f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /UninstallJava/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace UninstallJava.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /UninstallJava/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /UninstallJava/Properties/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 54 | -------------------------------------------------------------------------------- /UninstallJava/UninstallJava.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {87A0AD87-774D-40B8-B9F3-03512357BC5C} 8 | Exe 9 | Properties 10 | UninstallJava 11 | UninstallJava 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | LocalIntranet 36 | 37 | 38 | false 39 | 40 | 41 | Properties\app.manifest 42 | 43 | 44 | UninstallJava.Program 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | True 61 | True 62 | Settings.settings 63 | 64 | 65 | 66 | 67 | 68 | 69 | SettingsSingleFileGenerator 70 | Settings.Designer.cs 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 86 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | BuildTools Windows GUI 2 | ====================== 3 | 4 | The goal for this is, when it's finished, to be an easy to use, self-contained BuildTools GUI for Windows. It will 5 | check for and automatically setup the proper environment for BuildTools to run in, as well as automatically check for 6 | and download updates to the BuildTools jar itself. It is currently working on 64 bit systems, there seems to be some 7 | issues when running with a 32 bit JVM. This seems to be a BuildTools.jar issue, though. 8 | 9 | Downloading 10 | ----------- 11 | 12 | You can download the most recent build directly from GitHub 13 | 14 | No other setup needs to be done, just run the program once you've downloaded it. 15 | 16 | Building 17 | -------- 18 | 19 | Open the solution in Visual Studio. 20 | 21 | To resolve the dependencies, open the NuGet Package Manager (Tools -> Library Package Manager -> Manage NuGet Packages 22 | for Solution) and search for and install `Json.NET` and `DotNetZip`. 23 | 24 | Build it :) 25 | 26 | Further Info 27 | ------------ 28 | 29 | Original author: DemonWav https://github.com/KMStev/BuildToolsGUI 30 | -------------------------------------------------------------------------------- /web/buildtools.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildTools": { 3 | "name": "BuildTools.jar", 4 | "api": "https://hub.spigotmc.org/jenkins/job/BuildTools/lastBuild/api/json" 5 | }, 6 | "java": { 7 | "name": "", 8 | "uninstaller": { 9 | "name": "UninstallJava.exe", 10 | "url": "http://uglylauncher.de/UninstallJava.exe" 11 | }, 12 | "8": "http://uglylauncher.de/java/8.zip", 13 | "16": "http://uglylauncher.de/java/16.zip", 14 | "17": "http://uglylauncher.de/java/17.zip" 15 | }, 16 | "git": { 17 | "64": "http://uglylauncher.de/PortableGit-2.18.0-64-bit.7z.exe", 18 | "32": "http://uglylauncher.de/PortableGit-2.18.0-32-bit.7z.exe" 19 | } 20 | } 21 | --------------------------------------------------------------------------------