From e95773672116fcc987148f467111eaff000ce4b1 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Fri, 18 Mar 2016 14:36:50 -0700 Subject: [PATCH] Don't use PowerShell to download WiX - Don't use PowerShell to download WiX, instead just use HttpClient. - Rehome WiX on our Azure blob storage, not only does this remove an dependency of our build, it also fixes an issue where CodePlex 302's from HTTPS to HTTP which HttpClient doesn't like. - Bake version numbers into paths, to help in cases where we upgrade WiX tool versions but the artifacts folder is not cleaned between builds. --- scripts/dotnet-cli-build/MsiTargets.cs | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/scripts/dotnet-cli-build/MsiTargets.cs b/scripts/dotnet-cli-build/MsiTargets.cs index f71e868b0..4e7422be6 100644 --- a/scripts/dotnet-cli-build/MsiTargets.cs +++ b/scripts/dotnet-cli-build/MsiTargets.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; +using System.Net.Http; using System.Runtime.InteropServices; using Microsoft.DotNet.Cli.Build.Framework; using Microsoft.Extensions.PlatformAbstractions; @@ -14,11 +15,13 @@ namespace Microsoft.DotNet.Cli.Build { private const string ENGINE = "engine.exe"; + private const string WixVersion = "3.10.2"; + private static string WixRoot { get { - return Path.Combine(Dirs.Output, "WixTools"); + return Path.Combine(Dirs.Output, $"WixTools.{WixVersion}"); } } @@ -52,14 +55,24 @@ namespace Microsoft.DotNet.Cli.Build Directory.CreateDirectory(WixRoot); c.Info("Downloading WixTools.."); - // Download Wix version 3.10.2 - https://wix.codeplex.com/releases/view/619491 - Cmd("powershell", "-NoProfile", "-NoLogo", - $"Invoke-WebRequest -Uri https://wix.codeplex.com/downloads/get/1540241 -Method Get -OutFile {WixRoot}\\WixTools.zip") - .Execute() - .EnsureSuccessful(); + + DownloadFile($"https://dotnetcli.blob.core.windows.net/build/wix/wix.{WixVersion}.zip", Path.Combine(WixRoot, "WixTools.zip")); c.Info("Extracting WixTools.."); - ZipFile.ExtractToDirectory($"{WixRoot}\\WixTools.zip", WixRoot); + ZipFile.ExtractToDirectory(Path.Combine(WixRoot, "WixTools.zip"), WixRoot); + } + + private static void DownloadFile(string uri, string destinationPath) + { + using (var httpClient = new HttpClient()) + { + var getTask = httpClient.GetStreamAsync(uri); + + using (var outStream = File.OpenWrite(destinationPath)) + { + getTask.Result.CopyTo(outStream); + } + } } [Target]