Address some PR feedback.

- Make the MSI scripts to use parameters instead of environment variables.
This commit is contained in:
Sridhar Periyasamy 2016-03-07 14:52:41 -08:00
parent 0f679e68bf
commit ae041c8f61
8 changed files with 58 additions and 44 deletions

View file

@ -4,7 +4,11 @@
param( param(
[Parameter(Mandatory=$true)][string]$DotnetMSIFile, [Parameter(Mandatory=$true)][string]$DotnetMSIFile,
[Parameter(Mandatory=$true)][string]$DotnetBundleOutput, [Parameter(Mandatory=$true)][string]$DotnetBundleOutput,
[Parameter(Mandatory=$true)][string]$WixRoot [Parameter(Mandatory=$true)][string]$WixRoot,
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion,
[Parameter(Mandatory=$true)][string]$DotnetCLIVersion,
[Parameter(Mandatory=$true)][string]$Architecture,
[Parameter(Mandatory=$true)][string]$ReleaseSuffix
) )
. "$PSScriptRoot\..\..\scripts\common\_common.ps1" . "$PSScriptRoot\..\..\scripts\common\_common.ps1"
@ -21,11 +25,11 @@ function RunCandleForBundle
.\candle.exe -nologo ` .\candle.exe -nologo `
-dDotnetSrc="$inputDir" ` -dDotnetSrc="$inputDir" `
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" ` -dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
-dBuildVersion="$env:DOTNET_MSI_VERSION" ` -dBuildVersion="$DotnetMSIVersion" `
-dDisplayVersion="$env:DOTNET_CLI_VERSION" ` -dDisplayVersion="$DotnetCLIVersion" `
-dReleaseSuffix="$env:ReleaseSuffix" ` -dReleaseSuffix="$ReleaseSuffix" `
-dMsiSourcePath="$DotnetMSIFile" ` -dMsiSourcePath="$DotnetMSIFile" `
-arch "$env:ARCHITECTURE" ` -arch "$Architecture" `
-ext WixBalExtension.dll ` -ext WixBalExtension.dll `
-ext WixUtilExtension.dll ` -ext WixUtilExtension.dll `
-ext WixTagExtension.dll ` -ext WixTagExtension.dll `

View file

@ -4,7 +4,11 @@
param( param(
[Parameter(Mandatory=$true)][string]$inputDir, [Parameter(Mandatory=$true)][string]$inputDir,
[Parameter(Mandatory=$true)][string]$DotnetMSIOutput, [Parameter(Mandatory=$true)][string]$DotnetMSIOutput,
[Parameter(Mandatory=$true)][string]$WixRoot [Parameter(Mandatory=$true)][string]$WixRoot,
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion,
[Parameter(Mandatory=$true)][string]$DotnetCLIVersion,
[Parameter(Mandatory=$true)][string]$Architecture,
[Parameter(Mandatory=$true)][string]$ReleaseSuffix
) )
. "$PSScriptRoot\..\..\scripts\common\_common.ps1" . "$PSScriptRoot\..\..\scripts\common\_common.ps1"
@ -43,10 +47,10 @@ function RunCandle
.\candle.exe -nologo ` .\candle.exe -nologo `
-dDotnetSrc="$inputDir" ` -dDotnetSrc="$inputDir" `
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" ` -dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
-dBuildVersion="$env:DOTNET_MSI_VERSION" ` -dBuildVersion="$DotnetMSIVersion" `
-dDisplayVersion="$env:DOTNET_CLI_VERSION" ` -dDisplayVersion="$DotnetCLIVersion" `
-dReleaseSuffix="$env:ReleaseSuffix" ` -dReleaseSuffix="$ReleaseSuffix" `
-arch "$env:ARCHITECTURE" ` -arch "$Architecture" `
-ext WixDependencyExtension.dll ` -ext WixDependencyExtension.dll `
"$AuthWsxRoot\dotnet.wxs" ` "$AuthWsxRoot\dotnet.wxs" `
"$AuthWsxRoot\provider.wxs" ` "$AuthWsxRoot\provider.wxs" `
@ -101,11 +105,6 @@ if(!(Test-Path $inputDir))
throw "$inputDir not found" throw "$inputDir not found"
} }
if(!(Test-Path $PackageDir))
{
mkdir $PackageDir | Out-Null
}
Write-Host "Creating dotnet MSI at $DotnetMSIOutput" Write-Host "Creating dotnet MSI at $DotnetMSIOutput"
if([string]::IsNullOrEmpty($WixRoot)) if([string]::IsNullOrEmpty($WixRoot))

