Refactor the build scripts
- Bifurcate Package and Publish targets to enable signing. - Move publish from bash/ps into c#. - Create multiple targets to create MSIs and Bundles.
This commit is contained in:
parent
781678de92
commit
d4a3190bfc
25 changed files with 754 additions and 577 deletions
|
@ -13,8 +13,10 @@ if ($versionSuffix -ne "") {
|
|||
$versionArg = "--version-suffix"
|
||||
}
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
. "$REPOROOT\scripts\package\projectsToPack.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
. "$RepoRoot\scripts\common\_common.ps1"
|
||||
. "$RepoRoot\scripts\package\projectsToPack.ps1"
|
||||
|
||||
$IntermediatePackagesDir = "$RepoRoot\artifacts\packages\intermediate"
|
||||
$PackagesDir = "$RepoRoot\artifacts\packages"
|
||||
|
|
|
@ -12,26 +12,65 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../../scripts/common/_common.sh"
|
||||
help(){
|
||||
echo "Usage: $0 [--version <pkg version>] [--input <input directory>] [--output <output pkg>] [--help]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --version <pkg version> Specify a version for the package."
|
||||
echo " --input <input directory> Package the entire contents of the directory tree."
|
||||
echo " --output <output pkg> The path to which the package will be written."
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [[ $# > 0 ]]; do
|
||||
lowerI="$(echo $1 | awk '{print tolower($0)}')"
|
||||
case $lowerI in
|
||||
-v|--version)
|
||||
DOTNET_CLI_VERSION=$2
|
||||
shift
|
||||
;;
|
||||
-o|--output)
|
||||
OUTPUT_PKG=$2
|
||||
shift
|
||||
;;
|
||||
-i|--input)
|
||||
INPUT_DIR=$2
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
help
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$DOTNET_CLI_VERSION" ]; then
|
||||
echo "Provide a version number (DOTNET_CLI_VERSION) $DOTNET_CLI_VERSION" && exit 1
|
||||
echo "Provide a version number. Missing option '--version'" && help
|
||||
fi
|
||||
|
||||
STAGE2_DIR=$REPOROOT/artifacts/$RID/stage2
|
||||
if [ -z "$OUTPUT_PKG" ]; then
|
||||
echo "Provide an output pkg. Missing option '--output'" && help
|
||||
fi
|
||||
|
||||
if [ ! -d "$STAGE2_DIR" ]; then
|
||||
echo "Missing stage2 output in $STAGE2_DIR" 1>&2
|
||||
if [ -z "$INPUT_DIR" ]; then
|
||||
echo "Provide an inout directory. Missing option '--input'" && help
|
||||
fi
|
||||
|
||||
if [ ! -d "$INPUT_DIR" ]; then
|
||||
echo "Missing input directory - $INPUT_DIR" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PACKAGE_DIR=$REPOROOT/artifacts/packages/pkg
|
||||
PACKAGE_DIR=$(dirname "${OUTPUT_PKG}")
|
||||
[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR
|
||||
|
||||
PACKAGE_ID=dotnet-osx-x64.${DOTNET_CLI_VERSION}.pkg
|
||||
PACKAGE_NAME=$PACKAGE_DIR/$PACKAGE_ID
|
||||
#chmod -R 755 $STAGE2_DIR
|
||||
pkgbuild --root $STAGE2_DIR \
|
||||
PACKAGE_ID=$(basename "${OUTPUT_PKG}")
|
||||
|
||||
#chmod -R 755 $INPUT_DIR
|
||||
pkgbuild --root $INPUT_DIR \
|
||||
--version $DOTNET_CLI_VERSION \
|
||||
--scripts $DIR/scripts \
|
||||
--identifier com.microsoft.dotnet.cli.pkg.dotnet-osx-x64 \
|
||||
|
@ -40,10 +79,8 @@ pkgbuild --root $STAGE2_DIR \
|
|||
|
||||
cat $DIR/Distribution-Template | sed "/{VERSION}/s//$DOTNET_CLI_VERSION/g" > $DIR/Dist
|
||||
|
||||
productbuild --version $DOTNET_CLI_VERSION --identifier com.microsoft.dotnet.cli --package-path $DIR --resources $DIR/resources --distribution $DIR/Dist $PACKAGE_NAME
|
||||
productbuild --version $DOTNET_CLI_VERSION --identifier com.microsoft.dotnet.cli --package-path $DIR --resources $DIR/resources --distribution $DIR/Dist $OUTPUT_PKG
|
||||
|
||||
#Clean temp files
|
||||
rm $DIR/$PACKAGE_ID
|
||||
rm $DIR/Dist
|
||||
|
||||
$REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME
|
||||
|
|
104
packaging/windows/generatebundle.ps1
Normal file
104
packaging/windows/generatebundle.ps1
Normal file
|
@ -0,0 +1,104 @@
|
|||
# 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.
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIFile,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetBundleOutput,
|
||||
[Parameter(Mandatory=$true)][string]$WixRoot
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
function RunCandleForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running candle for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\candle.exe -nologo `
|
||||
-dDotnetSrc="$inputDir" `
|
||||
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
|
||||
-dBuildVersion="$env:DOTNET_MSI_VERSION" `
|
||||
-dDisplayVersion="$env:DOTNET_CLI_VERSION" `
|
||||
-dReleaseSuffix="$env:ReleaseSuffix" `
|
||||
-dMsiSourcePath="$DotnetMSIFile" `
|
||||
-arch "$env:ARCHITECTURE" `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
"$AuthWsxRoot\bundle.wxs" | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Candle failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
function RunLightForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running light for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\light.exe -nologo `
|
||||
-cultures:en-us `
|
||||
bundle.wixobj `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
-b "$AuthWsxRoot" `
|
||||
-out $DotnetBundleOutput | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Light failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
if(!(Test-Path $DotnetMSIFile))
|
||||
{
|
||||
throw "$DotnetMSIFile not found"
|
||||
}
|
||||
|
||||
Write-Host "Creating dotnet Bundle at $DotnetBundleOutput"
|
||||
|
||||
if([string]::IsNullOrEmpty($WixRoot))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunCandleForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLightForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetBundleOutput))
|
||||
{
|
||||
throw "Unable to create the dotnet bundle."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Successfully created dotnet bundle - $DotnetBundleOutput"
|
||||
|
||||
_ $RepoRoot\test\Installer\testmsi.ps1 @("$DotnetMSIFile")
|
||||
|
||||
exit $LastExitCode
|
|
@ -2,42 +2,17 @@
|
|||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$inputDir
|
||||
[Parameter(Mandatory=$true)][string]$inputDir,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIOutput,
|
||||
[Parameter(Mandatory=$true)][string]$WixRoot
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
$DotnetMSIOutput = ""
|
||||
$DotnetBundleOutput = ""
|
||||
$WixRoot = ""
|
||||
$InstallFileswsx = "install-files.wxs"
|
||||
$InstallFilesWixobj = "install-files.wixobj"
|
||||
|
||||
function AcquireWixTools
|
||||
{
|
||||
$result = Join-Path $OutputDir WiXTools
|
||||
|
||||
if(Test-Path "$result\candle.exe")
|
||||
{
|
||||
return $result
|
||||
}
|
||||
|
||||
Write-Host Downloading Wixtools..
|
||||
New-Item $result -type directory -force | Out-Null
|
||||
# Download Wix version 3.10.2 - https://wix.codeplex.com/releases/view/619491
|
||||
Invoke-WebRequest -Uri https://wix.codeplex.com/downloads/get/1540241 -Method Get -OutFile $result\WixTools.zip
|
||||
|
||||
Write-Host Extracting Wixtools..
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$result\WixTools.zip", $result)
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
throw "Unable to download and extract the WixTools."
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function RunHeat
|
||||
{
|
||||
$result = $true
|
||||
|
@ -121,65 +96,6 @@ function RunLight
|
|||
return $result
|
||||
}
|
||||
|
||||
function RunCandleForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running candle for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\candle.exe -nologo `
|
||||
-dDotnetSrc="$inputDir" `
|
||||
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
|
||||
-dBuildVersion="$env:DOTNET_MSI_VERSION" `
|
||||
-dDisplayVersion="$env:DOTNET_CLI_VERSION" `
|
||||
-dReleaseSuffix="$env:ReleaseSuffix" `
|
||||
-dMsiSourcePath="$DotnetMSIOutput" `
|
||||
-arch "$env:ARCHITECTURE" `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
"$AuthWsxRoot\bundle.wxs" | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Candle failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
function RunLightForBundle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running light for bundle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\windows"
|
||||
|
||||
.\light.exe -nologo `
|
||||
-cultures:en-us `
|
||||
bundle.wixobj `
|
||||
-ext WixBalExtension.dll `
|
||||
-ext WixUtilExtension.dll `
|
||||
-ext WixTagExtension.dll `
|
||||
-b "$AuthWsxRoot" `
|
||||
-out $DotnetBundleOutput | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Light failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
if(!(Test-Path $inputDir))
|
||||
{
|
||||
throw "$inputDir not found"
|
||||
|
@ -190,14 +106,7 @@ if(!(Test-Path $PackageDir))
|
|||
mkdir $PackageDir | Out-Null
|
||||
}
|
||||
|
||||
$DotnetMSIOutput = Join-Path $PackageDir "dotnet-win-$env:ARCHITECTURE.$env:DOTNET_CLI_VERSION.msi"
|
||||
$DotnetBundleOutput = Join-Path $PackageDir "dotnet-win-$env:ARCHITECTURE.$env:DOTNET_CLI_VERSION.exe"
|
||||
|
||||
Write-Host "Creating dotnet MSI at $DotnetMSIOutput"
|
||||
Write-Host "Creating dotnet Bundle at $DotnetBundleOutput"
|
||||
|
||||
$WixRoot = AcquireWixTools
|
||||
|
||||
|
||||
if([string]::IsNullOrEmpty($WixRoot))
|
||||
{
|
||||
|
@ -214,39 +123,17 @@ if(-Not (RunCandle))
|
|||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunCandleForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLight))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLightForBundle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetMSIOutput))
|
||||
{
|
||||
throw "Unable to create the dotnet msi."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetBundleOutput))
|
||||
{
|
||||
throw "Unable to create the dotnet bundle."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Successfully created dotnet MSI - $DotnetMSIOutput"
|
||||
Write-Host -ForegroundColor Green "Successfully created dotnet bundle - $DotnetBundleOutput"
|
||||
|
||||
_ $RepoRoot\test\Installer\testmsi.ps1 @("$DotnetMSIOutput")
|
||||
|
||||
$PublishScript = Join-Path $PSScriptRoot "..\..\scripts\publish\publish.ps1"
|
||||
& $PublishScript -file $DotnetBundleOutput
|
||||
|
||||
exit $LastExitCode
|
||||
|
|
|
@ -48,6 +48,43 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsUnix
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsLinux || IsOSX;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsLinux
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsUbuntu || IsCentOS;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPlatform(BuildPlatform platform)
|
||||
{
|
||||
switch (platform)
|
||||
{
|
||||
case BuildPlatform.Windows:
|
||||
return IsWindows;
|
||||
case BuildPlatform.Ubuntu:
|
||||
return IsUbuntu;
|
||||
case BuildPlatform.OSX:
|
||||
return IsOSX;
|
||||
case BuildPlatform.CentOS:
|
||||
return IsCentOS;
|
||||
case BuildPlatform.Unix:
|
||||
return IsUnix;
|
||||
case BuildPlatform.Linux:
|
||||
return IsLinux;
|
||||
default:
|
||||
throw new Exception("Unrecognized Platform.");
|
||||
}
|
||||
}
|
||||
|
||||
private static BuildPlatform DetermineCurrentPlatform()
|
||||
{
|
||||
if (IsWindows)
|
||||
|
|
|
@ -3,8 +3,10 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
public enum BuildPlatform
|
||||
{
|
||||
Windows = 1,
|
||||
OSX = 2,
|
||||
Ubuntu = 3,
|
||||
CentOS = 4
|
||||
Unix = 2,
|
||||
Linux = 3,
|
||||
OSX = 4,
|
||||
Ubuntu = 5,
|
||||
CentOS = 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,11 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
{
|
||||
return self.UseTargets(new[]
|
||||
{
|
||||
new BuildTarget("Default", "Standard Goals", new [] { "Prepare", "Compile", "Test", "Publish" }),
|
||||
new BuildTarget("Default", "Standard Goals", new [] { "Prepare", "Compile", "Test", "Package", "Publish" }),
|
||||
new BuildTarget("Prepare", "Standard Goals"),
|
||||
new BuildTarget("Compile", "Standard Goals"),
|
||||
new BuildTarget("Test", "Standard Goals"),
|
||||
new BuildTarget("Package", "Standard Goals"),
|
||||
new BuildTarget("Publish", "Standard Goals")
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,16 +20,9 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
|
||||
public override bool EvaluateCondition()
|
||||
{
|
||||
var currentPlatform = CurrentPlatform.Current;
|
||||
|
||||
if (currentPlatform == default(BuildPlatform))
|
||||
{
|
||||
throw new Exception("Unrecognized Platform.");
|
||||
}
|
||||
|
||||
foreach (var platform in _buildPlatforms)
|
||||
{
|
||||
if (platform == currentPlatform)
|
||||
if (CurrentPlatform.IsPlatform(platform))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build.Framework
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
|
||||
public class EnvironmentAttribute : TargetConditionAttribute
|
||||
{
|
||||
private string _envVar;
|
||||
private string _expectedVal;
|
||||
|
||||
public EnvironmentAttribute(string envVar, string expectedVal)
|
||||
{
|
||||
if (string.IsNullOrEmpty(envVar))
|
||||
{
|
||||
throw new ArgumentNullException("envVar");
|
||||
}
|
||||
|
||||
_envVar = envVar;
|
||||
_expectedVal = expectedVal;
|
||||
}
|
||||
|
||||
public override bool EvaluateCondition()
|
||||
{
|
||||
var actualVal = Environment.GetEnvironmentVariable(_envVar);
|
||||
|
||||
if (string.IsNullOrEmpty(_expectedVal))
|
||||
{
|
||||
return string.IsNullOrEmpty(actualVal) ||
|
||||
actualVal.Equals("0") ||
|
||||
actualVal.ToLower().Equals("false");
|
||||
}
|
||||
|
||||
return _expectedVal.Equals(actualVal, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
51
scripts/dotnet-cli-build/InstallerTargets.cs
Normal file
51
scripts/dotnet-cli-build/InstallerTargets.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class InstallerTargets
|
||||
{
|
||||
[Target(nameof(MsiTargets.GenerateMsis),
|
||||
nameof(MsiTargets.GenerateBundle),
|
||||
nameof(InstallerTargets.GeneratePkg),
|
||||
nameof(InstallerTargets.GenerateDeb))]
|
||||
public static BuildTargetResult GenerateInstaller(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.OSX)]
|
||||
public static BuildTargetResult GeneratePkg(BuildTargetContext c)
|
||||
{
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
var pkg = c.BuildContext.Get<string>("InstallerFile");
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
|
||||
"-v", version, "-i", Dirs.Stage2, "-o", pkg)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult GenerateDeb(BuildTargetContext c)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"))
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
}
|
||||
}
|
139
scripts/dotnet-cli-build/MsiTargets.cs
Normal file
139
scripts/dotnet-cli-build/MsiTargets.cs
Normal file
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class MsiTargets
|
||||
{
|
||||
private const string ENGINE = "engine.exe";
|
||||
|
||||
private static string WixRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Dirs.Output, "WixTools");
|
||||
}
|
||||
}
|
||||
|
||||
private static string Msi { get; set; }
|
||||
|
||||
private static string Bundle { get; set; }
|
||||
|
||||
private static string Engine { get; set; }
|
||||
|
||||
private static void AcquireWix(BuildTargetContext c)
|
||||
{
|
||||
if (File.Exists(Path.Combine(WixRoot, "candle.exe")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
c.Info("Extracting WixTools..");
|
||||
ZipFile.ExtractToDirectory($"{WixRoot}\\WixTools.zip", WixRoot);
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult InitMsi(BuildTargetContext c)
|
||||
{
|
||||
Bundle = c.BuildContext.Get<string>("InstallerFile");
|
||||
Msi = Path.ChangeExtension(Bundle, "msi");
|
||||
Engine = Path.Combine(Path.GetDirectoryName(Bundle), ENGINE);
|
||||
AcquireWix(c);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi),
|
||||
nameof(GenerateDotnetMuxerMsi),
|
||||
nameof(GenerateDotnetSharedFxMsi),
|
||||
nameof(GenerateCLISDKMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateMsis(BuildTargetContext c)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"), Dirs.Stage2, Msi, WixRoot)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateCLISDKMsi(BuildTargetContext c)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"), Dirs.Stage2, Msi, WixRoot)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateDotnetMuxerMsi(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateDotnetSharedFxMsi(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateBundle(BuildTargetContext c)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatebundle.ps1"), Msi, Bundle, WixRoot)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c)
|
||||
{
|
||||
Cmd($"{WixRoot}\\insignia.exe", "-ib", Bundle, "-o", Engine)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult ReattachEngineToBundle(BuildTargetContext c)
|
||||
{
|
||||
Cmd($"{WixRoot}\\insignia.exe", "-ab", Engine, Bundle, "-o", Bundle)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
}
|
||||
}
|
138
scripts/dotnet-cli-build/PackageTargets.cs
Normal file
138
scripts/dotnet-cli-build/PackageTargets.cs
Normal file
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public static class PackageTargets
|
||||
{
|
||||
[Target]
|
||||
public static BuildTargetResult InitPackage(BuildTargetContext c)
|
||||
{
|
||||
Directory.CreateDirectory(Dirs.Packages);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init),
|
||||
nameof(PackageTargets.InitPackage),
|
||||
nameof(PackageTargets.GenerateVersionBadge),
|
||||
nameof(PackageTargets.GenerateCompressedFile),
|
||||
nameof(InstallerTargets.GenerateInstaller),
|
||||
nameof(PackageTargets.GenerateNugetPackages))]
|
||||
[Environment("DOTNET_BUILD_SKIP_PACKAGING", null)]
|
||||
public static BuildTargetResult Package(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult GenerateVersionBadge(BuildTargetContext c)
|
||||
{
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var versionSvg = Path.Combine(Dirs.RepoRoot, "resources", "images", "version_badge.svg");
|
||||
var outputVersionSvg = c.BuildContext.Get<string>("VersionBadge");
|
||||
|
||||
var versionSvgContent = File.ReadAllText(versionSvg);
|
||||
versionSvgContent = versionSvgContent.Replace("ver_number", buildVersion.SimpleVersion);
|
||||
File.WriteAllText(outputVersionSvg, versionSvgContent);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.GenerateZip), nameof(PackageTargets.GenerateTarBall))]
|
||||
public static BuildTargetResult GenerateCompressedFile(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.InitPackage))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateZip(BuildTargetContext c)
|
||||
{
|
||||
var zipFile = c.BuildContext.Get<string>("CompressedFile");
|
||||
|
||||
if (File.Exists(zipFile))
|
||||
{
|
||||
File.Delete(zipFile);
|
||||
}
|
||||
|
||||
ZipFile.CreateFromDirectory(Dirs.Stage2, zipFile, CompressionLevel.Optimal, false);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.InitPackage))]
|
||||
[BuildPlatforms(BuildPlatform.Unix)]
|
||||
public static BuildTargetResult GenerateTarBall(BuildTargetContext c)
|
||||
{
|
||||
var tarFile = c.BuildContext.Get<string>("CompressedFile");
|
||||
|
||||
if (File.Exists(tarFile))
|
||||
{
|
||||
File.Delete(tarFile);
|
||||
}
|
||||
|
||||
Cmd("tar", "-czf", tarFile, "-C", Dirs.Stage2, ".")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateNugetPackages(BuildTargetContext c)
|
||||
{
|
||||
var versionSuffix = c.BuildContext.Get<BuildVersion>("BuildVersion").VersionSuffix;
|
||||
var env = GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "nuget", "package.ps1"), Path.Combine(Dirs.Stage2, "bin"), versionSuffix)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string> GetCommonEnvVars(BuildTargetContext c)
|
||||
{
|
||||
// Set up the environment variables previously defined by common.sh/ps1
|
||||
// This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names)
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var architecture = PlatformServices.Default.Runtime.RuntimeArchitecture;
|
||||
var env = new Dictionary<string, string>()
|
||||
{
|
||||
{ "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() },
|
||||
{ "OSNAME", PlatformServices.Default.Runtime.OperatingSystem },
|
||||
{ "TFM", "dnxcore50" },
|
||||
{ "REPOROOT", Dirs.RepoRoot },
|
||||
{ "OutputDir", Dirs.Output },
|
||||
{ "Stage1Dir", Dirs.Stage1 },
|
||||
{ "Stage1CompilationDir", Dirs.Stage1Compilation },
|
||||
{ "Stage2Dir", Dirs.Stage2 },
|
||||
{ "STAGE2_DIR", Dirs.Stage2 },
|
||||
{ "Stage2CompilationDir", Dirs.Stage2Compilation },
|
||||
{ "HostDir", Dirs.Corehost },
|
||||
{ "PackageDir", Path.Combine(Dirs.Packages) }, // Legacy name
|
||||
{ "TestBinRoot", Dirs.TestOutput },
|
||||
{ "TestPackageDir", Dirs.TestPackages },
|
||||
{ "MajorVersion", buildVersion.Major.ToString() },
|
||||
{ "MinorVersion", buildVersion.Minor.ToString() },
|
||||
{ "PatchVersion", buildVersion.Patch.ToString() },
|
||||
{ "CommitCountVersion", buildVersion.CommitCountString },
|
||||
{ "COMMIT_COUNT_VERSION", buildVersion.CommitCountString },
|
||||
{ "DOTNET_CLI_VERSION", buildVersion.SimpleVersion },
|
||||
{ "DOTNET_MSI_VERSION", buildVersion.GenerateMsiVersion() },
|
||||
{ "VersionSuffix", buildVersion.VersionSuffix },
|
||||
{ "CONFIGURATION", configuration },
|
||||
{ "ARCHITECTURE", architecture }
|
||||
};
|
||||
|
||||
return env;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public static BuildTargetResult CheckInstallerBuildPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
|
||||
// All major targets will depend on this in order to ensure variables are set up right if they are run independently
|
||||
[Target(nameof(GenerateVersions), nameof(CheckPrereqs), nameof(LocateStage0))]
|
||||
[Target(nameof(GenerateVersions), nameof(CheckPrereqs), nameof(LocateStage0), nameof(ExpectedBuildArtifacts))]
|
||||
public static BuildTargetResult Init(BuildTargetContext c)
|
||||
{
|
||||
var runtimeInfo = PlatformServices.Default.Runtime;
|
||||
|
@ -104,6 +104,41 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c)
|
||||
{
|
||||
var productName = Monikers.GetProductMoniker(c);
|
||||
var config = Environment.GetEnvironmentVariable("CONFIGURATION");
|
||||
var versionBadgeName = $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}_{config}_version_badge.svg";
|
||||
c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName);
|
||||
|
||||
var extension = CurrentPlatform.IsWindows ? ".zip" : ".tar.gz";
|
||||
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();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CheckPackageCache(BuildTargetContext c)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,10 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.WindowsAzure;
|
||||
using Microsoft.WindowsAzure.Storage;
|
||||
using Microsoft.WindowsAzure.Storage.Auth;
|
||||
using Microsoft.WindowsAzure.Storage.Blob;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
|
@ -11,71 +15,110 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public static class PublishTargets
|
||||
{
|
||||
[Target(nameof(PrepareTargets.Init))]
|
||||
private static CloudBlobContainer BlobContainer { get; set; }
|
||||
|
||||
private static string Channel { get; } = "Test";// Environment.GetEnvironmentVariable("RELEASE_SUFFIX");
|
||||
|
||||
private static string Version { get; set; }
|
||||
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult InitPublish(BuildTargetContext c)
|
||||
{
|
||||
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("CONNECTION_STRING").Trim('"'));
|
||||
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
|
||||
BlobContainer = blobClient.GetContainerReference("dotnet");
|
||||
|
||||
Version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init),
|
||||
nameof(PublishTargets.InitPublish),
|
||||
nameof(PublishTargets.PublishArtifacts))]
|
||||
[Environment("PUBLISH_TO_AZURE_BLOB", "true")] // This is set by CI systems
|
||||
public static BuildTargetResult Publish(BuildTargetContext c)
|
||||
{
|
||||
if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_BUILD_SKIP_PACKAGING"), "1", StringComparison.Ordinal))
|
||||
{
|
||||
c.Info("Skipping packaging because DOTNET_BUILD_SKIP_PACKAGING is set");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
// NOTE(anurse): Currently, this just invokes the remaining build scripts as-is. We should port those to C# as well, but
|
||||
// I want to get the merged in.
|
||||
|
||||
// Set up the environment variables previously defined by common.sh/ps1
|
||||
// This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names)
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
var architecture = PlatformServices.Default.Runtime.RuntimeArchitecture;
|
||||
var env = new Dictionary<string, string>()
|
||||
{
|
||||
{ "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() },
|
||||
{ "OSNAME", PlatformServices.Default.Runtime.OperatingSystem },
|
||||
{ "TFM", "netstandardapp1.5" },
|
||||
{ "OutputDir", Dirs.Output },
|
||||
{ "Stage1Dir", Dirs.Stage1 },
|
||||
{ "Stage1CompilationDir", Dirs.Stage1Compilation },
|
||||
{ "Stage2Dir", Dirs.Stage2 },
|
||||
{ "STAGE2_DIR", Dirs.Stage2 },
|
||||
{ "Stage2CompilationDir", Dirs.Stage2Compilation },
|
||||
{ "HostDir", Dirs.Corehost },
|
||||
{ "PackageDir", Path.Combine(Dirs.Packages, "dnvm") }, // Legacy name
|
||||
{ "TestBinRoot", Dirs.TestOutput },
|
||||
{ "TestPackageDir", Dirs.TestPackages },
|
||||
{ "MajorVersion", buildVersion.Major.ToString() },
|
||||
{ "MinorVersion", buildVersion.Minor.ToString() },
|
||||
{ "PatchVersion", buildVersion.Patch.ToString() },
|
||||
{ "CommitCountVersion", buildVersion.CommitCountString },
|
||||
{ "COMMIT_COUNT_VERSION", buildVersion.CommitCountString },
|
||||
{ "DOTNET_CLI_VERSION", buildVersion.SimpleVersion },
|
||||
{ "DOTNET_MSI_VERSION", buildVersion.GenerateMsiVersion() },
|
||||
{ "VersionSuffix", buildVersion.VersionSuffix },
|
||||
{ "CONFIGURATION", configuration },
|
||||
{ "ARCHITECTURE", architecture }
|
||||
};
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
env["OSNAME"] = "osx";
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo", Path.Combine(c.BuildContext.BuildDirectory, "scripts", "package", "package.ps1"))
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can directly execute scripts on Unix :). Thank you shebangs!
|
||||
Cmd(Path.Combine(c.BuildContext.BuildDirectory, "scripts", "package", "package.sh"))
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PublishTargets.PublishVersionBadge),
|
||||
nameof(PublishTargets.PublishCompressedFile),
|
||||
nameof(PublishTargets.PublishInstallerFile),
|
||||
nameof(PublishTargets.PublishLatestVersionTextFile))]
|
||||
public static BuildTargetResult PublishArtifacts(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishVersionBadge(BuildTargetContext c)
|
||||
{
|
||||
var versionBadge = c.BuildContext.Get<string>("VersionBadge");
|
||||
var latestVersionBadgeBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(versionBadge)}";
|
||||
var versionBadgeBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(versionBadge)}";
|
||||
|
||||
PublishFileAzure(versionBadgeBlob, versionBadge);
|
||||
PublishFileAzure(latestVersionBadgeBlob, versionBadge);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishCompressedFile(BuildTargetContext c)
|
||||
{
|
||||
var compressedFile = c.BuildContext.Get<string>("CompressedFile");
|
||||
var compressedFileBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(compressedFile)}";
|
||||
var latestCompressedFile = compressedFile.Replace(Version, "latest");
|
||||
var latestCompressedFileBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(latestCompressedFile)}";
|
||||
|
||||
PublishFileAzure(compressedFileBlob, compressedFile);
|
||||
PublishFileAzure(latestCompressedFileBlob, compressedFile);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishInstallerFile(BuildTargetContext c)
|
||||
{
|
||||
var installerFile = c.BuildContext.Get<string>("InstallerFile");
|
||||
var installerFileBlob = $"{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
||||
var latestInstallerFile = installerFile.Replace(Version, "latest");
|
||||
var latestInstallerFileBlob = $"{Channel}/Installers/Latest/{Path.GetFileName(latestInstallerFile)}";
|
||||
|
||||
PublishFileAzure(installerFileBlob, installerFile);
|
||||
PublishFileAzure(latestInstallerFileBlob, installerFile);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishLatestVersionTextFile(BuildTargetContext c)
|
||||
{
|
||||
var osname = Monikers.GetOSShortName();
|
||||
var latestVersionBlob = $"{Channel}/dnvm/latest.{osname}.{CurrentArchitecture.Current}.version";
|
||||
var latestVersionFile = Path.Combine(Dirs.Stage2, ".version");
|
||||
|
||||
PublishFileAzure(latestVersionBlob, latestVersionFile);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static BuildTargetResult PublishFile(BuildTargetContext c, string file)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "scripts", "publish", "publish.ps1"), file)
|
||||
.Environment(env)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static void PublishFileAzure(string blob, string file)
|
||||
{
|
||||
CloudBlockBlob blockBlob = BlobContainer.GetBlockBlobReference(blob);
|
||||
using (var fileStream = File.OpenRead(file))
|
||||
{
|
||||
blockBlob.UploadFromStreamAsync(fileStream).Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public static class Dirs
|
||||
{
|
||||
public static readonly string RepoRoot = Directory.GetCurrentDirectory();
|
||||
public static readonly string Output = Path.Combine(
|
||||
Directory.GetCurrentDirectory(),
|
||||
RepoRoot,
|
||||
"artifacts",
|
||||
PlatformServices.Default.Runtime.GetRuntimeIdentifier());
|
||||
public static readonly string Packages = Path.Combine(Output, "packages");
|
||||
|
|
35
scripts/dotnet-cli-build/Utils/Monikers.cs
Normal file
35
scripts/dotnet-cli-build/Utils/Monikers.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class Monikers
|
||||
{
|
||||
public static string GetProductMoniker(BuildTargetContext c)
|
||||
{
|
||||
string osname = GetOSShortName();
|
||||
var arch = CurrentArchitecture.Current.ToString();
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
return $"dotnet-{osname}-{arch}.{version}";
|
||||
}
|
||||
|
||||
public static string GetOSShortName()
|
||||
{
|
||||
string osname = "";
|
||||
switch (CurrentPlatform.Current)
|
||||
{
|
||||
case BuildPlatform.Windows:
|
||||
osname = "win";
|
||||
break;
|
||||
default:
|
||||
osname = CurrentPlatform.Current.ToString().ToLower();
|
||||
break;
|
||||
}
|
||||
|
||||
return osname;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,12 +9,13 @@
|
|||
"NETStandard.Library": "1.0.0-rc2-23901",
|
||||
"System.IO.Compression.ZipFile": "4.0.1-rc2-23901",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537",
|
||||
"Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*"
|
||||
"Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*",
|
||||
"WindowsAzure.Storage" : "6.2.2-preview"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netstandardapp1.5": {
|
||||
"imports": "dnxcore50"
|
||||
"imports": ["dnxcore50", "portable-net45+win8"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,3 @@ execute_build
|
|||
DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb")
|
||||
|
||||
execute_test
|
||||
|
||||
# Publish
|
||||
$REPOROOT/scripts/publish/publish.sh $DEBIAN_FILE
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
if [ ! -d "$STAGE2_DIR" ]; then
|
||||
error "missing stage2 output in $STAGE2_DIR" 1>&2
|
||||
exit
|
||||
fi
|
||||
|
||||
PACKAGE_DIR=$REPOROOT/artifacts/packages/dnvm
|
||||
[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR
|
||||
|
||||
PACKAGE_SHORT_NAME=dotnet-${OSNAME}-x64.${DOTNET_CLI_VERSION}
|
||||
PACKAGE_NAME=$PACKAGE_DIR/${PACKAGE_SHORT_NAME}.tar.gz
|
||||
|
||||
cd $STAGE2_DIR
|
||||
|
||||
header "Packaging $PACKAGE_SHORT_NAME"
|
||||
|
||||
# Tar up the stage2 artifacts
|
||||
# We need both "*" and ".version" to ensure we pick up that file
|
||||
tar -czf $PACKAGE_NAME * .version
|
||||
|
||||
info "Packaged stage2 from '$STAGE2_DIR' to '$PACKAGE_NAME'"
|
||||
|
||||
$REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
if [[ "$OSNAME" == "ubuntu" ]]; then
|
||||
# Create Debian package
|
||||
$REPOROOT/scripts/package/package-debian.sh
|
||||
elif [[ "$OSNAME" == "osx" ]]; then
|
||||
# Create OSX PKG
|
||||
$REPOROOT/packaging/osx/package-osx.sh
|
||||
fi
|
|
@ -1,44 +0,0 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
if(!(Test-Path $PackageDir)) {
|
||||
mkdir $PackageDir | Out-Null
|
||||
}
|
||||
|
||||
if(![string]::IsNullOrEmpty($env:DOTNET_CLI_VERSION)) {
|
||||
$PackageVersion = $env:DOTNET_CLI_VERSION
|
||||
} else {
|
||||
$Timestamp = [DateTime]::Now.ToString("yyyyMMddHHmmss")
|
||||
$PackageVersion = "0.0.1-dev-t$Timestamp"
|
||||
}
|
||||
|
||||
# Stamp the output with the commit metadata and version number
|
||||
$Commit = git rev-parse HEAD
|
||||
|
||||
$VersionContent = @"
|
||||
$Commit
|
||||
$PackageVersion
|
||||
"@
|
||||
|
||||
$VersionContent | Out-File -Encoding UTF8 "$Stage2Dir\.version"
|
||||
|
||||
$PackageName = Join-Path $PackageDir "dotnet-win-$env:ARCHITECTURE.$PackageVersion.zip"
|
||||
|
||||
if (Test-Path $PackageName)
|
||||
{
|
||||
del $PackageName
|
||||
}
|
||||
|
||||
Add-Type -Assembly System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($Stage2Dir, $PackageName, "Optimal", $false)
|
||||
|
||||
Write-Host "Packaged stage2 to $PackageName"
|
||||
|
||||
$PublishScript = Join-Path $PSScriptRoot "..\publish\publish.ps1"
|
||||
& $PublishScript -file $PackageName
|
||||
|
||||
exit $LastExitCode
|
|
@ -1,6 +0,0 @@
|
|||
@echo off
|
||||
|
||||
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
powershell -NoProfile -NoLogo -Command "%~dp0package.ps1 %*; exit $LastExitCode;"
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
||||
|
||||
header "Generating zip package"
|
||||
_ "$RepoRoot\scripts\package\package-zip.ps1"
|
||||
|
||||
header "Generating dotnet MSI"
|
||||
_ "$RepoRoot\packaging\windows\generatemsi.ps1" @("$Stage2Dir")
|
||||
|
||||
header "Generating NuGet packages"
|
||||
_ "$RepoRoot\packaging\nuget\package.ps1" @("$Stage2Dir\bin", "$env:VersionSuffix")
|
||||
|
||||
header "Generating version badge"
|
||||
$VersionBadge = "$RepoRoot\resources\images\version_badge.svg"
|
||||
$BadgeDestination = "$RepoRoot\artifacts\version_badge.svg"
|
||||
(get-content $VersionBadge).replace("ver_number", "$env:DOTNET_CLI_VERSION") | set-content $BadgeDestination
|
||||
|
||||
& "$RepoRoot\scripts\publish\publish.ps1" -file $BadgeDestination
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
export REPOROOT="$(cd -P "$DIR/../.." && pwd)"
|
||||
|
||||
set -e
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
if [ -z "$DOTNET_CLI_VERSION" ]; then
|
||||
TIMESTAMP=$(date "+%Y%m%d%H%M%S")
|
||||
DOTNET_CLI_VERSION=0.0.1-dev-t$TIMESTAMP
|
||||
fi
|
||||
|
||||
VERSION_BADGE="$REPOROOT/resources/images/version_badge.svg"
|
||||
BADGE_DESTINATION="$REPOROOT/artifacts/version_badge.svg"
|
||||
|
||||
header "Generating tarball"
|
||||
$DIR/package-dnvm.sh
|
||||
|
||||
header "Generating Native Installer"
|
||||
$DIR/package-native.sh
|
||||
|
||||
header "Generating version badge"
|
||||
sed "s/ver_number/$DOTNET_CLI_VERSION/g" $VERSION_BADGE > $BADGE_DESTINATION
|
||||
|
||||
header "Publishing version badge"
|
||||
$DIR/../publish/publish.sh $BADGE_DESTINATION
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$file
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
function CheckRequiredVariables
|
||||
{
|
||||
if([string]::IsNullOrEmpty($env:DOTNET_CLI_VERSION))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:SASTOKEN))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:STORAGE_ACCOUNT))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:STORAGE_CONTAINER))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:CHANNEL))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
# this variable is set by the CI system
|
||||
if([string]::IsNullOrEmpty($env:CONNECTION_STRING))
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
function UploadFile($Blob, $Uploadfile, $PreventCaching = $false)
|
||||
{
|
||||
Write-Host "Uploading $Uploadfile to dotnet feed."
|
||||
|
||||
if([string]::IsNullOrEmpty($env:HOME))
|
||||
{
|
||||
$env:HOME=Get-Location
|
||||
}
|
||||
|
||||
$properties = ""
|
||||
|
||||
if($PreventCaching)
|
||||
{
|
||||
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
||||
azure storage blob upload --quiet --properties cacheControl=no-cache --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
||||
}
|
||||
else
|
||||
{
|
||||
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
||||
azure storage blob upload --quiet $properties --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
||||
}
|
||||
|
||||
|
||||
if($?)
|
||||
{
|
||||
Write-Host "Successfully uploaded $Uploadfile to dotnet feed."
|
||||
return $true
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Failed to upload $Uploadfile to dotnet feed."
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function UploadBinaries($zipFile)
|
||||
{
|
||||
$result = -1
|
||||
$fileName = [System.IO.Path]::GetFileName($zipFile)
|
||||
$zipBlob = "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName"
|
||||
|
||||
if(-Not (UploadFile $zipBlob $zipFile))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
Write-Host "Updating the latest dotnet binaries for windows.."
|
||||
$zipBlobLatest = "$env:CHANNEL/Binaries/Latest/dotnet-win-$env:ARCHITECTURE.latest.zip"
|
||||
|
||||
if(-Not (UploadFile $zipBlobLatest $zipFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
# update the version file
|
||||
$versionFile = Convert-Path $PSScriptRoot\..\..\artifacts\$env:RID\stage2\.version
|
||||
$versionBlob = "$env:CHANNEL/dnvm/latest.win.$env:ARCHITECTURE.version"
|
||||
|
||||
if(-Not (UploadFile $versionBlob $versionFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function UploadInstallers($installerFile)
|
||||
{
|
||||
$fileName = [System.IO.Path]::GetFileName($installerFile)
|
||||
$installerBlob = "$env:CHANNEL/Installers/$env:DOTNET_CLI_VERSION/$fileName"
|
||||
|
||||
if(-Not (UploadFile $installerBlob $installerFile))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
Write-Host "Updating the latest dotnet installer for windows.."
|
||||
$installerBlobLatest = "$env:CHANNEL/Installers/Latest/dotnet-win-$env:ARCHITECTURE.latest.exe"
|
||||
|
||||
if(-Not (UploadFile $installerBlobLatest $installerFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function UploadVersionBadge($badgeFile)
|
||||
{
|
||||
$fileName = "windows_$($env:CONFIGURATION)_$([System.IO.Path]::GetFileName($badgeFile))"
|
||||
|
||||
Write-Host "Uploading the version badge to Latest"
|
||||
if(-Not (UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile $true))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION"
|
||||
if(-Not (UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile))
|
||||
{
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if(!(CheckRequiredVariables))
|
||||
{
|
||||
# fail silently if the required variables are not available for publishing the file
|
||||
exit 0
|
||||
}
|
||||
|
||||
if(![System.IO.File]::Exists($file))
|
||||
{
|
||||
throw "$file not found"
|
||||
}
|
||||
|
||||
$result = $false
|
||||
|
||||
if([System.IO.Path]::GetExtension($file).ToLower() -eq ".zip")
|
||||
{
|
||||
$result = UploadBinaries $file
|
||||
}
|
||||
elseif([System.IO.Path]::GetExtension($file).ToLower() -eq ".exe")
|
||||
{
|
||||
$result = UploadInstallers $file
|
||||
}
|
||||
elseif ([System.IO.Path]::GetExtension($file).ToLower() -eq ".svg")
|
||||
{
|
||||
$result = UploadVersionBadge $file
|
||||
}
|
||||
|
||||
exit $result
|
Loading…
Add table
Reference in a new issue