dotnet-installer/build_projects/dotnet-cli-build/CheckIfAllBuildsHavePublished.cs
Livar Cunha e2b679c4bb Merge branch 'master' of /Users/livarcocc/Documents/git/cli into merge_master_cli
* 'master' of /Users/livarcocc/Documents/git/cli: (1063 commits)
  Updating signing project to use new intermediate directory (int).
  Update runtimeconfig.json doc for 2.1 (#9382)
  Shortening the path to the intermediate folder by renaming it to int.
  fix typo (#9364)
  Updating asp.net to 2.2.0 as well.
  Updating the build and tests to work with the 2.2.0 runtime.
  Simplified combining dictionaries in Telemetry
  Fixing 'Channel' and 'BranchName': "release/2.1.4xx" to "master" (#9362)
  Fix extraction of folders (#9335)
  Update Sha256Hasher.cs
  Fix relative path tool path (#9330)
  Insert updated SDK from 2.1.4xx branch
  MSBuild 15.8.60
  Fix crash when user home directory cannot be determined.
  Make `CliFolderPathCalculator` a static class.
  Don't add the ReleaseSuffix to the branding on the CLI when DropSuffix is set to true.
  Add retry when Directory.Move (#9313)
  Override new SdkResult public properties
  Add reference to Microsoft.Build.NuGetSdkResolver
  Disable crossgen for MSBuild inline-task refs
  ...
2018-06-25 22:38:01 -07:00

91 lines
2.6 KiB
C#

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#if !SOURCE_BUILD
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Microsoft.DotNet.Cli.Build
{
public class CheckIfAllBuildsHavePublished : Task
{
private AzurePublisher _azurePublisher;
[Required]
public string AccountName { get; set; }
[Required]
public string AccountKey { get; set; }
[Required]
public string ContainerName { get; set; }
[Required]
public string NugetVersion { get; set; }
[Required]
public string VersionBadgeMoniker { get; set; }
[Output]
public string HaveAllBuildsPublished { get; set; }
private AzurePublisher AzurePublisherTool
{
get
{
if (_azurePublisher == null)
{
_azurePublisher = new AzurePublisher(AccountName, AccountKey, ContainerName);
}
return _azurePublisher;
}
}
public override bool Execute()
{
var badges = new Dictionary<string, bool>()
{
{ "win_x86", false },
{ "win_x64", false },
{ "osx_x64", false },
{ "linux_x64", false },
{ "rhel.6_x64", false },
{ "linux_musl_x64", false },
{ "all_linux_distros_native_installer", false },
{ "linux_arm", false },
{ "linux_arm64", false }
};
if (!badges.ContainsKey(VersionBadgeMoniker))
{
throw new ArgumentException($"A new OS build '{VersionBadgeMoniker}' was added without adding the moniker to the {nameof(badges)} lookup");
}
IEnumerable<string> blobs = AzurePublisherTool.ListBlobs(AzurePublisher.Product.Sdk, NugetVersion);
foreach (string file in blobs)
{
string name = Path.GetFileName(file);
foreach (string img in badges.Keys)
{
if ((name.StartsWith($"{img}_")) && (name.EndsWith(".svg")))
{
badges[img] = true;
break;
}
}
}
HaveAllBuildsPublished = badges.Values.All(v => v).ToString();
return true;
}
}
}
#endif