View file

@ -7,9 +7,9 @@ namespace Microsoft.DotNet.Cli.Build.Framework
public class EnvironmentAttribute : TargetConditionAttribute public class EnvironmentAttribute : TargetConditionAttribute
{ {
private string _envVar; private string _envVar;
private string _expectedVal; private string[] _expectedVals;
public EnvironmentAttribute(string envVar, string expectedVal) public EnvironmentAttribute(string envVar, params string[] expectedVals)
{ {
if (string.IsNullOrEmpty(envVar)) if (string.IsNullOrEmpty(envVar))
{ {
@ -17,21 +17,22 @@ namespace Microsoft.DotNet.Cli.Build.Framework
} }
_envVar = envVar; _envVar = envVar;
_expectedVal = expectedVal; _expectedVals = expectedVals;
} }
public override bool EvaluateCondition() public override bool EvaluateCondition()
{ {
var actualVal = Environment.GetEnvironmentVariable(_envVar); var actualVal = Environment.GetEnvironmentVariable(_envVar);
if (string.IsNullOrEmpty(_expectedVal)) foreach (var expectedVal in _expectedVals)
{ {
return string.IsNullOrEmpty(actualVal) || if (string.Equals(actualVal, expectedVal, StringComparison.Ordinal))
actualVal.Equals("0") || {
actualVal.ToLower().Equals("false"); return true;
}
} }
return _expectedVal.Equals(actualVal, StringComparison.Ordinal); return false;
} }
} }
} }

View file

@ -28,6 +28,14 @@ namespace Microsoft.DotNet.Cli.Build
private static string Engine { get; set; } private static string Engine { get; set; }
private static string MsiVersion { get; set; }
private static string CliVersion { get; set; }
private static string Arch { get; } = CurrentArchitecture.Current.ToString();
private static string Channel { get; set; }
private static void AcquireWix(BuildTargetContext c) private static void AcquireWix(BuildTargetContext c)
{ {
if (File.Exists(Path.Combine(WixRoot, "candle.exe"))) if (File.Exists(Path.Combine(WixRoot, "candle.exe")))
@ -55,6 +63,12 @@ namespace Microsoft.DotNet.Cli.Build
Bundle = c.BuildContext.Get<string>("InstallerFile"); Bundle = c.BuildContext.Get<string>("InstallerFile");
Msi = Path.ChangeExtension(Bundle, "msi"); Msi = Path.ChangeExtension(Bundle, "msi");
Engine = Path.Combine(Path.GetDirectoryName(Bundle), ENGINE); Engine = Path.Combine(Path.GetDirectoryName(Bundle), ENGINE);
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
MsiVersion = buildVersion.GenerateMsiVersion();
CliVersion = buildVersion.SimpleVersion;
Channel = c.BuildContext.Get<string>("Channel");
AcquireWix(c); AcquireWix(c);
return c.Success(); return c.Success();
} }
@ -66,12 +80,6 @@ namespace Microsoft.DotNet.Cli.Build
[BuildPlatforms(BuildPlatform.Windows)] [BuildPlatforms(BuildPlatform.Windows)]
public static BuildTargetResult GenerateMsis(BuildTargetContext c) 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(); return c.Success();
} }
@ -79,10 +87,9 @@ namespace Microsoft.DotNet.Cli.Build
[BuildPlatforms(BuildPlatform.Windows)] [BuildPlatforms(BuildPlatform.Windows)]
public static BuildTargetResult GenerateCLISDKMsi(BuildTargetContext c) public static BuildTargetResult GenerateCLISDKMsi(BuildTargetContext c)
{ {
var env = PackageTargets.GetCommonEnvVars(c);
Cmd("powershell", "-NoProfile", "-NoLogo", Cmd("powershell", "-NoProfile", "-NoLogo",
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"), Dirs.Stage2, Msi, WixRoot) Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatemsi.ps1"),
.Environment(env) Dirs.Stage2, Msi, WixRoot, MsiVersion, CliVersion, Arch, Channel)
.Execute() .Execute()
.EnsureSuccessful(); .EnsureSuccessful();
return c.Success(); return c.Success();
@ -107,10 +114,10 @@ namespace Microsoft.DotNet.Cli.Build
[BuildPlatforms(BuildPlatform.Windows)] [BuildPlatforms(BuildPlatform.Windows)]
public static BuildTargetResult GenerateBundle(BuildTargetContext c) public static BuildTargetResult GenerateBundle(BuildTargetContext c)
{ {
var env = PackageTargets.GetCommonEnvVars(c);
Cmd("powershell", "-NoProfile", "-NoLogo", Cmd("powershell", "-NoProfile", "-NoLogo",
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatebundle.ps1"), Msi, Bundle, WixRoot) Path.Combine(Dirs.RepoRoot, "packaging", "windows", "generatebundle.ps1"),
.Environment(env) Msi, Bundle, WixRoot, MsiVersion, CliVersion, Arch, Channel)
.EnvironmentVariable("Stage2Dir", Dirs.Stage2)
.Execute() .Execute()
.EnsureSuccessful(); .EnsureSuccessful();
return c.Success(); return c.Success();

View file

@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Cli.Build
nameof(PackageTargets.GenerateCompressedFile), nameof(PackageTargets.GenerateCompressedFile),
nameof(InstallerTargets.GenerateInstaller), nameof(InstallerTargets.GenerateInstaller),
nameof(PackageTargets.GenerateNugetPackages))] nameof(PackageTargets.GenerateNugetPackages))]
[Environment("DOTNET_BUILD_SKIP_PACKAGING", null)] [Environment("DOTNET_BUILD_SKIP_PACKAGING", null, "0", "false")]
public static BuildTargetResult Package(BuildTargetContext c) public static BuildTargetResult Package(BuildTargetContext c)
{ {
return c.Success(); return c.Success();

View file

@ -44,6 +44,7 @@ namespace Microsoft.DotNet.Cli.Build
} }
c.BuildContext["Configuration"] = configEnv; c.BuildContext["Configuration"] = configEnv;
c.BuildContext["Channel"] = Environment.GetEnvironmentVariable("CHANNEL");
c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}"); c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}");
c.Info("Build Environment:"); c.Info("Build Environment:");

