Misc build changes

For injestion into a composed build, I'm adding some minor tweaks to
our build system:

 - Teach DownloadFile task how to consume file:// URLs so we can pass
   around artifacts using local sources.
 - Add `SkipBuildingInstallers`, an MSBuild property that can be set
   to true when installers (pkgs, msis, debs, rpms and the like) do
   not need to be built.
 - Add `IncludeAdditionalSharedFrameworks`, an MSBuild property that
   can be set to prevent additional shared frameworks (i.e. shared
   frameworks that the CLI does not use at runtime) from being
   downloaded and included in our payload.
 - Add `IncludeNuGetPackageArchive` an MSBuild property that can be
   set to prevent the lzma archive containing all the nupkgs we
   restore on first run from being included in the final output.
 - Provide a way to change the Uri use for blob storage (so the
   composed build and point at a local folder that looks like blob
   storage to pick up artifacts from).
This commit is contained in:
Matt Ellis 2017-02-14 17:21:37 -08:00
parent a6bc22e499
commit 47b75cfa12
6 changed files with 44 additions and 26 deletions

View file

@ -28,23 +28,34 @@ namespace Microsoft.DotNet.Cli.Build
return true;
}
Log.LogMessage($"Downloading '{Uri}' to '{DestinationPath}'");
const string FileUriProtocol = "file://";
using (var httpClient = new HttpClient())
if (Uri.StartsWith(FileUriProtocol, StringComparison.Ordinal))
{
var getTask = httpClient.GetStreamAsync(Uri);
var filePath = Uri.Substring(FileUriProtocol.Length);
Log.LogMessage($"Copying '{filePath}' to '{DestinationPath}'");
File.Copy(filePath, DestinationPath);
}
else
{
Log.LogMessage($"Downloading '{Uri}' to '{DestinationPath}'");
try
using (var httpClient = new HttpClient())
{
using (var outStream = File.Create(DestinationPath))
var getTask = httpClient.GetStreamAsync(Uri);
try
{
getTask.Result.CopyTo(outStream);
using (var outStream = File.Create(DestinationPath))
{
getTask.Result.CopyTo(outStream);
}
}
catch (Exception)
{
File.Delete(DestinationPath);
throw;
}
}
catch (Exception)
{
File.Delete(DestinationPath);
throw;
}
}