Refactor SDK Build Steps
Prefix the SDK build stuff with "Sdk" to make it easier to add other sorts of packages (e.g. the shared host and the shared framework).
This commit is contained in:
parent
88c1340f6d
commit
29bc612565
6 changed files with 54 additions and 47 deletions
|
@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
public static BuildTargetResult GeneratePkg(BuildTargetContext c)
|
public static BuildTargetResult GeneratePkg(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||||
var pkg = c.BuildContext.Get<string>("InstallerFile");
|
var pkg = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||||
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
|
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
|
||||||
"-v", version, "-i", Dirs.Stage2, "-o", pkg)
|
"-v", version, "-i", Dirs.Stage2, "-o", pkg)
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -43,7 +43,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||||
var packageName = Monikers.GetDebianPackageName(c);
|
var packageName = Monikers.GetDebianPackageName(c);
|
||||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||||
var debFile = c.BuildContext.Get<string>("InstallerFile");
|
var debFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||||
var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages");
|
var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages");
|
||||||
var previousVersionURL = $"https://dotnetcli.blob.core.windows.net/dotnet/{channel}/Installers/Latest/dotnet-ubuntu-x64.latest.deb";
|
var previousVersionURL = $"https://dotnetcli.blob.core.windows.net/dotnet/{channel}/Installers/Latest/dotnet-ubuntu-x64.latest.deb";
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string Msi { get; set; }
|
private static string SdkMsi { get; set; }
|
||||||
|
|
||||||
private static string Bundle { get; set; }
|
private static string SdkBundle { get; set; }
|
||||||
|
|
||||||
private static string Engine { get; set; }
|
private static string Engine { get; set; }
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[BuildPlatforms(BuildPlatform.Windows)]
|
[BuildPlatforms(BuildPlatform.Windows)]
|
||||||
public static BuildTargetResult InitMsi(BuildTargetContext c)
|
public static BuildTargetResult InitMsi(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
Bundle = c.BuildContext.Get<string>("InstallerFile");
|
SdkBundle = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||||
Msi = Path.ChangeExtension(Bundle, "msi");
|
SdkMsi = Path.ChangeExtension(SdkBundle, "msi");
|
||||||
Engine = Path.Combine(Path.GetDirectoryName(Bundle), ENGINE);
|
Engine = Path.Combine(Path.GetDirectoryName(SdkBundle), ENGINE);
|
||||||
|
|
||||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||||
|
@ -76,7 +76,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[Target(nameof(MsiTargets.InitMsi),
|
[Target(nameof(MsiTargets.InitMsi),
|
||||||
nameof(GenerateDotnetMuxerMsi),
|
nameof(GenerateDotnetMuxerMsi),
|
||||||
nameof(GenerateDotnetSharedFxMsi),
|
nameof(GenerateDotnetSharedFxMsi),
|
||||||
nameof(GenerateCLISDKMsi))]
|
nameof(GenerateCliSdkMsi))]
|
||||||
[BuildPlatforms(BuildPlatform.Windows)]
|
[BuildPlatforms(BuildPlatform.Windows)]
|
||||||
public static BuildTargetResult GenerateMsis(BuildTargetContext c)
|
public static BuildTargetResult GenerateMsis(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
|
@ -85,11 +85,11 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
[Target]
|
[Target]
|
||||||
[BuildPlatforms(BuildPlatform.Windows)]
|
[BuildPlatforms(BuildPlatform.Windows)]
|
||||||
public static BuildTargetResult GenerateCLISDKMsi(BuildTargetContext c)
|
public static BuildTargetResult GenerateCliSdkMsi(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"),
|
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"),
|
||||||
Dirs.Stage2, Msi, WixRoot, MsiVersion, CliVersion, Arch, Channel)
|
Dirs.Stage2, SdkMsi, WixRoot, MsiVersion, CliVersion, Arch, Channel)
|
||||||
.Execute()
|
.Execute()
|
||||||
.EnsureSuccessful();
|
.EnsureSuccessful();
|
||||||
return c.Success();
|
return c.Success();
|
||||||
|
@ -116,7 +116,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatebundle.ps1"),
|
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatebundle.ps1"),
|
||||||
Msi, Bundle, WixRoot, MsiVersion, CliVersion, Arch, Channel)
|
SdkMsi, SdkBundle, WixRoot, MsiVersion, CliVersion, Arch, Channel)
|
||||||
.EnvironmentVariable("Stage2Dir", Dirs.Stage2)
|
.EnvironmentVariable("Stage2Dir", Dirs.Stage2)
|
||||||
.Execute()
|
.Execute()
|
||||||
.EnsureSuccessful();
|
.EnsureSuccessful();
|
||||||
|
@ -127,7 +127,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[BuildPlatforms(BuildPlatform.Windows)]
|
[BuildPlatforms(BuildPlatform.Windows)]
|
||||||
public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c)
|
public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
Cmd($"{WixRoot}\\insignia.exe", "-ib", Bundle, "-o", Engine)
|
Cmd($"{WixRoot}\\insignia.exe", "-ib", SdkBundle, "-o", Engine)
|
||||||
.Execute()
|
.Execute()
|
||||||
.EnsureSuccessful();
|
.EnsureSuccessful();
|
||||||
return c.Success();
|
return c.Success();
|
||||||
|
@ -137,7 +137,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[BuildPlatforms(BuildPlatform.Windows)]
|
[BuildPlatforms(BuildPlatform.Windows)]
|
||||||
public static BuildTargetResult ReattachEngineToBundle(BuildTargetContext c)
|
public static BuildTargetResult ReattachEngineToBundle(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
Cmd($"{WixRoot}\\insignia.exe", "-ab", Engine, Bundle, "-o", Bundle)
|
Cmd($"{WixRoot}\\insignia.exe", "-ab", Engine, SdkBundle, "-o", SdkBundle)
|
||||||
.Execute()
|
.Execute()
|
||||||
.EnsureSuccessful();
|
.EnsureSuccessful();
|
||||||
return c.Success();
|
return c.Success();
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[BuildPlatforms(BuildPlatform.Windows)]
|
[BuildPlatforms(BuildPlatform.Windows)]
|
||||||
public static BuildTargetResult GenerateZip(BuildTargetContext c)
|
public static BuildTargetResult GenerateZip(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var zipFile = c.BuildContext.Get<string>("CompressedFile");
|
var zipFile = c.BuildContext.Get<string>("SdkCompressedFile");
|
||||||
|
|
||||||
if (File.Exists(zipFile))
|
if (File.Exists(zipFile))
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[BuildPlatforms(BuildPlatform.Unix)]
|
[BuildPlatforms(BuildPlatform.Unix)]
|
||||||
public static BuildTargetResult GenerateTarBall(BuildTargetContext c)
|
public static BuildTargetResult GenerateTarBall(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var tarFile = c.BuildContext.Get<string>("CompressedFile");
|
var tarFile = c.BuildContext.Get<string>("SdkCompressedFile");
|
||||||
|
|
||||||
if (File.Exists(tarFile))
|
if (File.Exists(tarFile))
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,34 +108,11 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[Target]
|
[Target]
|
||||||
public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c)
|
public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var productName = Monikers.GetProductMoniker(c);
|
|
||||||
var config = Environment.GetEnvironmentVariable("CONFIGURATION");
|
var config = Environment.GetEnvironmentVariable("CONFIGURATION");
|
||||||
var versionBadgeName = $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}_{config}_version_badge.svg";
|
var versionBadgeName = $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}_{config}_version_badge.svg";
|
||||||
c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName);
|
c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName);
|
||||||
|
|
||||||
var extension = CurrentPlatform.IsWindows ? ".zip" : ".tar.gz";
|
AddInstallerArtifactToContext(c, "dotnet", "Sdk");
|
||||||
c.BuildContext["CompressedFile"] = Path.Combine(Dirs.Packages, productName + extension);
|
|
||||||
|
|
||||||
string installer = "";
|
|
||||||
switch (CurrentPlatform.Current)
|
|
||||||
{
|
|
||||||
case BuildPlatform.Windows:
|
|
||||||
installer = productName + ".exe";
|
|
||||||
break;
|
|
||||||
case BuildPlatform.OSX:
|
|
||||||
installer = productName + ".pkg";
|
|
||||||
break;
|
|
||||||
case BuildPlatform.Ubuntu:
|
|
||||||
installer = productName + ".deb";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(installer))
|
|
||||||
{
|
|
||||||
c.BuildContext["InstallerFile"] = Path.Combine(Dirs.Packages, installer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
@ -361,5 +338,35 @@ cmake is required to build the native host 'corehost'";
|
||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AddInstallerArtifactToContext(BuildTargetContext c, string artifactPrefix, string contextPrefix)
|
||||||
|
{
|
||||||
|
var productName = Monikers.GetProductMoniker(c, artifactPrefix);
|
||||||
|
|
||||||
|
var extension = CurrentPlatform.IsWindows ? ".zip" : ".tar.gz";
|
||||||
|
c.BuildContext[contextPrefix + "CompressedFile"] = Path.Combine(Dirs.Packages, productName + extension);
|
||||||
|
|
||||||
|
string installer = "";
|
||||||
|
switch (CurrentPlatform.Current)
|
||||||
|
{
|
||||||
|
case BuildPlatform.Windows:
|
||||||
|
installer = productName + ".exe";
|
||||||
|
break;
|
||||||
|
case BuildPlatform.OSX:
|
||||||
|
installer = productName + ".pkg";
|
||||||
|
break;
|
||||||
|
case BuildPlatform.Ubuntu:
|
||||||
|
installer = productName + ".deb";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(installer))
|
||||||
|
{
|
||||||
|
c.BuildContext[contextPrefix + "InstallerFile"] = Path.Combine(Dirs.Packages, installer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
[Target(nameof(PublishTargets.PublishVersionBadge),
|
[Target(nameof(PublishTargets.PublishVersionBadge),
|
||||||
nameof(PublishTargets.PublishCompressedFile),
|
nameof(PublishTargets.PublishCompressedFile),
|
||||||
nameof(PublishTargets.PublishInstallerFile),
|
nameof(PublishTargets.PublishSdkInstallerFile),
|
||||||
nameof(PublishTargets.PublishLatestVersionTextFile))]
|
nameof(PublishTargets.PublishLatestVersionTextFile))]
|
||||||
public static BuildTargetResult PublishArtifacts(BuildTargetContext c)
|
public static BuildTargetResult PublishArtifacts(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
[Target]
|
[Target]
|
||||||
public static BuildTargetResult PublishCompressedFile(BuildTargetContext c)
|
public static BuildTargetResult PublishCompressedFile(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var compressedFile = c.BuildContext.Get<string>("CompressedFile");
|
var compressedFile = c.BuildContext.Get<string>("SdkCompressedFile");
|
||||||
var compressedFileBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(compressedFile)}";
|
var compressedFileBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(compressedFile)}";
|
||||||
var latestCompressedFile = compressedFile.Replace(Version, "latest");
|
var latestCompressedFile = compressedFile.Replace(Version, "latest");
|
||||||
var latestCompressedFileBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(latestCompressedFile)}";
|
var latestCompressedFileBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(latestCompressedFile)}";
|
||||||
|
@ -79,9 +79,9 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
[Target]
|
[Target]
|
||||||
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu)]
|
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu)]
|
||||||
public static BuildTargetResult PublishInstallerFile(BuildTargetContext c)
|
public static BuildTargetResult PublishSdkInstallerFile(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var installerFile = c.BuildContext.Get<string>("InstallerFile");
|
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||||
var installerFileBlob = $"{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
var installerFileBlob = $"{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
||||||
var latestInstallerFile = installerFile.Replace(Version, "latest");
|
var latestInstallerFile = installerFile.Replace(Version, "latest");
|
||||||
var latestInstallerFileBlob = $"{Channel}/Installers/Latest/{Path.GetFileName(latestInstallerFile)}";
|
var latestInstallerFileBlob = $"{Channel}/Installers/Latest/{Path.GetFileName(latestInstallerFile)}";
|
||||||
|
@ -102,12 +102,12 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Target(nameof(PublishInstallerFile))]
|
[Target(nameof(PublishSdkInstallerFile))]
|
||||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||||
public static BuildTargetResult PublishDebFileToDebianRepo(BuildTargetContext c)
|
public static BuildTargetResult PublishDebFileToDebianRepo(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var packageName = Monikers.GetDebianPackageName(c);
|
var packageName = Monikers.GetDebianPackageName(c);
|
||||||
var installerFile = c.BuildContext.Get<string>("InstallerFile");
|
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||||
var uploadUrl = $"https://dotnetcli.blob.core.windows.net/dotnet/{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
var uploadUrl = $"https://dotnetcli.blob.core.windows.net/dotnet/{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
||||||
var uploadJson = GenerateUploadJsonFile(packageName, Version, uploadUrl);
|
var uploadJson = GenerateUploadJsonFile(packageName, Version, uploadUrl);
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
public class Monikers
|
public class Monikers
|
||||||
{
|
{
|
||||||
public static string GetProductMoniker(BuildTargetContext c)
|
public static string GetProductMoniker(BuildTargetContext c, string artifactPrefix)
|
||||||
{
|
{
|
||||||
string osname = GetOSShortName();
|
string osname = GetOSShortName();
|
||||||
var arch = CurrentArchitecture.Current.ToString();
|
var arch = CurrentArchitecture.Current.ToString();
|
||||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||||
return $"dotnet-{osname}-{arch}.{version}";
|
return $"{artifactPrefix}-{osname}-{arch}.{version}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetDebianPackageName(BuildTargetContext c)
|
public static string GetDebianPackageName(BuildTargetContext c)
|
||||||
|
|
Loading…
Reference in a new issue