From fdbc958b3481680f3ca575e9c24fe4debb100597 Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Wed, 2 Oct 2019 16:29:26 -0700 Subject: [PATCH] Include the download script --- .github/workflows/msbuild-test.yml | 2 +- scripts/SetupMSBuild.cs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 scripts/SetupMSBuild.cs diff --git a/.github/workflows/msbuild-test.yml b/.github/workflows/msbuild-test.yml index 5763e4d4..b2d259dd 100644 --- a/.github/workflows/msbuild-test.yml +++ b/.github/workflows/msbuild-test.yml @@ -10,7 +10,7 @@ jobs: with: submodules: recursive - name: Download MSBuild installer - run: powershell "$source = (New-Object System.Net.WebClient).DownloadString(\"https://gist.githubusercontent.com/sgkoishi/87e613881f9164bf03849603dd4f4266/raw/\") ; Add-Type + run: powershell "$source = Get-Content -Path \"scripts\\SetupMSBuild.cs\" ; Add-Type -TypeDefinition \"$source\" ; [SetupMSBuild]::Download((Get-Item -Path \".\\\").FullName); " - name: Setup .NET SDK diff --git a/scripts/SetupMSBuild.cs b/scripts/SetupMSBuild.cs new file mode 100644 index 00000000..89ce0588 --- /dev/null +++ b/scripts/SetupMSBuild.cs @@ -0,0 +1,22 @@ +using System; + +public class SetupMSBuild +{ + public static void Download(string directory) + { + try + { + var wc = new System.Net.WebClient(); + var content = wc.DownloadString("https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16"); + var url = System.Text.RegularExpressions.Regex.Match(content, + "https://download.visualstudio.microsoft.com/download/.*\\.exe").Value; + Console.WriteLine(url); + wc.DownloadFile(url, System.IO.Path.Combine(directory, "vs_BuildTools.exe")); + wc.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", System.IO.Path.Combine(directory, "nuget.exe")); + } + catch (Exception e) + { + Console.WriteLine(e); + } + } +} \ No newline at end of file