View file

@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Cli.Build
{ {
private static CloudBlobContainer BlobContainer { get; set; } private static CloudBlobContainer BlobContainer { get; set; }
private static string Channel { get; } = "Test";// Environment.GetEnvironmentVariable("RELEASE_SUFFIX"); private static string Channel { get; set; }
private static string Version { get; set; } private static string Version { get; set; }
@ -30,13 +30,14 @@ namespace Microsoft.DotNet.Cli.Build
BlobContainer = blobClient.GetContainerReference("dotnet"); BlobContainer = blobClient.GetContainerReference("dotnet");
Version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion; Version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
Channel = c.BuildContext.Get<string>("Channel");
return c.Success(); return c.Success();
} }
[Target(nameof(PrepareTargets.Init), [Target(nameof(PrepareTargets.Init),
nameof(PublishTargets.InitPublish), nameof(PublishTargets.InitPublish),
nameof(PublishTargets.PublishArtifacts))] nameof(PublishTargets.PublishArtifacts))]
[Environment("PUBLISH_TO_AZURE_BLOB", "true")] // This is set by CI systems [Environment("PUBLISH_TO_AZURE_BLOB", "1", "true")] // This is set by CI systems
public static BuildTargetResult Publish(BuildTargetContext c) public static BuildTargetResult Publish(BuildTargetContext c)
{ {
return c.Success(); return c.Success();

View file

@ -82,7 +82,8 @@ done < "$DIR/../branchinfo.txt"
[ -d $DOTNET_INSTALL_DIR ] || mkdir -p $DOTNET_INSTALL_DIR [ -d $DOTNET_INSTALL_DIR ] || mkdir -p $DOTNET_INSTALL_DIR
# Ensure the latest stage0 is installed # Ensure the latest stage0 is installed
$DIR/obtain/install.sh --channel $RELEASE_SUFFIX export CHANNEL=$RELEASE_SUFFIX
$DIR/obtain/install.sh --channel $CHANNEL
# Put stage 0 on the PATH (for this shell only) # Put stage 0 on the PATH (for this shell only)
PATH="$DOTNET_INSTALL_DIR/bin:$PATH" PATH="$DOTNET_INSTALL_DIR/bin:$PATH"