Update PullNupkgFilesFromBlob to find the latest Azure blob drop
that contains all the runtime packages
This commit is contained in:
parent
d7376f84c3
commit
0b913968b6
3 changed files with 93 additions and 4 deletions
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.WindowsAzure.Storage;
|
||||
using Microsoft.WindowsAzure.Storage.Blob;
|
||||
|
@ -326,12 +328,87 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target(nameof(PrepareTargets.Init), nameof(InitPublish))]
|
||||
public static BuildTargetResult PullNupkgFilesFromBlob(BuildTargetContext c)
|
||||
{
|
||||
var hostBlob = $"{Channel}/Binaries/{CliNuGetVersion}/";
|
||||
var pathToPublish = Environment.GetEnvironmentVariable("BLOB_VIRTUAL_PATH_TO_PUBLISH");
|
||||
if (string.IsNullOrEmpty(pathToPublish))
|
||||
pathToPublish = FindLatestCompleteBuild();
|
||||
|
||||
Directory.CreateDirectory(Dirs.Packages);
|
||||
AzurePublisherTool.DownloadFiles(hostBlob, ".nupkg", Dirs.Packages);
|
||||
if (string.IsNullOrEmpty(pathToPublish))
|
||||
{
|
||||
Console.WriteLine("Didn't find a directory with all the necessary runtime packages!");
|
||||
return c.Failed();
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Dirs.PackagesNoRID);
|
||||
AzurePublisherTool.DownloadFiles(pathToPublish, ".nupkg", Dirs.PackagesNoRID);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static string FindLatestCompleteBuild()
|
||||
{
|
||||
var hostBlob = $"{Channel}/Binaries/";
|
||||
|
||||
Regex buildVersionRegex = new Regex(@"Binaries/(?<version>\d+\.\d+\.\d+-[^-]+-\d{6})/$");
|
||||
|
||||
List<string> buildVersions = new List<string>();
|
||||
foreach (string file in AzurePublisherTool.ListBlobs(hostBlob))
|
||||
{
|
||||
var match = buildVersionRegex.Match(file);
|
||||
if (match.Success)
|
||||
{
|
||||
buildVersions.Add(match.Groups["version"].Value);
|
||||
}
|
||||
}
|
||||
|
||||
buildVersions.Sort();
|
||||
buildVersions.Reverse();
|
||||
|
||||
Dictionary<string, bool> runtimes = new Dictionary<string, bool>()
|
||||
{
|
||||
{"win7", false },
|
||||
{"osx.10.10", false },
|
||||
{"rhel.7", false },
|
||||
{"ubuntu.14.04", false },
|
||||
|
||||
};
|
||||
|
||||
foreach (var bv in buildVersions)
|
||||
{
|
||||
Console.WriteLine($"Version: {bv}");
|
||||
|
||||
var buildFiles = AzurePublisherTool.ListBlobs(hostBlob + bv);
|
||||
|
||||
foreach (var bf in buildFiles)
|
||||
{
|
||||
string buildFile = Path.GetFileName(bf);
|
||||
|
||||
foreach (var runtime in runtimes.Keys)
|
||||
{
|
||||
if (buildFile.StartsWith($"runtime.{runtime}"))
|
||||
{
|
||||
runtimes[runtime] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool missingRuntime = false;
|
||||
foreach (var runtime in runtimes)
|
||||
{
|
||||
if (!runtime.Value)
|
||||
{
|
||||
missingRuntime = true;
|
||||
Console.WriteLine($"Version {bv} is missing packages for runtime {runtime.Key}");
|
||||
}
|
||||
}
|
||||
|
||||
if (!missingRuntime)
|
||||
{
|
||||
return hostBlob + bv;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
|
@ -94,7 +95,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return $"{channel}/Binaries/{version}/{Path.GetFileName(archiveFile)}";
|
||||
}
|
||||
|
||||
public async void DownloadFiles(string blobVirtualDirectory, string fileExtension, string downloadPath)
|
||||
public void DownloadFiles(string blobVirtualDirectory, string fileExtension, string downloadPath)
|
||||
{
|
||||
CloudBlobDirectory blobDir = _blobContainer.GetDirectoryReference(blobVirtualDirectory);
|
||||
BlobContinuationToken continuationToken = new BlobContinuationToken();
|
||||
|
@ -111,5 +112,15 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> ListBlobs(string blobVirtualDirectory)
|
||||
{
|
||||
CloudBlobDirectory blobDir = _blobContainer.GetDirectoryReference(blobVirtualDirectory);
|
||||
BlobContinuationToken continuationToken = new BlobContinuationToken();
|
||||
|
||||
var blobFiles = blobDir.ListBlobsSegmentedAsync(continuationToken).Result;
|
||||
|
||||
return blobFiles.Results.Select(bf => bf.Uri.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
PlatformServices.Default.Runtime.GetRuntimeIdentifier());
|
||||
|
||||
public static readonly string PackagesIntermediate = Path.Combine(Output, "packages/intermediate");
|
||||
public static readonly string PackagesNoRID = Path.Combine(RepoRoot, "artifacts", "packages");
|
||||
public static readonly string Packages = Path.Combine(Output, "packages");
|
||||
public static readonly string Stage1 = Path.Combine(Output, "stage1");
|
||||
public static readonly string Stage1Compilation = Path.Combine(Output, "stage1compilation");
|
||||
|
|
Loading…
Add table
Reference in a new issue