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.
This commit is contained in:
Matt Ellis 2016-03-18 14:36:50 -07:00
parent 1428eb81cf
commit e957736721

View file

@ -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]