From 29bc612565e6c06f608a0113f8ff05de7ae7b6ff Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 8 Mar 2016 13:39:41 -0800 Subject: [PATCH 01/15] 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). --- scripts/dotnet-cli-build/InstallerTargets.cs | 4 +- scripts/dotnet-cli-build/MsiTargets.cs | 22 ++++---- scripts/dotnet-cli-build/PackageTargets.cs | 4 +- scripts/dotnet-cli-build/PrepareTargets.cs | 55 +++++++++++--------- scripts/dotnet-cli-build/PublishTargets.cs | 12 ++--- scripts/dotnet-cli-build/Utils/Monikers.cs | 4 +- 6 files changed, 54 insertions(+), 47 deletions(-) diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/scripts/dotnet-cli-build/InstallerTargets.cs index be1a4836a..b11039d7e 100644 --- a/scripts/dotnet-cli-build/InstallerTargets.cs +++ b/scripts/dotnet-cli-build/InstallerTargets.cs @@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Cli.Build public static BuildTargetResult GeneratePkg(BuildTargetContext c) { var version = c.BuildContext.Get("BuildVersion").SimpleVersion; - var pkg = c.BuildContext.Get("InstallerFile"); + var pkg = c.BuildContext.Get("SdkInstallerFile"); Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"), "-v", version, "-i", Dirs.Stage2, "-o", pkg) .Execute() @@ -43,7 +43,7 @@ namespace Microsoft.DotNet.Cli.Build var channel = c.BuildContext.Get("Channel").ToLower(); var packageName = Monikers.GetDebianPackageName(c); var version = c.BuildContext.Get("BuildVersion").SimpleVersion; - var debFile = c.BuildContext.Get("InstallerFile"); + var debFile = c.BuildContext.Get("SdkInstallerFile"); 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"; diff --git a/scripts/dotnet-cli-build/MsiTargets.cs b/scripts/dotnet-cli-build/MsiTargets.cs index 6d83a8794..daf76a449 100644 --- a/scripts/dotnet-cli-build/MsiTargets.cs +++ b/scripts/dotnet-cli-build/MsiTargets.cs @@ -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; } @@ -60,9 +60,9 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult InitMsi(BuildTargetContext c) { - Bundle = c.BuildContext.Get("InstallerFile"); - Msi = Path.ChangeExtension(Bundle, "msi"); - Engine = Path.Combine(Path.GetDirectoryName(Bundle), ENGINE); + SdkBundle = c.BuildContext.Get("SdkInstallerFile"); + SdkMsi = Path.ChangeExtension(SdkBundle, "msi"); + Engine = Path.Combine(Path.GetDirectoryName(SdkBundle), ENGINE); var buildVersion = c.BuildContext.Get("BuildVersion"); MsiVersion = buildVersion.GenerateMsiVersion(); @@ -76,7 +76,7 @@ namespace Microsoft.DotNet.Cli.Build [Target(nameof(MsiTargets.InitMsi), nameof(GenerateDotnetMuxerMsi), nameof(GenerateDotnetSharedFxMsi), - nameof(GenerateCLISDKMsi))] + nameof(GenerateCliSdkMsi))] [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult GenerateMsis(BuildTargetContext c) { @@ -85,11 +85,11 @@ namespace Microsoft.DotNet.Cli.Build [Target] [BuildPlatforms(BuildPlatform.Windows)] - public static BuildTargetResult GenerateCLISDKMsi(BuildTargetContext c) + public static BuildTargetResult GenerateCliSdkMsi(BuildTargetContext c) { Cmd("powershell", "-NoProfile", "-NoLogo", 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() .EnsureSuccessful(); return c.Success(); @@ -116,7 +116,7 @@ namespace Microsoft.DotNet.Cli.Build { Cmd("powershell", "-NoProfile", "-NoLogo", 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) .Execute() .EnsureSuccessful(); @@ -127,7 +127,7 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c) { - Cmd($"{WixRoot}\\insignia.exe", "-ib", Bundle, "-o", Engine) + Cmd($"{WixRoot}\\insignia.exe", "-ib", SdkBundle, "-o", Engine) .Execute() .EnsureSuccessful(); return c.Success(); @@ -137,7 +137,7 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Windows)] 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() .EnsureSuccessful(); return c.Success(); diff --git a/scripts/dotnet-cli-build/PackageTargets.cs b/scripts/dotnet-cli-build/PackageTargets.cs index c43b201e1..af31bf688 100644 --- a/scripts/dotnet-cli-build/PackageTargets.cs +++ b/scripts/dotnet-cli-build/PackageTargets.cs @@ -55,7 +55,7 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult GenerateZip(BuildTargetContext c) { - var zipFile = c.BuildContext.Get("CompressedFile"); + var zipFile = c.BuildContext.Get("SdkCompressedFile"); if (File.Exists(zipFile)) { @@ -70,7 +70,7 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Unix)] public static BuildTargetResult GenerateTarBall(BuildTargetContext c) { - var tarFile = c.BuildContext.Get("CompressedFile"); + var tarFile = c.BuildContext.Get("SdkCompressedFile"); if (File.Exists(tarFile)) { diff --git a/scripts/dotnet-cli-build/PrepareTargets.cs b/scripts/dotnet-cli-build/PrepareTargets.cs index 9a11d5b7e..1465d9d44 100644 --- a/scripts/dotnet-cli-build/PrepareTargets.cs +++ b/scripts/dotnet-cli-build/PrepareTargets.cs @@ -108,34 +108,11 @@ namespace Microsoft.DotNet.Cli.Build [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); - } + AddInstallerArtifactToContext(c, "dotnet", "Sdk"); return c.Success(); } @@ -361,5 +338,35 @@ cmake is required to build the native host 'corehost'"; } 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); + } + + } } } diff --git a/scripts/dotnet-cli-build/PublishTargets.cs b/scripts/dotnet-cli-build/PublishTargets.cs index 6a69fcd89..797f8a6a9 100644 --- a/scripts/dotnet-cli-build/PublishTargets.cs +++ b/scripts/dotnet-cli-build/PublishTargets.cs @@ -45,7 +45,7 @@ namespace Microsoft.DotNet.Cli.Build [Target(nameof(PublishTargets.PublishVersionBadge), nameof(PublishTargets.PublishCompressedFile), - nameof(PublishTargets.PublishInstallerFile), + nameof(PublishTargets.PublishSdkInstallerFile), nameof(PublishTargets.PublishLatestVersionTextFile))] public static BuildTargetResult PublishArtifacts(BuildTargetContext c) { @@ -67,7 +67,7 @@ namespace Microsoft.DotNet.Cli.Build [Target] public static BuildTargetResult PublishCompressedFile(BuildTargetContext c) { - var compressedFile = c.BuildContext.Get("CompressedFile"); + var compressedFile = c.BuildContext.Get("SdkCompressedFile"); var compressedFileBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(compressedFile)}"; var latestCompressedFile = compressedFile.Replace(Version, "latest"); var latestCompressedFileBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(latestCompressedFile)}"; @@ -79,9 +79,9 @@ namespace Microsoft.DotNet.Cli.Build [Target] [BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu)] - public static BuildTargetResult PublishInstallerFile(BuildTargetContext c) + public static BuildTargetResult PublishSdkInstallerFile(BuildTargetContext c) { - var installerFile = c.BuildContext.Get("InstallerFile"); + var installerFile = c.BuildContext.Get("SdkInstallerFile"); var installerFileBlob = $"{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}"; var latestInstallerFile = installerFile.Replace(Version, "latest"); var latestInstallerFileBlob = $"{Channel}/Installers/Latest/{Path.GetFileName(latestInstallerFile)}"; @@ -102,12 +102,12 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - [Target(nameof(PublishInstallerFile))] + [Target(nameof(PublishSdkInstallerFile))] [BuildPlatforms(BuildPlatform.Ubuntu)] public static BuildTargetResult PublishDebFileToDebianRepo(BuildTargetContext c) { var packageName = Monikers.GetDebianPackageName(c); - var installerFile = c.BuildContext.Get("InstallerFile"); + var installerFile = c.BuildContext.Get("SdkInstallerFile"); var uploadUrl = $"https://dotnetcli.blob.core.windows.net/dotnet/{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}"; var uploadJson = GenerateUploadJsonFile(packageName, Version, uploadUrl); diff --git a/scripts/dotnet-cli-build/Utils/Monikers.cs b/scripts/dotnet-cli-build/Utils/Monikers.cs index ae8052636..56eac7ee1 100644 --- a/scripts/dotnet-cli-build/Utils/Monikers.cs +++ b/scripts/dotnet-cli-build/Utils/Monikers.cs @@ -8,12 +8,12 @@ namespace Microsoft.DotNet.Cli.Build { public class Monikers { - public static string GetProductMoniker(BuildTargetContext c) + public static string GetProductMoniker(BuildTargetContext c, string artifactPrefix) { string osname = GetOSShortName(); var arch = CurrentArchitecture.Current.ToString(); var version = c.BuildContext.Get("BuildVersion").SimpleVersion; - return $"dotnet-{osname}-{arch}.{version}"; + return $"{artifactPrefix}-{osname}-{arch}.{version}"; } public static string GetDebianPackageName(BuildTargetContext c) From 04d21e6693a221f884294a15ee747498c50f69c6 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 8 Mar 2016 15:22:33 -0800 Subject: [PATCH 02/15] Add Shared Host MSI Authoring Ideally in the project.json for the shared host we would just list the actual package that holds the shared host, instead of all of NetStandard.Library, but doing some leads to compliation errors, since publish wants to include a compile step that has a generated AssemblyAttributes file which references types like System.String. --- packaging/host/windows/generatemsi.ps1 | 109 ++++++++++++++++++ packaging/host/windows/host.wxs | 44 +++++++ packaging/host/windows/provider.wxs | 9 ++ packaging/host/windows/registrykeys.wxs | 28 +++++ packaging/host/windows/variables.wxi | 29 +++++ scripts/dotnet-cli-build/MsiTargets.cs | 25 +++- scripts/dotnet-cli-build/PrepareTargets.cs | 1 + .../SharedFrameworkTargets.cs | 46 ++++++++ src/sharedframework/host/project.json | 11 ++ 9 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 packaging/host/windows/generatemsi.ps1 create mode 100644 packaging/host/windows/host.wxs create mode 100644 packaging/host/windows/provider.wxs create mode 100644 packaging/host/windows/registrykeys.wxs create mode 100644 packaging/host/windows/variables.wxi create mode 100644 scripts/dotnet-cli-build/SharedFrameworkTargets.cs create mode 100644 src/sharedframework/host/project.json diff --git a/packaging/host/windows/generatemsi.ps1 b/packaging/host/windows/generatemsi.ps1 new file mode 100644 index 000000000..124a987e8 --- /dev/null +++ b/packaging/host/windows/generatemsi.ps1 @@ -0,0 +1,109 @@ +# 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]$SharedHostPublishRoot, + [Parameter(Mandatory=$true)][string]$DotnetHostMSIOutput, + [Parameter(Mandatory=$true)][string]$WixRoot, + [Parameter(Mandatory=$true)][string]$DotnetMSIVersion, + [Parameter(Mandatory=$true)][string]$DotnetCLIVersion, + [Parameter(Mandatory=$true)][string]$Architecture, + [Parameter(Mandatory=$true)][string]$WixObjRoot +) + +. "$PSScriptRoot\..\..\..\scripts\common\_common.ps1" +$RepoRoot = Convert-Path "$PSScriptRoot\..\..\.." + +function RunCandle +{ + $result = $true + pushd "$WixRoot" + + Write-Host Running candle.. + $AuthWsxRoot = Join-Path $RepoRoot "packaging\host\windows" + + .\candle.exe -nologo ` + -out "$WixObjRoot\" ` + -ext WixDependencyExtension.dll ` + -dHostSrc="$SharedHostPublishRoot" ` + -dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" ` + -dBuildVersion="$DotnetMSIVersion" ` + -dDisplayVersion="$DotnetCLIVersion" ` + -arch $Architecture ` + "$AuthWsxRoot\host.wxs" ` + "$AuthWsxRoot\provider.wxs" ` + "$AuthWsxRoot\registrykeys.wxs" | Out-Host + + if($LastExitCode -ne 0) + { + $result = $false + Write-Host "Candle failed with exit code $LastExitCode." + } + + popd + return $result +} + +function RunLight +{ + $result = $true + pushd "$WixRoot" + + Write-Host Running light.. + + .\light.exe -nologo ` + -ext WixUIExtension.dll ` + -ext WixDependencyExtension.dll ` + -ext WixUtilExtension.dll ` + -cultures:en-us ` + "$WixObjRoot\host.wixobj" ` + "$WixObjRoot\provider.wixobj" ` + "$WixObjRoot\registrykeys.wixobj" ` + -out $DotnetHostMSIOutput | Out-Host + + if($LastExitCode -ne 0) + { + $result = $false + Write-Host "Light failed with exit code $LastExitCode." + } + + popd + return $result +} + +if(!(Test-Path $SharedHostPublishRoot)) +{ + throw "$SharedHostPublishRoot not found" +} + +if(!(Test-Path $WixObjRoot)) +{ + throw "$WixObjRoot not found" +} + +Write-Host "Creating shared host MSI at $DotnetHostMSIOutput" + +if([string]::IsNullOrEmpty($WixRoot)) +{ + Exit -1 +} + +if(-Not (RunCandle)) +{ + Exit -1 +} + +if(-Not (RunLight)) +{ + Exit -1 +} + +if(!(Test-Path $DotnetHostMSIOutput)) +{ + throw "Unable to create the shared host msi." + Exit -1 +} + +Write-Host -ForegroundColor Green "Successfully created shared host MSI - $DotnetHostMSIOutput" + +exit $LastExitCode \ No newline at end of file diff --git a/packaging/host/windows/host.wxs b/packaging/host/windows/host.wxs new file mode 100644 index 000000000..736beb665 --- /dev/null +++ b/packaging/host/windows/host.wxs @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packaging/host/windows/provider.wxs b/packaging/host/windows/provider.wxs new file mode 100644 index 000000000..be191eb7e --- /dev/null +++ b/packaging/host/windows/provider.wxs @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/packaging/host/windows/registrykeys.wxs b/packaging/host/windows/registrykeys.wxs new file mode 100644 index 000000000..6f5a3cad0 --- /dev/null +++ b/packaging/host/windows/registrykeys.wxs @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packaging/host/windows/variables.wxi b/packaging/host/windows/variables.wxi new file mode 100644 index 000000000..71ea4a1d8 --- /dev/null +++ b/packaging/host/windows/variables.wxi @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/dotnet-cli-build/MsiTargets.cs b/scripts/dotnet-cli-build/MsiTargets.cs index daf76a449..7cbb00ca5 100644 --- a/scripts/dotnet-cli-build/MsiTargets.cs +++ b/scripts/dotnet-cli-build/MsiTargets.cs @@ -26,6 +26,8 @@ namespace Microsoft.DotNet.Cli.Build private static string SdkBundle { get; set; } + private static string SharedHostMsi { get; set; } + private static string Engine { get; set; } private static string MsiVersion { get; set; } @@ -64,6 +66,8 @@ namespace Microsoft.DotNet.Cli.Build SdkMsi = Path.ChangeExtension(SdkBundle, "msi"); Engine = Path.Combine(Path.GetDirectoryName(SdkBundle), ENGINE); + SharedHostMsi = Path.ChangeExtension(c.BuildContext.Get("SharedHostInstallerFile"), "msi"); + var buildVersion = c.BuildContext.Get("BuildVersion"); MsiVersion = buildVersion.GenerateMsiVersion(); CliVersion = buildVersion.SimpleVersion; @@ -74,7 +78,7 @@ namespace Microsoft.DotNet.Cli.Build } [Target(nameof(MsiTargets.InitMsi), - nameof(GenerateDotnetMuxerMsi), + nameof(GenerateDotnetSharedHostMsi), nameof(GenerateDotnetSharedFxMsi), nameof(GenerateCliSdkMsi))] [BuildPlatforms(BuildPlatform.Windows)] @@ -95,10 +99,25 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - [Target] + [Target(nameof(SharedFrameworkTargets.PublishSharedHost))] [BuildPlatforms(BuildPlatform.Windows)] - public static BuildTargetResult GenerateDotnetMuxerMsi(BuildTargetContext c) + public static BuildTargetResult GenerateDotnetSharedHostMsi(BuildTargetContext c) { + var inputDir = c.BuildContext.Get("SharedHostPublishRoot"); + var wixObjRoot = Path.Combine(Dirs.Output, "obj", "wix", "sharedhost"); + + if (Directory.Exists(wixObjRoot)) + { + Directory.Delete(wixObjRoot, true); + } + + Directory.CreateDirectory(wixObjRoot); + + Cmd("powershell", "-NoProfile", "-NoLogo", + Path.Combine(Dirs.RepoRoot, "packaging", "host", "windows", "generatemsi.ps1"), + inputDir, SharedHostMsi, WixRoot, MsiVersion, CliVersion, Arch, wixObjRoot) + .Execute() + .EnsureSuccessful(); return c.Success(); } diff --git a/scripts/dotnet-cli-build/PrepareTargets.cs b/scripts/dotnet-cli-build/PrepareTargets.cs index 1465d9d44..69c957e91 100644 --- a/scripts/dotnet-cli-build/PrepareTargets.cs +++ b/scripts/dotnet-cli-build/PrepareTargets.cs @@ -113,6 +113,7 @@ namespace Microsoft.DotNet.Cli.Build c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName); AddInstallerArtifactToContext(c, "dotnet", "Sdk"); + AddInstallerArtifactToContext(c, "dotnet-host", "SharedHost"); return c.Success(); } diff --git a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs new file mode 100644 index 000000000..412b6ef1f --- /dev/null +++ b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs @@ -0,0 +1,46 @@ +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 SharedFrameworkTargets + { + private const string CoreHostBaseName = "corehost"; + + [Target] + public static BuildTargetResult PublishSharedHost(BuildTargetContext c) + { + string SharedHostPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedhost"); + + if (Directory.Exists(SharedHostPublishRoot)) + { + Directory.Delete(SharedHostPublishRoot, true); + } + + DotNetCli.Stage0.Publish("--output", SharedHostPublishRoot, Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "host")).Execute().EnsureSuccessful(); + + // For the shared host, we only want corerun and not any of the other artifacts in the package (like the hostpolicy) + foreach (var filePath in Directory.GetFiles(SharedHostPublishRoot)) + { + if (Path.GetFileName(filePath) != $"{CoreHostBaseName}{Constants.ExeSuffix}") + { + File.Delete(filePath); + } + } + + // corehost will be renamed to dotnet at some point and then this can be removed. + File.Move(Path.Combine(SharedHostPublishRoot, $"{CoreHostBaseName}{Constants.ExeSuffix}"), Path.Combine(SharedHostPublishRoot, $"dotnet{Constants.ExeSuffix}")); + + c.BuildContext["SharedHostPublishRoot"] = SharedHostPublishRoot; + + return c.Success(); + } + } +} \ No newline at end of file diff --git a/src/sharedframework/host/project.json b/src/sharedframework/host/project.json new file mode 100644 index 000000000..30251684c --- /dev/null +++ b/src/sharedframework/host/project.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "NETStandard.Library": "1.0.0-rc2-23811" + }, + + "frameworks": { + "dnxcore50": { } + } +} \ No newline at end of file From e6bcfee4a4d73437c38bc55b4477afadc1181a31 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 8 Mar 2016 19:32:31 -0800 Subject: [PATCH 03/15] Add SharedFramework MSI Authoring --- .../sharedframework/windows/generatemsi.ps1 | 151 ++++++++++++++++++ .../sharedframework/windows/provider.wxs | 9 ++ .../sharedframework/windows/registrykeys.wxs | 28 ++++ .../windows/sharedframework.wxs | 35 ++++ .../sharedframework/windows/variables.wxi | 31 ++++ scripts/dotnet-cli-build/MsiTargets.cs | 27 +++- scripts/dotnet-cli-build/PrepareTargets.cs | 1 + .../SharedFrameworkTargets.cs | 57 +++++++ scripts/dotnet-cli-build/Utils/Utils.cs | 51 ++++++ scripts/dotnet-cli-build/project.json | 1 + src/sharedframework/framework/Program.cs | 11 ++ src/sharedframework/framework/project.json | 14 ++ 12 files changed, 413 insertions(+), 3 deletions(-) create mode 100644 packaging/sharedframework/windows/generatemsi.ps1 create mode 100644 packaging/sharedframework/windows/provider.wxs create mode 100644 packaging/sharedframework/windows/registrykeys.wxs create mode 100644 packaging/sharedframework/windows/sharedframework.wxs create mode 100644 packaging/sharedframework/windows/variables.wxi create mode 100644 src/sharedframework/framework/Program.cs create mode 100644 src/sharedframework/framework/project.json diff --git a/packaging/sharedframework/windows/generatemsi.ps1 b/packaging/sharedframework/windows/generatemsi.ps1 new file mode 100644 index 000000000..ed78f847d --- /dev/null +++ b/packaging/sharedframework/windows/generatemsi.ps1 @@ -0,0 +1,151 @@ +# 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]$SharedFrameworkPublishRoot, + [Parameter(Mandatory=$true)][string]$SharedFrameworkMSIOutput, + [Parameter(Mandatory=$true)][string]$WixRoot, + [Parameter(Mandatory=$true)][string]$DotnetMSIVersion, + [Parameter(Mandatory=$true)][string]$SharedFrameworkNugetName, + [Parameter(Mandatory=$true)][string]$SharedFrameworkNugetVersion, + [Parameter(Mandatory=$true)][string]$SharedFrameworkUpgradeCode, + [Parameter(Mandatory=$true)][string]$Architecture, + [Parameter(Mandatory=$true)][string]$WixObjRoot +) + +. "$PSScriptRoot\..\..\..\scripts\common\_common.ps1" +$RepoRoot = Convert-Path "$PSScriptRoot\..\..\.." + +$InstallFileswsx = "$WixObjRoot\install-files.wxs" +$InstallFilesWixobj = "$WixObjRoot\install-files.wixobj" + + +function RunHeat +{ + $result = $true + pushd "$WixRoot" + + Write-Host Running heat.. + + .\heat.exe dir `"$SharedFrameworkPublishRoot`" ` + -nologo ` + -template fragment ` + -sreg -gg ` + -var var.SharedFrameworkSource ` + -cg InstallFiles ` + -srd ` + -dr DOTNETHOME ` + -out $InstallFileswsx | Out-Host + + if($LastExitCode -ne 0) + { + $result = $false + Write-Host "Heat failed with exit code $LastExitCode." + } + + popd + return $result +} + +function RunCandle +{ + $result = $true + pushd "$WixRoot" + + Write-Host Running candle.. + $AuthWsxRoot = Join-Path $RepoRoot "packaging\sharedframework\windows" + $SharedFrameworkComponentVersion = $SharedFrameworkNugetVersion.Replace('-', '_'); + + .\candle.exe -nologo ` + -out "$WixObjRoot\" ` + -dSharedFrameworkSource="$SharedFrameworkPublishRoot" ` + -dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" ` + -dFrameworkName="$SharedFrameworkNugetName" ` + -dFrameworkDisplayVersion="$SharedFrameworkNugetVersion" ` + -dFrameworkComponentVersion="$SharedFrameworkComponentVersion" ` + -dFrameworkUpgradeCode="$SharedFrameworkUpgradeCode" ` + -dBuildVersion="$DotnetMSIVersion" ` + -arch $Architecture ` + -ext WixDependencyExtension.dll ` + "$AuthWsxRoot\sharedframework.wxs" ` + "$AuthWsxRoot\provider.wxs" ` + "$AuthWsxRoot\registrykeys.wxs" ` + $InstallFileswsx | Out-Host + + if($LastExitCode -ne 0) + { + $result = $false + Write-Host "Candle failed with exit code $LastExitCode." + } + + popd + return $result +} + +function RunLight +{ + $result = $true + pushd "$WixRoot" + + Write-Host Running light.. + $CabCache = Join-Path $WixRoot "cabcache" + + .\light.exe -nologo -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension ` + -cultures:en-us ` + "$WixObjRoot\sharedframework.wixobj" ` + "$WixObjRoot\provider.wixobj" ` + "$WixObjRoot\registrykeys.wixobj" ` + "$InstallFilesWixobj" ` + -out $SharedFrameworkMSIOutput | Out-Host + + if($LastExitCode -ne 0) + { + $result = $false + Write-Host "Light failed with exit code $LastExitCode." + } + + popd + return $result +} + +if(!(Test-Path $SharedFrameworkPublishRoot)) +{ + throw "$SharedHostPublishRoot not found" +} + +if(!(Test-Path $WixObjRoot)) +{ + throw "$WixObjRoot not found" +} + +Write-Host "Creating dotnet shared framework MSI at $SharedFrameworkMSIOutput" + +if([string]::IsNullOrEmpty($WixRoot)) +{ + Exit -1 +} + +if(-Not (RunHeat)) +{ + Exit -1 +} + +if(-Not (RunCandle)) +{ + Exit -1 +} + +if(-Not (RunLight)) +{ + Exit -1 +} + +if(!(Test-Path $SharedFrameworkMSIOutput)) +{ + throw "Unable to create the dotnet shared framework msi." + Exit -1 +} + +Write-Host -ForegroundColor Green "Successfully created shared framework MSI - $SharedFrameworkMSIOutput" + +exit $LastExitCode diff --git a/packaging/sharedframework/windows/provider.wxs b/packaging/sharedframework/windows/provider.wxs new file mode 100644 index 000000000..665d58c4a --- /dev/null +++ b/packaging/sharedframework/windows/provider.wxs @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/packaging/sharedframework/windows/registrykeys.wxs b/packaging/sharedframework/windows/registrykeys.wxs new file mode 100644 index 000000000..51d322da1 --- /dev/null +++ b/packaging/sharedframework/windows/registrykeys.wxs @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packaging/sharedframework/windows/sharedframework.wxs b/packaging/sharedframework/windows/sharedframework.wxs new file mode 100644 index 000000000..88680f5f2 --- /dev/null +++ b/packaging/sharedframework/windows/sharedframework.wxs @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/sharedframework/windows/variables.wxi b/packaging/sharedframework/windows/variables.wxi new file mode 100644 index 000000000..ad175258f --- /dev/null +++ b/packaging/sharedframework/windows/variables.wxi @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/dotnet-cli-build/MsiTargets.cs b/scripts/dotnet-cli-build/MsiTargets.cs index 7cbb00ca5..12c3f1f6c 100644 --- a/scripts/dotnet-cli-build/MsiTargets.cs +++ b/scripts/dotnet-cli-build/MsiTargets.cs @@ -28,6 +28,8 @@ namespace Microsoft.DotNet.Cli.Build private static string SharedHostMsi { get; set; } + private static string SharedFrameworkMsi { get; set; } + private static string Engine { get; set; } private static string MsiVersion { get; set; } @@ -67,6 +69,7 @@ namespace Microsoft.DotNet.Cli.Build Engine = Path.Combine(Path.GetDirectoryName(SdkBundle), ENGINE); SharedHostMsi = Path.ChangeExtension(c.BuildContext.Get("SharedHostInstallerFile"), "msi"); + SharedFrameworkMsi = Path.ChangeExtension(c.BuildContext.Get("SharedFrameworkInstallerFile"), "msi"); var buildVersion = c.BuildContext.Get("BuildVersion"); MsiVersion = buildVersion.GenerateMsiVersion(); @@ -79,7 +82,7 @@ namespace Microsoft.DotNet.Cli.Build [Target(nameof(MsiTargets.InitMsi), nameof(GenerateDotnetSharedHostMsi), - nameof(GenerateDotnetSharedFxMsi), + nameof(GenerateDotnetSharedFrameworkMsi), nameof(GenerateCliSdkMsi))] [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult GenerateMsis(BuildTargetContext c) @@ -121,10 +124,28 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - [Target] + [Target(nameof(SharedFrameworkTargets.PublishSharedFramework))] [BuildPlatforms(BuildPlatform.Windows)] - public static BuildTargetResult GenerateDotnetSharedFxMsi(BuildTargetContext c) + public static BuildTargetResult GenerateDotnetSharedFrameworkMsi(BuildTargetContext c) { + var inputDir = c.BuildContext.Get("SharedFrameworkPublishRoot"); + var sharedFrameworkNuGetName = SharedFrameworkTargets.SharedFrameworkName; + var sharedFrameworkNuGetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); + var upgradeCode = Utils.GenerateGuidFromName($"{sharedFrameworkNuGetName}-{sharedFrameworkNuGetVersion}-{Arch}").ToString().ToUpper(); + var wixObjRoot = Path.Combine(Dirs.Output, "obj", "wix", "sharedframework"); + + if (Directory.Exists(wixObjRoot)) + { + Directory.Delete(wixObjRoot, true); + } + + Directory.CreateDirectory(wixObjRoot); + + Cmd("powershell", "-NoProfile", "-NoLogo", + Path.Combine(Dirs.RepoRoot, "packaging", "sharedframework", "windows", "generatemsi.ps1"), + inputDir, SharedFrameworkMsi, WixRoot, MsiVersion, sharedFrameworkNuGetName, sharedFrameworkNuGetVersion, upgradeCode, Arch, wixObjRoot) + .Execute() + .EnsureSuccessful(); return c.Success(); } diff --git a/scripts/dotnet-cli-build/PrepareTargets.cs b/scripts/dotnet-cli-build/PrepareTargets.cs index 69c957e91..08dca3e05 100644 --- a/scripts/dotnet-cli-build/PrepareTargets.cs +++ b/scripts/dotnet-cli-build/PrepareTargets.cs @@ -114,6 +114,7 @@ namespace Microsoft.DotNet.Cli.Build AddInstallerArtifactToContext(c, "dotnet", "Sdk"); AddInstallerArtifactToContext(c, "dotnet-host", "SharedHost"); + AddInstallerArtifactToContext(c, "dotnet-sharedframework", "SharedFramework"); return c.Success(); } diff --git a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs index 412b6ef1f..760992734 100644 --- a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs +++ b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; +using System.Text.RegularExpressions; using System.Runtime.InteropServices; using Microsoft.DotNet.Cli.Build.Framework; using Microsoft.Extensions.PlatformAbstractions; @@ -12,8 +13,47 @@ namespace Microsoft.DotNet.Cli.Build { public class SharedFrameworkTargets { + public const string SharedFrameworkName = "NETStandard.Library"; + private const string CoreHostBaseName = "corehost"; + [Target] + public static BuildTargetResult PublishSharedFramework(BuildTargetContext c) + { + string SharedFrameworkPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedframework"); + string SharedFrameworkSourceRoot = Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "framework"); + string SharedFrameworkNugetVersion = GetVersionFromProjectJson(Path.Combine(Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "framework"), "project.json")); + + if (Directory.Exists(SharedFrameworkPublishRoot)) + { + Directory.Delete(SharedFrameworkPublishRoot, true); + } + + // We publish to a sub folder of the PublishRoot so tools like heat and zip can generate folder structures easier. + string SharedFrameworkNameAndVersionRoot = Path.Combine(SharedFrameworkPublishRoot, "shared", SharedFrameworkName, SharedFrameworkNugetVersion); + + DotNetCli.Stage0.Publish("--output", SharedFrameworkNameAndVersionRoot, SharedFrameworkSourceRoot).Execute().EnsureSuccessful(); + + c.BuildContext["SharedFrameworkPublishRoot"] = SharedFrameworkPublishRoot; + c.BuildContext["SharedFrameworkNugetVersion"] = SharedFrameworkNugetVersion; + + // Clean up artifacts that dotnet-publish generates which we don't need + File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, $"framework{Constants.ExeSuffix}")); + File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.dll")); + File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.pdb")); + + // Rename the .deps file + File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.deps"), Path.Combine(SharedFrameworkNameAndVersionRoot, $"{SharedFrameworkName}.deps")); + + // corehost will be renamed to dotnet at some point and then this can be removed. + File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, $"{CoreHostBaseName}{Constants.ExeSuffix}"), Path.Combine(SharedFrameworkNameAndVersionRoot, $"dotnet{Constants.ExeSuffix}")); + + // hostpolicy will be renamed to dotnet at some point and then this can be removed. + File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(SharedFrameworkNameAndVersionRoot, $"{Constants.DynamicLibPrefix}dotnethostimpl{Constants.DynamicLibSuffix}")); + + return c.Success(); + } + [Target] public static BuildTargetResult PublishSharedHost(BuildTargetContext c) { @@ -42,5 +82,22 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } + + private static string GetVersionFromProjectJson(string pathToProjectJson) + { + Regex r = new Regex($"\"{Regex.Escape(SharedFrameworkName)}\"\\s*:\\s*\"(?'version'[^\"]*)\""); + + foreach(var line in File.ReadAllLines(pathToProjectJson)) + { + var m = r.Match(line); + + if (m.Success) + { + return m.Groups["version"].Value; + } + } + + return null; + } } } \ No newline at end of file diff --git a/scripts/dotnet-cli-build/Utils/Utils.cs b/scripts/dotnet-cli-build/Utils/Utils.cs index edbee23d1..21512a08b 100644 --- a/scripts/dotnet-cli-build/Utils/Utils.cs +++ b/scripts/dotnet-cli-build/Utils/Utils.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Runtime.InteropServices; +using System.Security.Cryptography; namespace Microsoft.DotNet.Cli.Build { @@ -34,5 +35,55 @@ namespace Microsoft.DotNet.Cli.Build throw new PlatformNotSupportedException(); } } + + // Generate a Version 5 (SHA1 Name Based) Guid from a name. + public static Guid GenerateGuidFromName(string name) + { + // Any fixed GUID will do for a namespace. + Guid namespaceId = new Guid("28F1468D-672B-489A-8E0C-7C5B3030630C"); + + using (SHA1 hasher = SHA1.Create()) + { + var nameBytes = System.Text.Encoding.UTF8.GetBytes(name ?? string.Empty); + var namespaceBytes = namespaceId.ToByteArray(); + + SwapGuidByteOrder(namespaceBytes); + + var streamToHash = new byte[namespaceBytes.Length + nameBytes.Length]; + + Array.Copy(namespaceBytes, streamToHash, namespaceBytes.Length); + Array.Copy(nameBytes, 0, streamToHash, namespaceBytes.Length, nameBytes.Length); + + var hashResult = hasher.ComputeHash(streamToHash); + + var res = new byte[16]; + + Array.Copy(hashResult, res, res.Length); + + unchecked { res[6] = (byte)(0x50 | (res[6] & 0x0F)); } + unchecked { res[8] = (byte)(0x40 | (res[8] & 0x3F)); } + + SwapGuidByteOrder(res); + + return new Guid(res); + } + } + + // Do a byte order swap, .NET GUIDs store multi byte components in little + // endian. + private static void SwapGuidByteOrder(byte[] b) + { + Swap(b, 0, 3); + Swap(b, 1, 2); + Swap(b, 5, 6); + Swap(b, 7, 8); + } + + private static void Swap(byte[] b, int x, int y) + { + byte t = b[x]; + b[x] = b[y]; + b[y] = t; + } } } diff --git a/scripts/dotnet-cli-build/project.json b/scripts/dotnet-cli-build/project.json index e76a7a1c3..2be69c156 100755 --- a/scripts/dotnet-cli-build/project.json +++ b/scripts/dotnet-cli-build/project.json @@ -8,6 +8,7 @@ "dependencies": { "NETStandard.Library": "1.0.0-rc2-23901", "System.IO.Compression.ZipFile": "4.0.1-rc2-23901", + "System.Security.Cryptography.Algorithms": "4.0.0-rc2-23901", "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537", "Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*", "WindowsAzure.Storage" : "6.2.2-preview" diff --git a/src/sharedframework/framework/Program.cs b/src/sharedframework/framework/Program.cs new file mode 100644 index 000000000..4aa370b90 --- /dev/null +++ b/src/sharedframework/framework/Program.cs @@ -0,0 +1,11 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + } + } +} \ No newline at end of file diff --git a/src/sharedframework/framework/project.json b/src/sharedframework/framework/project.json new file mode 100644 index 000000000..5d904b02f --- /dev/null +++ b/src/sharedframework/framework/project.json @@ -0,0 +1,14 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "emitEntryPoint": true + }, + + "dependencies": { + "NETStandard.Library": "1.0.0-rc2-23811" + }, + + "frameworks": { + "dnxcore50": { } + } +} \ No newline at end of file From 92edb36e5b12bdbc063209b483b9146b5e55ccd5 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 8 Mar 2016 21:52:34 -0800 Subject: [PATCH 04/15] Generate zips for SharedHost and SharedFramework --- scripts/dotnet-cli-build/MsiTargets.cs | 4 ++-- scripts/dotnet-cli-build/PackageTargets.cs | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/dotnet-cli-build/MsiTargets.cs b/scripts/dotnet-cli-build/MsiTargets.cs index 12c3f1f6c..e0e3ecb37 100644 --- a/scripts/dotnet-cli-build/MsiTargets.cs +++ b/scripts/dotnet-cli-build/MsiTargets.cs @@ -102,7 +102,7 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - [Target(nameof(SharedFrameworkTargets.PublishSharedHost))] + [Target] [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult GenerateDotnetSharedHostMsi(BuildTargetContext c) { @@ -124,7 +124,7 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - [Target(nameof(SharedFrameworkTargets.PublishSharedFramework))] + [Target] [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult GenerateDotnetSharedFrameworkMsi(BuildTargetContext c) { diff --git a/scripts/dotnet-cli-build/PackageTargets.cs b/scripts/dotnet-cli-build/PackageTargets.cs index af31bf688..af17fe7b7 100644 --- a/scripts/dotnet-cli-build/PackageTargets.cs +++ b/scripts/dotnet-cli-build/PackageTargets.cs @@ -22,6 +22,8 @@ namespace Microsoft.DotNet.Cli.Build [Target(nameof(PrepareTargets.Init), nameof(PackageTargets.InitPackage), nameof(PackageTargets.GenerateVersionBadge), + nameof(SharedFrameworkTargets.PublishSharedHost), + nameof(SharedFrameworkTargets.PublishSharedFramework), nameof(PackageTargets.GenerateCompressedFile), nameof(InstallerTargets.GenerateInstaller), nameof(PackageTargets.GenerateNugetPackages))] @@ -55,14 +57,10 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Windows)] public static BuildTargetResult GenerateZip(BuildTargetContext c) { - var zipFile = c.BuildContext.Get("SdkCompressedFile"); + CreateZipFromDirectory(c.BuildContext.Get("SharedHostPublishRoot"), c.BuildContext.Get("SharedHostCompressedFile")); + CreateZipFromDirectory(c.BuildContext.Get("SharedFrameworkPublishRoot"), c.BuildContext.Get("SharedFrameworkCompressedFile")); + CreateZipFromDirectory(Dirs.Stage2, c.BuildContext.Get("SdkCompressedFile")); - if (File.Exists(zipFile)) - { - File.Delete(zipFile); - } - - ZipFile.CreateFromDirectory(Dirs.Stage2, zipFile, CompressionLevel.Optimal, false); return c.Success(); } @@ -134,5 +132,15 @@ namespace Microsoft.DotNet.Cli.Build return env; } + + private static void CreateZipFromDirectory(string directory, string artifactPath) + { + if (File.Exists(artifactPath)) + { + File.Delete(artifactPath); + } + + ZipFile.CreateFromDirectory(directory, artifactPath, CompressionLevel.Optimal, false); + } } } From 92e520bf7c9b12b03731bc49ab6052340d660db9 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 8 Mar 2016 22:42:16 -0800 Subject: [PATCH 05/15] Generate tars for SharedHost and SharedFramework --- scripts/dotnet-cli-build/PackageTargets.cs | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/dotnet-cli-build/PackageTargets.cs b/scripts/dotnet-cli-build/PackageTargets.cs index af17fe7b7..11ba01b43 100644 --- a/scripts/dotnet-cli-build/PackageTargets.cs +++ b/scripts/dotnet-cli-build/PackageTargets.cs @@ -68,16 +68,10 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Unix)] public static BuildTargetResult GenerateTarBall(BuildTargetContext c) { - var tarFile = c.BuildContext.Get("SdkCompressedFile"); + CreateTarBallFromDirectory(c.BuildContext.Get("SharedHostPublishRoot"), c.BuildContext.Get("SharedHostCompressedFile")); + CreateTarBallFromDirectory(c.BuildContext.Get("SharedFrameworkPublishRoot"), c.BuildContext.Get("SharedFrameworkCompressedFile")); + CreateTarBallFromDirectory(Dirs.Stage2, c.BuildContext.Get("SdkCompressedFile")); - if (File.Exists(tarFile)) - { - File.Delete(tarFile); - } - - Cmd("tar", "-czf", tarFile, "-C", Dirs.Stage2, ".") - .Execute() - .EnsureSuccessful(); return c.Success(); } @@ -142,5 +136,17 @@ namespace Microsoft.DotNet.Cli.Build ZipFile.CreateFromDirectory(directory, artifactPath, CompressionLevel.Optimal, false); } + + private static void CreateTarBallFromDirectory(string directory, string artifactPath) + { + if (File.Exists(artifactPath)) + { + File.Delete(artifactPath); + } + + Cmd("tar", "-czf", artifactPath, "-C", directory, ".") + .Execute() + .EnsureSuccessful(); + } } } From 7e7995274a7e80731ee3f56c53faf7cb1c829a5a Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 8 Mar 2016 23:23:15 -0800 Subject: [PATCH 06/15] Add stub targets for shared framework and host --- scripts/dotnet-cli-build/InstallerTargets.cs | 55 ++++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/scripts/dotnet-cli-build/InstallerTargets.cs index b11039d7e..fb7f425db 100644 --- a/scripts/dotnet-cli-build/InstallerTargets.cs +++ b/scripts/dotnet-cli-build/InstallerTargets.cs @@ -14,18 +14,25 @@ namespace Microsoft.DotNet.Cli.Build { [Target(nameof(MsiTargets.GenerateMsis), nameof(MsiTargets.GenerateBundle), - nameof(InstallerTargets.GeneratePkg), - nameof(InstallerTargets.GenerateDeb))] + nameof(InstallerTargets.GeneratePkgs), + nameof(InstallerTargets.GenerateDebs))] public static BuildTargetResult GenerateInstaller(BuildTargetContext c) { return c.Success(); } - + [Target(nameof(InstallerTargets.GenerateSdkPkg), + nameof(InstallerTargets.GenerateSharedFrameworkPkg), + nameof(InstallerTargets.GenerateSharedHostPkg))] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GeneratePkgs(BuildTargetContext c) + { + return c.Success(); + } [Target] [BuildPlatforms(BuildPlatform.OSX)] - public static BuildTargetResult GeneratePkg(BuildTargetContext c) + public static BuildTargetResult GenerateSdkPkg(BuildTargetContext c) { var version = c.BuildContext.Get("BuildVersion").SimpleVersion; var pkg = c.BuildContext.Get("SdkInstallerFile"); @@ -37,8 +44,31 @@ namespace Microsoft.DotNet.Cli.Build } [Target] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c) + { + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c) + { + return c.Success(); + } + + [Target(nameof(InstallerTargets.GenerateSdkDeb), + nameof(InstallerTargets.GenerateSharedFrameworkDeb), + nameof(InstallerTargets.GenerateSharedHostDeb))] [BuildPlatforms(BuildPlatform.Ubuntu)] - public static BuildTargetResult GenerateDeb(BuildTargetContext c) + public static BuildTargetResult GenerateDebs(BuildTargetContext c) + { + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.Ubuntu)] + public static BuildTargetResult GenerateSdkDeb(BuildTargetContext c) { var channel = c.BuildContext.Get("Channel").ToLower(); var packageName = Monikers.GetDebianPackageName(c); @@ -53,5 +83,20 @@ namespace Microsoft.DotNet.Cli.Build .EnsureSuccessful(); return c.Success(); } + + [Target] + [BuildPlatforms(BuildPlatform.Ubuntu)] + public static BuildTargetResult GenerateSharedHostDeb(BuildTargetContext c) + { + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.Ubuntu)] + public static BuildTargetResult GenerateSharedFrameworkDeb(BuildTargetContext c) + { + return c.Success(); + } + } } From 5cf35e4f38a4dcb64c26f286cb61e72e689f3817 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 10 Mar 2016 00:21:09 -0800 Subject: [PATCH 07/15] Use explicit object directory for sdk deb pacakge As we add more deb packages, we should keep everything tidy by given each one it's on individual object root. --- scripts/dotnet-cli-build/InstallerTargets.cs | 11 ++++++++++- scripts/package/package-debian.sh | 11 ++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/scripts/dotnet-cli-build/InstallerTargets.cs index fb7f425db..88b36c800 100644 --- a/scripts/dotnet-cli-build/InstallerTargets.cs +++ b/scripts/dotnet-cli-build/InstallerTargets.cs @@ -77,8 +77,17 @@ namespace Microsoft.DotNet.Cli.Build 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 objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sdk"); + + if (Directory.Exists(objRoot)) + { + Directory.Delete(objRoot, true); + } + + Directory.CreateDirectory(objRoot); + Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"), - "-v", version, "-i", Dirs.Stage2, "-o", debFile, "-p", packageName, "-m", manPagesDir, "--previous-version-url", previousVersionURL) + "-v", version, "-i", Dirs.Stage2, "-o", debFile, "-p", packageName, "-m", manPagesDir, "--previous-version-url", previousVersionURL, "--obj-root", objRoot) .Execute() .EnsureSuccessful(); return c.Success(); diff --git a/scripts/package/package-debian.sh b/scripts/package/package-debian.sh index e06748739..1b54bfb02 100755 --- a/scripts/package/package-debian.sh +++ b/scripts/package/package-debian.sh @@ -29,6 +29,7 @@ help(){ echo " --output The full path to which the package will be written." echo " --package-name Package to identify during installation. Example - 'dotnet-nightly', 'dotnet'" echo " --previous-version-url Url to the previous version of the debian packge against which to run the upgrade tests." + echo " --obj-root Root folder for intermediate objects." exit 1 } @@ -61,6 +62,10 @@ parseargs(){ PREVIOUS_VERSION_URL=$2 shift ;; + --obj-root) + OBJECT_DIR=$2 + shift + ;; --help) help ;; @@ -103,9 +108,9 @@ parseargs $@ PACKAGING_ROOT="$REPOROOT/packaging/debian" PACKAGING_TOOL_DIR="$REPOROOT/tools/DebianPackageTool" -PACKAGE_OUTPUT_DIR=$(dirname "${OUTPUT_DEBIAN_FILE}") -PACKAGE_LAYOUT_DIR="$PACKAGE_OUTPUT_DIR/deb_intermediate" -TEST_STAGE_DIR="$PACKAGE_OUTPUT_DIR/debian_tests" +PACKAGE_OUTPUT_DIR="$OBJECT_DIR/deb_output" +PACKAGE_LAYOUT_DIR="$OBJECT_DIR/deb_intermediate" +TEST_STAGE_DIR="$OBJECT_DIR/debian_tests" # remove any residual deb files from earlier builds rm -f "$PACKAGE_OUTPUT_DIR/*.deb" From 9004e20cf4dd3ff838f8e8b90d42a3a0ecf4c234 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 10 Mar 2016 00:12:25 -0800 Subject: [PATCH 08/15] Allow optional install_root in package config The shared framework packages will want to install to the same root directory as the "dotnet" package itself. Augment the package_tool script to look for a json key named `install_root` and use that if specificed, falling back to `/usr/share/$PACKAGE_NAME` when it is not present. --- tools/DebianPackageTool/package_tool | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/DebianPackageTool/package_tool b/tools/DebianPackageTool/package_tool index c48da1755..3cc139878 100755 --- a/tools/DebianPackageTool/package_tool +++ b/tools/DebianPackageTool/package_tool @@ -132,7 +132,10 @@ parse_config_and_set_env_vars(){ DOCS_JSON_PATH="$INPUT_DIR/docs.json" PACKAGE_SOURCE_DIR="${OUTPUT_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}" - INSTALL_ROOT="/usr/share/${PACKAGE_NAME}" + + if ! INSTALL_ROOT="$($extract_base_cmd $CONFIG "install_root")"; then + INSTALL_ROOT="/usr/share/$PACKAGE_NAME" + fi DEBIAN_DIR="${PACKAGE_SOURCE_DIR}/debian" DOCS_DIR="${PACKAGE_SOURCE_DIR}/docs" From 696f4dc167a377b39539e49842a142929c034036 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Wed, 9 Mar 2016 17:33:05 -0800 Subject: [PATCH 09/15] Add Shared Framework debian packaging --- .../dotnet-sharedframework-debian_config.json | 35 +++++ scripts/dotnet-cli-build/InstallerTargets.cs | 20 +++ scripts/dotnet-cli-build/Utils/Monikers.cs | 7 + .../package/package-sharedframework-debian.sh | 132 ++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json create mode 100755 scripts/package/package-sharedframework-debian.sh diff --git a/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json b/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json new file mode 100644 index 000000000..866a67515 --- /dev/null +++ b/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json @@ -0,0 +1,35 @@ +{ + "maintainer_name":"Microsoft", + "maintainer_email": "dotnetcore@microsoft.com", + + "package_name": "%SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME%", + "install_root": "/usr/share/dotnet", + + "short_description": ".NET Core Shared Framework %SHARED_FRAMEWORK_NUGET_NAME% %SHARED_FRAMEWORK_NUGET_VERSION%", + "long_description": ".NET Core is a cross-platform implementation of .NET Framework, a modern, modular platform\n for building diverse kinds of applications, from command-line applications to microservices and \n modern websites.\n This package contains a runtime and framework which can be used by .NET Core applications.", + "homepage": "https://dotnet.github.io/core", + + "release":{ + "package_version":"1.0.0.0", + "package_revision":"1", + "urgency" : "low", + "changelog_message" : "Inital shared framework." + }, + + "control": { + "priority":"standard", + "section":"libs", + "architecture":"amd64" + }, + + "copyright": "2015 Microsoft", + "license": { + "type": "MIT", + "full_text": "Copyright (c) 2015 Microsoft\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE." + }, + + "debian_dependencies":{ + "libssl-dev" : {}, + "libcurl3" : {} + } +} diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/scripts/dotnet-cli-build/InstallerTargets.cs index 88b36c800..f822b4ad8 100644 --- a/scripts/dotnet-cli-build/InstallerTargets.cs +++ b/scripts/dotnet-cli-build/InstallerTargets.cs @@ -104,6 +104,26 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Ubuntu)] public static BuildTargetResult GenerateSharedFrameworkDeb(BuildTargetContext c) { + var packageName = Monikers.GetDebianSharedFrameworkPackageName(c); + var version = c.BuildContext.Get("BuildVersion").SimpleVersion; + var inputRoot = c.BuildContext.Get("SharedFrameworkPublishRoot"); + var debFile = c.BuildContext.Get("SharedFrameworkInstallerFile"); + var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sharedframework"); + + if (Directory.Exists(objRoot)) + { + Directory.Delete(objRoot, true); + } + + Directory.CreateDirectory(objRoot); + + Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-sharedframework-debian.sh"), + "--input", inputRoot, "--output", debFile, "--package-name", packageName, + "--framework-nuget-name", SharedFrameworkTargets.SharedFrameworkName, + "--framework-nuget-version", c.BuildContext.Get("SharedFrameworkNugetVersion"), + "--obj-root", objRoot, "--version", version) + .Execute() + .EnsureSuccessful(); return c.Success(); } diff --git a/scripts/dotnet-cli-build/Utils/Monikers.cs b/scripts/dotnet-cli-build/Utils/Monikers.cs index 56eac7ee1..b69c0d05b 100644 --- a/scripts/dotnet-cli-build/Utils/Monikers.cs +++ b/scripts/dotnet-cli-build/Utils/Monikers.cs @@ -38,6 +38,13 @@ namespace Microsoft.DotNet.Cli.Build return packageName; } + public static string GetDebianSharedFrameworkPackageName(BuildTargetContext c) + { + var sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); + + return $"dotnet-sharedframework-{SharedFrameworkTargets.SharedFrameworkName}-{sharedFrameworkNugetVersion}".ToLower(); + } + public static string GetOSShortName() { string osname = ""; diff --git a/scripts/package/package-sharedframework-debian.sh b/scripts/package/package-sharedframework-debian.sh new file mode 100755 index 000000000..f4d993c98 --- /dev/null +++ b/scripts/package/package-sharedframework-debian.sh @@ -0,0 +1,132 @@ +#!/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. + +# Debian Packaging Script +# Currently Intended to build on ubuntu14.04 + +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" +REPOROOT="$DIR/../.." + +help(){ + echo "Usage: $0" + echo "" + echo "Options:" + echo " --input Package the entire contents of the directory tree." + echo " --output The full path to which the package will be written." + echo " --package-name Package to identify during installation. Example - 'dotnet-sharedframework'" + echo " --framework-nuget-name The name of the nuget package that produced this shared framework." + echo " --framework-nuget-version The versionf of the nuget package that produced this shared framework." + echo " --obj-root Root folder for intermediate objects." + echo " --version Version for the debain package." + exit 1 +} + +while [[ $# > 0 ]]; do + lowerI="$(echo $1 | awk '{print tolower($0)}')" + case $lowerI in + -o|--output) + OUTPUT_DEBIAN_FILE=$2 + shift + ;; + -i|--input) + REPO_BINARIES_DIR=$2 + shift + ;; + -p|--package-name) + SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME=$2 + shift + ;; + --framework-nuget-name) + SHARED_FRAMEWORK_NUGET_NAME=$2 + shift + ;; + --framework-nuget-version) + SHARED_FRAMEWORK_NUGET_VERSION=$2 + shift + ;; + --obj-root) + OBJECT_DIR=$2 + shift + ;; + --version) + SHARED_FRAMEWORK_DEBIAN_VERSION=$2 + shift + ;; + --help) + help + ;; + *) + break + ;; + esac + shift +done + +PACKAGING_ROOT="$REPOROOT/packaging/sharedframework/debian" +PACKAGING_TOOL_DIR="$REPOROOT/tools/DebianPackageTool" + +PACKAGE_OUTPUT_DIR="$OBJECT_DIR/deb_output" +PACKAGE_LAYOUT_DIR="$OBJECT_DIR/deb_intermediate" + +execute_build(){ + create_empty_debian_layout + copy_files_to_debian_layout + update_debian_json + create_debian_package +} + +create_empty_debian_layout(){ + header "Creating empty debian package layout" + + rm -rf "$PACKAGE_LAYOUT_DIR" + mkdir -p "$PACKAGE_LAYOUT_DIR" + + mkdir "$PACKAGE_LAYOUT_DIR/\$" + mkdir "$PACKAGE_LAYOUT_DIR/package_root" + mkdir "$PACKAGE_LAYOUT_DIR/samples" + mkdir "$PACKAGE_LAYOUT_DIR/docs" +} + +copy_files_to_debian_layout(){ + header "Copying files to debian layout" + + # Copy Built Binaries + cp -a "$REPO_BINARIES_DIR/." "$PACKAGE_LAYOUT_DIR/package_root" + + # Copy config file + cp "$PACKAGING_ROOT/dotnet-sharedframework-debian_config.json" "$PACKAGE_LAYOUT_DIR/debian_config.json" +} + +create_debian_package(){ + header "Packing .deb" + + mkdir -p "$PACKAGE_OUTPUT_DIR" + + "$PACKAGING_TOOL_DIR/package_tool" -i "$PACKAGE_LAYOUT_DIR" -o "$PACKAGE_OUTPUT_DIR" -n "$SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME" -v "$SHARED_FRAMEWORK_DEBIAN_VERSION" +} + +update_debian_json() +{ + header "Updating debian.json file" + sed -i "s/%SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME%/$SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME/g" "$PACKAGE_LAYOUT_DIR"/debian_config.json + sed -i "s/%SHARED_FRAMEWORK_NUGET_NAME%/$SHARED_FRAMEWORK_NUGET_NAME/g" "$PACKAGE_LAYOUT_DIR"/debian_config.json + sed -i "s/%SHARED_FRAMEWORK_NUGET_VERSION%/$SHARED_FRAMEWORK_NUGET_VERSION/g" "$PACKAGE_LAYOUT_DIR"/debian_config.json +} + +execute_build + +DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") + +mv -f "$DEBIAN_FILE" "$OUTPUT_DEBIAN_FILE" From 56e5a99c5402badcc4133d8bb63fabfa8dfb1c7b Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Wed, 9 Mar 2016 17:53:08 -0800 Subject: [PATCH 10/15] Add Shared Host Debian Package --- .../dotnet-sharedhost-debian_config.json | 35 ++++++ scripts/dotnet-cli-build/InstallerTargets.cs | 17 ++- scripts/package/package-sharedhost-debian.sh | 108 ++++++++++++++++++ 3 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 packaging/host/debian/dotnet-sharedhost-debian_config.json create mode 100755 scripts/package/package-sharedhost-debian.sh diff --git a/packaging/host/debian/dotnet-sharedhost-debian_config.json b/packaging/host/debian/dotnet-sharedhost-debian_config.json new file mode 100644 index 000000000..840e5945f --- /dev/null +++ b/packaging/host/debian/dotnet-sharedhost-debian_config.json @@ -0,0 +1,35 @@ +{ + "maintainer_name":"Microsoft", + "maintainer_email": "dotnetcore@microsoft.com", + + "package_name": "dotnet-host", + "install_root": "/usr/share/dotnet", + + "short_description": ".NET Core Shared Host", + "long_description": ".NET Core is a cross-platform implementation of .NET Framework, a modern, modular platform\n for building diverse kinds of applications, from command-line applications to microservices and \n modern websites.\n This package contains the host that launches a .NET Core application.", + "homepage": "https://dotnet.github.io/core", + + "release":{ + "package_version":"1.0.0.0", + "package_revision":"1", + "urgency" : "low", + "changelog_message" : "Inital shared host." + }, + + "control": { + "priority":"standard", + "section":"libs", + "architecture":"amd64" + }, + + "copyright": "2015 Microsoft", + "license": { + "type": "MIT", + "full_text": "Copyright (c) 2015 Microsoft\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE." + }, + + "debian_dependencies":{ + "libssl-dev" : {}, + "libcurl3" : {} + } +} diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/scripts/dotnet-cli-build/InstallerTargets.cs index f822b4ad8..e8e5d910b 100644 --- a/scripts/dotnet-cli-build/InstallerTargets.cs +++ b/scripts/dotnet-cli-build/InstallerTargets.cs @@ -97,6 +97,22 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.Ubuntu)] public static BuildTargetResult GenerateSharedHostDeb(BuildTargetContext c) { + var version = c.BuildContext.Get("BuildVersion").SimpleVersion; + var inputRoot = c.BuildContext.Get("SharedHostPublishRoot"); + var debFile = c.BuildContext.Get("SharedHostInstallerFile"); + var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sharedhost"); + + if (Directory.Exists(objRoot)) + { + Directory.Delete(objRoot, true); + } + + Directory.CreateDirectory(objRoot); + + Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-sharedhost-debian.sh"), + "--input", inputRoot, "--output", debFile, "--obj-root", objRoot, "--version", version) + .Execute() + .EnsureSuccessful(); return c.Success(); } @@ -126,6 +142,5 @@ namespace Microsoft.DotNet.Cli.Build .EnsureSuccessful(); return c.Success(); } - } } diff --git a/scripts/package/package-sharedhost-debian.sh b/scripts/package/package-sharedhost-debian.sh new file mode 100755 index 000000000..6ab255dc9 --- /dev/null +++ b/scripts/package/package-sharedhost-debian.sh @@ -0,0 +1,108 @@ +#!/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. + +# Debian Packaging Script +# Currently Intended to build on ubuntu14.04 + +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" +REPOROOT="$DIR/../.." + +help(){ + echo "Usage: $0" + echo "" + echo "Options:" + echo " --input Package the entire contents of the directory tree." + echo " --output The full path to which the package will be written." + echo " --obj-root Root folder for intermediate objects." + echo " --version Version for the debain package." + exit 1 +} + +while [[ $# > 0 ]]; do + lowerI="$(echo $1 | awk '{print tolower($0)}')" + case $lowerI in + -o|--output) + OUTPUT_DEBIAN_FILE=$2 + shift + ;; + -i|--input) + REPO_BINARIES_DIR=$2 + shift + ;; + --obj-root) + OBJECT_DIR=$2 + shift + ;; + --version) + SHARED_HOST_DEBIAN_VERSION=$2 + shift + ;; + --help) + help + ;; + *) + break + ;; + esac + shift +done + +PACKAGING_ROOT="$REPOROOT/packaging/host/debian" +PACKAGING_TOOL_DIR="$REPOROOT/tools/DebianPackageTool" + +PACKAGE_OUTPUT_DIR="$OBJECT_DIR/deb_output" +PACKAGE_LAYOUT_DIR="$OBJECT_DIR/deb_intermediate" + +execute_build(){ + create_empty_debian_layout + copy_files_to_debian_layout + create_debian_package +} + +create_empty_debian_layout(){ + header "Creating empty debian package layout" + + rm -rf "$PACKAGE_LAYOUT_DIR" + mkdir -p "$PACKAGE_LAYOUT_DIR" + + mkdir "$PACKAGE_LAYOUT_DIR/\$" + mkdir "$PACKAGE_LAYOUT_DIR/package_root" + mkdir "$PACKAGE_LAYOUT_DIR/samples" + mkdir "$PACKAGE_LAYOUT_DIR/docs" +} + +copy_files_to_debian_layout(){ + header "Copying files to debian layout" + + # Copy Built Binaries + cp -a "$REPO_BINARIES_DIR/." "$PACKAGE_LAYOUT_DIR/package_root" + + # Copy config file + cp "$PACKAGING_ROOT/dotnet-sharedhost-debian_config.json" "$PACKAGE_LAYOUT_DIR/debian_config.json" +} + +create_debian_package(){ + header "Packing .deb" + + mkdir -p "$PACKAGE_OUTPUT_DIR" + + "$PACKAGING_TOOL_DIR/package_tool" -i "$PACKAGE_LAYOUT_DIR" -o "$PACKAGE_OUTPUT_DIR" -v "$SHARED_HOST_DEBIAN_VERSION" +} + +execute_build + +DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") + +mv -f "$DEBIAN_FILE" "$OUTPUT_DEBIAN_FILE" From 4df5ed39d5f63e2074d8d0a3ad326c9528d1a0ce Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 10 Mar 2016 03:19:00 -0800 Subject: [PATCH 11/15] Crossgen Shared Framework managed assemblies - Use Crossgen's Ready To Run mode on all of the managed assemblies that make up the shared framework. - Upgrade the version of the shared framework to match what is used in the rest of CLI (see the comment in SharedFrameworkTargets.cs to understand why this is needed). - Remove the IL mscorlib.dll image, since the Crossgen'd image is already published. Fixes dotnet/corefx#6753 --- scripts/dotnet-cli-build/CompileTargets.cs | 34 ++---------- .../SharedFrameworkTargets.cs | 54 ++++++++++++++++++- scripts/dotnet-cli-build/Utils/Crossgen.cs | 50 +++++++++++++++++ scripts/dotnet-cli-build/project.json | 3 +- src/sharedframework/framework/project.json | 2 +- src/sharedframework/host/project.json | 2 +- 6 files changed, 110 insertions(+), 35 deletions(-) create mode 100644 scripts/dotnet-cli-build/Utils/Crossgen.cs diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/scripts/dotnet-cli-build/CompileTargets.cs index 1fc300ce0..9cecf95de 100644 --- a/scripts/dotnet-cli-build/CompileTargets.cs +++ b/scripts/dotnet-cli-build/CompileTargets.cs @@ -293,41 +293,13 @@ namespace Microsoft.DotNet.Cli.Build } // Find crossgen - string arch = PlatformServices.Default.Runtime.RuntimeArchitecture; - string packageId; - if (CurrentPlatform.IsWindows) - { - packageId = $"runtime.win7-{arch}.Microsoft.NETCore.Runtime.CoreCLR"; - } - else if (CurrentPlatform.IsUbuntu) - { - packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR"; - } - else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL) - { - // CentOS runtime is in the runtime.rhel.7-x64... package. - packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR"; - } - else if (CurrentPlatform.IsDebian) - { - packageId = "runtime.debian.8.2-x64.Microsoft.NETCore.Runtime.CoreCLR"; - } - else if (CurrentPlatform.IsOSX) - { - packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR"; - } - else + var crossGenExePath = Microsoft.DotNet.Cli.Build.Crossgen.GetCrossgenPathForVersion(CoreCLRVersion); + + if (string.IsNullOrEmpty(crossGenExePath)) { return c.Failed("Unsupported OS Platform"); } - var crossGenExePath = Path.Combine( - Dirs.NuGetPackages, - packageId, - CoreCLRVersion, - "tools", - $"crossgen{Constants.ExeSuffix}"); - // We have to copy crossgen next to mscorlib var crossgen = Path.Combine(outputDir, $"crossgen{Constants.ExeSuffix}"); File.Copy(crossGenExePath, crossgen, overwrite: true); diff --git a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs index 760992734..e3b1d316f 100644 --- a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs +++ b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Text.RegularExpressions; +using System.Reflection.PortableExecutable; using System.Runtime.InteropServices; using Microsoft.DotNet.Cli.Build.Framework; using Microsoft.Extensions.PlatformAbstractions; @@ -51,6 +52,15 @@ namespace Microsoft.DotNet.Cli.Build // hostpolicy will be renamed to dotnet at some point and then this can be removed. File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(SharedFrameworkNameAndVersionRoot, $"{Constants.DynamicLibPrefix}dotnethostimpl{Constants.DynamicLibSuffix}")); + if (File.Exists(Path.Combine(SharedFrameworkNameAndVersionRoot, "mscorlib.ni.dll"))) + { + // Publish already places the crossgen'd version of mscorlib into the output, so we can + // remove the IL version + File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "mscorlib.dll")); + + CrossGenAllManagedAssemblies(SharedFrameworkNameAndVersionRoot); + } + return c.Success(); } @@ -99,5 +109,47 @@ namespace Microsoft.DotNet.Cli.Build return null; } + + private static void CrossGenAllManagedAssemblies(string pathToAssemblies) + { + foreach (var file in Directory.GetFiles(pathToAssemblies)) + { + string fileName = Path.GetFileName(file); + + if (fileName == "mscorlib.dll" || fileName == "mscorlib.ni.dll" || !HasMetadata(file)) + { + continue; + } + + string tempPathName = Path.ChangeExtension(file, "readytorun"); + + // This is not always correct. The version of crossgen we need to pick up is whatever one was restored as part + // of the Microsoft.NETCore.Runtime.CoreCLR package that is part of the shared library. For now, the version hardcoded + // in CompileTargets and the one in the shared library project.json match and are updated in lock step, but long term + // we need to be able to look at the project.lock.json file and figure out what version of Microsoft.NETCore.Runtime.CoreCLR + // was used, and then select that version. + ExecSilent(Crossgen.GetCrossgenPathForVersion(CompileTargets.CoreCLRVersion), + "-readytorun", "-in", file, "-out", tempPathName, "-platform_assemblies_paths", pathToAssemblies); + + File.Delete(file); + File.Move(tempPathName, file); + } + } + + private static bool HasMetadata(string pathToFile) + { + try + { + using (var inStream = File.OpenRead(pathToFile)) + { + using (var peReader = new PEReader(inStream)) + { + return peReader.HasMetadata; + } + } + } catch (BadImageFormatException) { } + + return false; + } } -} \ No newline at end of file +} diff --git a/scripts/dotnet-cli-build/Utils/Crossgen.cs b/scripts/dotnet-cli-build/Utils/Crossgen.cs new file mode 100644 index 000000000..37cf836aa --- /dev/null +++ b/scripts/dotnet-cli-build/Utils/Crossgen.cs @@ -0,0 +1,50 @@ +using System.IO; +using System.Linq; +using System; +using System.Runtime.InteropServices; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.Extensions.PlatformAbstractions; + +namespace Microsoft.DotNet.Cli.Build +{ + internal static class Crossgen + { + public static string GetCrossgenPathForVersion(string coreClrVersion) + { + string arch = PlatformServices.Default.Runtime.RuntimeArchitecture; + string packageId; + if (CurrentPlatform.IsWindows) + { + packageId = $"runtime.win7-{arch}.Microsoft.NETCore.Runtime.CoreCLR"; + } + else if (CurrentPlatform.IsUbuntu) + { + packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL) + { + // CentOS runtime is in the runtime.rhel.7-x64... package. + packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else if (CurrentPlatform.IsOSX) + { + packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else if (CurrentPlatform.IsDebian) + { + packageId = "runtime.debian.8.2-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else + { + return null; + } + + return Path.Combine( + Dirs.NuGetPackages, + packageId, + coreClrVersion, + "tools", + $"crossgen{Constants.ExeSuffix}"); + } + } +} diff --git a/scripts/dotnet-cli-build/project.json b/scripts/dotnet-cli-build/project.json index 2be69c156..f66171d24 100755 --- a/scripts/dotnet-cli-build/project.json +++ b/scripts/dotnet-cli-build/project.json @@ -11,7 +11,8 @@ "System.Security.Cryptography.Algorithms": "4.0.0-rc2-23901", "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537", "Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*", - "WindowsAzure.Storage" : "6.2.2-preview" + "WindowsAzure.Storage" : "6.2.2-preview", + "System.Reflection.Metadata" : "1.2.0" }, "frameworks": { diff --git a/src/sharedframework/framework/project.json b/src/sharedframework/framework/project.json index 5d904b02f..48e835c95 100644 --- a/src/sharedframework/framework/project.json +++ b/src/sharedframework/framework/project.json @@ -5,7 +5,7 @@ }, "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23811" + "NETStandard.Library": "1.0.0-rc2-23901" }, "frameworks": { diff --git a/src/sharedframework/host/project.json b/src/sharedframework/host/project.json index 30251684c..80a3611f2 100644 --- a/src/sharedframework/host/project.json +++ b/src/sharedframework/host/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23811" + "NETStandard.Library": "1.0.0-rc2-23901" }, "frameworks": { From edbbc64b030b5a0b208c5294c9dda147e9352829 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Wed, 9 Mar 2016 13:26:37 -0800 Subject: [PATCH 12/15] Fill out pkg installer targets This causes three pkg files to be produced: * A component pkg for the shared framework. * A component pkg for the shared host. * A product archive which includes the above two components. The product archive also needs a distribution.xml file which contains metadata about the package (name, title, images, etc.). The installer for the "SDK" itself is still using logic implemented in package-osx.sh. We should move this logic into the build target as well, but we may want to wait until the CLI is using the shared framework to do so. --- .../osx/sharedframework/scripts/postinstall | 13 ++ ...shared-framework-distribution-template.xml | 24 ++++ packaging/osx/sharedhost/scripts/postinstall | 13 ++ scripts/dotnet-cli-build/InstallerTargets.cs | 38 +----- scripts/dotnet-cli-build/PkgTargets.cs | 123 ++++++++++++++++++ 5 files changed, 174 insertions(+), 37 deletions(-) create mode 100755 packaging/osx/sharedframework/scripts/postinstall create mode 100644 packaging/osx/sharedframework/shared-framework-distribution-template.xml create mode 100755 packaging/osx/sharedhost/scripts/postinstall create mode 100644 scripts/dotnet-cli-build/PkgTargets.cs diff --git a/packaging/osx/sharedframework/scripts/postinstall b/packaging/osx/sharedframework/scripts/postinstall new file mode 100755 index 000000000..50fd8f1b7 --- /dev/null +++ b/packaging/osx/sharedframework/scripts/postinstall @@ -0,0 +1,13 @@ +#!/bin/sh +# +# 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. +# + +PACKAGE=$1 +INSTALL_DESTINATION=$2 + +# A temporary fix for the permissions issue(s) +chmod -R 755 $INSTALL_DESTINATION/shared + +exit 0 diff --git a/packaging/osx/sharedframework/shared-framework-distribution-template.xml b/packaging/osx/sharedframework/shared-framework-distribution-template.xml new file mode 100644 index 000000000..a4c42cbc1 --- /dev/null +++ b/packaging/osx/sharedframework/shared-framework-distribution-template.xml @@ -0,0 +1,24 @@ + + + .NET Core Shared Framework ({SharedFrameworkNugetVersion}) + + + + + + + + + + + + + + + + + + + com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg + com.microsoft.dotnet.sharedhost.osx.x64.pkg + diff --git a/packaging/osx/sharedhost/scripts/postinstall b/packaging/osx/sharedhost/scripts/postinstall new file mode 100755 index 000000000..bac3303f2 --- /dev/null +++ b/packaging/osx/sharedhost/scripts/postinstall @@ -0,0 +1,13 @@ +#!/bin/sh +# +# 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. +# + +PACKAGE=$1 +INSTALL_DESTINATION=$2 + +# A temporary fix for the permissions issue(s) +chmod 755 $INSTALL_DESTINATION/dotnet + +exit 0 diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/scripts/dotnet-cli-build/InstallerTargets.cs index e8e5d910b..097d37f18 100644 --- a/scripts/dotnet-cli-build/InstallerTargets.cs +++ b/scripts/dotnet-cli-build/InstallerTargets.cs @@ -14,49 +14,13 @@ namespace Microsoft.DotNet.Cli.Build { [Target(nameof(MsiTargets.GenerateMsis), nameof(MsiTargets.GenerateBundle), - nameof(InstallerTargets.GeneratePkgs), + nameof(PkgTargets.GeneratePkgs), nameof(InstallerTargets.GenerateDebs))] public static BuildTargetResult GenerateInstaller(BuildTargetContext c) { return c.Success(); } - [Target(nameof(InstallerTargets.GenerateSdkPkg), - nameof(InstallerTargets.GenerateSharedFrameworkPkg), - nameof(InstallerTargets.GenerateSharedHostPkg))] - [BuildPlatforms(BuildPlatform.OSX)] - public static BuildTargetResult GeneratePkgs(BuildTargetContext c) - { - return c.Success(); - } - - [Target] - [BuildPlatforms(BuildPlatform.OSX)] - public static BuildTargetResult GenerateSdkPkg(BuildTargetContext c) - { - var version = c.BuildContext.Get("BuildVersion").SimpleVersion; - var pkg = c.BuildContext.Get("SdkInstallerFile"); - 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.OSX)] - public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c) - { - return c.Success(); - } - - [Target] - [BuildPlatforms(BuildPlatform.OSX)] - public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c) - { - return c.Success(); - } - [Target(nameof(InstallerTargets.GenerateSdkDeb), nameof(InstallerTargets.GenerateSharedFrameworkDeb), nameof(InstallerTargets.GenerateSharedHostDeb))] diff --git a/scripts/dotnet-cli-build/PkgTargets.cs b/scripts/dotnet-cli-build/PkgTargets.cs new file mode 100644 index 000000000..a60d32d21 --- /dev/null +++ b/scripts/dotnet-cli-build/PkgTargets.cs @@ -0,0 +1,123 @@ +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 PkgTargets + { + [Target(nameof(GenerateSdkProductArchive), nameof(GenerateSharedFrameworkProductArchive))] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GeneratePkgs(BuildTargetContext c) + { + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateSdkProductArchive(BuildTargetContext c) + { + var version = c.BuildContext.Get("BuildVersion").SimpleVersion; + var pkg = c.BuildContext.Get("SdkInstallerFile"); + + Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"), + "-v", version, "-i", Dirs.Stage2, "-o", pkg) + .Execute() + .EnsureSuccessful(); + return c.Success(); + } + + [Target(nameof(GenerateSharedFrameworkPkg), nameof(GenerateSharedHostPkg))] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateSharedFrameworkProductArchive(BuildTargetContext c) + { + string sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); + string version = c.BuildContext.Get("BuildVersion").SimpleVersion; + string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetVersion}.osx.x64"; + string packageIntermediatesPath = Path.Combine(Dirs.Output, "obj", "pkg"); + string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "resources"); + string outFilePath = Path.Combine(packageIntermediatesPath, id + ".pkg"); + + string inputDistTemplatePath = Path.Combine( + Dirs.RepoRoot, + "packaging", + "osx", + "sharedframework", + "shared-framework-distribution-template.xml"); + string distTemplate = File.ReadAllText(inputDistTemplatePath); + string distributionPath = Path.Combine(packageIntermediatesPath, "shared-framework-formatted-distribution.xml"); + string formattedDistContents = + distTemplate.Replace("{SharedFrameworkNugetVersion}", sharedFrameworkNugetVersion) + .Replace("{VERSION}", version); + File.WriteAllText(distributionPath, formattedDistContents); + + Cmd("productbuild", + "--version", version, + "--identifier", id, + "--package-path", packageIntermediatesPath, + "--resources", resourcePath, + "--distribution", distributionPath, + outFilePath + ) + .Execute() + .EnsureSuccessful(); + + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c) + { + string sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); + Directory.CreateDirectory(Path.Combine(Dirs.Output, "obj", "pkg")); + string version = c.BuildContext.Get("BuildVersion").SimpleVersion; + string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetVersion}.component.osx.x64"; + string outFilePath = Path.Combine(Dirs.Output, "obj", "pkg", id + ".pkg"); + string installLocation = "/usr/local/share/dotnet"; + string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedframework", "scripts"); + + Cmd("pkgbuild", + "--root", c.BuildContext.Get("SharedFrameworkPublishRoot"), + "--identifier", id, + "--version", version, + "--install-location", installLocation, + "--scripts", scriptsLocation, + outFilePath) + .Execute() + .EnsureSuccessful(); + + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c) + { + Directory.CreateDirectory(Path.Combine(Dirs.Output, "obj", "pkg")); + string version = c.BuildContext.Get("BuildVersion").SimpleVersion; + string id = $"com.microsoft.dotnet.sharedhost.osx.x64"; + string outFilePath = Path.Combine(Dirs.Output, "obj", "pkg", id + ".pkg"); + string installLocation = "/usr/local/share/dotnet"; + string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedhost", "scripts"); + + Cmd("pkgbuild", + "--root", c.BuildContext.Get("SharedHostPublishRoot"), + "--identifier", id, + "--version", version, + "--install-location", installLocation, + "--scripts", scriptsLocation, + outFilePath) + .Execute() + .EnsureSuccessful(); + + return c.Success(); + } + } +} \ No newline at end of file From d77fad4e684df505bae10dd40850b6e3ab462306 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Thu, 10 Mar 2016 15:19:54 -0800 Subject: [PATCH 13/15] Bring the OSX installer 'title' in line with Windows It now includes the shared framework 'name' (NuGet package name) in the installer. In this case, the installer is called '.NET Core Shared Framework (NETStandard.Library 1.0.0-*)' --- .../shared-framework-distribution-template.xml | 10 +++++----- scripts/dotnet-cli-build/PkgTargets.cs | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packaging/osx/sharedframework/shared-framework-distribution-template.xml b/packaging/osx/sharedframework/shared-framework-distribution-template.xml index a4c42cbc1..15ff9e92a 100644 --- a/packaging/osx/sharedframework/shared-framework-distribution-template.xml +++ b/packaging/osx/sharedframework/shared-framework-distribution-template.xml @@ -1,6 +1,6 @@ - .NET Core Shared Framework ({SharedFrameworkNugetVersion}) + .NET Core Shared Framework ({SharedFrameworkNugetName} {SharedFrameworkNugetVersion}) @@ -10,15 +10,15 @@ - + - - + + - com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg + com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetName}.{SharedFrameworkNugetVersion}.component.osx.x64.pkg com.microsoft.dotnet.sharedhost.osx.x64.pkg diff --git a/scripts/dotnet-cli-build/PkgTargets.cs b/scripts/dotnet-cli-build/PkgTargets.cs index a60d32d21..1f082b069 100644 --- a/scripts/dotnet-cli-build/PkgTargets.cs +++ b/scripts/dotnet-cli-build/PkgTargets.cs @@ -37,9 +37,10 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.OSX)] public static BuildTargetResult GenerateSharedFrameworkProductArchive(BuildTargetContext c) { + string sharedFrameworkNugetName = SharedFrameworkTargets.SharedFrameworkName; string sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); string version = c.BuildContext.Get("BuildVersion").SimpleVersion; - string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetVersion}.osx.x64"; + string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.osx.x64"; string packageIntermediatesPath = Path.Combine(Dirs.Output, "obj", "pkg"); string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "resources"); string outFilePath = Path.Combine(packageIntermediatesPath, id + ".pkg"); @@ -54,6 +55,7 @@ namespace Microsoft.DotNet.Cli.Build string distributionPath = Path.Combine(packageIntermediatesPath, "shared-framework-formatted-distribution.xml"); string formattedDistContents = distTemplate.Replace("{SharedFrameworkNugetVersion}", sharedFrameworkNugetVersion) + .Replace("{SharedFrameworkNugetName}", SharedFrameworkTargets.SharedFrameworkName) .Replace("{VERSION}", version); File.WriteAllText(distributionPath, formattedDistContents); @@ -63,8 +65,7 @@ namespace Microsoft.DotNet.Cli.Build "--package-path", packageIntermediatesPath, "--resources", resourcePath, "--distribution", distributionPath, - outFilePath - ) + outFilePath) .Execute() .EnsureSuccessful(); @@ -75,10 +76,11 @@ namespace Microsoft.DotNet.Cli.Build [BuildPlatforms(BuildPlatform.OSX)] public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c) { + string sharedFrameworkNugetName = SharedFrameworkTargets.SharedFrameworkName; string sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); Directory.CreateDirectory(Path.Combine(Dirs.Output, "obj", "pkg")); string version = c.BuildContext.Get("BuildVersion").SimpleVersion; - string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetVersion}.component.osx.x64"; + string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.component.osx.x64"; string outFilePath = Path.Combine(Dirs.Output, "obj", "pkg", id + ".pkg"); string installLocation = "/usr/local/share/dotnet"; string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedframework", "scripts"); From ce118f9d079557b1e2ffab6a42362a0752e7612d Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Thu, 10 Mar 2016 15:20:29 -0800 Subject: [PATCH 14/15] Add warning if shared framework is not going to be crossgen'd because mscorlib.ni.dll does not exist --- scripts/dotnet-cli-build/SharedFrameworkTargets.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs index e3b1d316f..e2bbd53f9 100644 --- a/scripts/dotnet-cli-build/SharedFrameworkTargets.cs +++ b/scripts/dotnet-cli-build/SharedFrameworkTargets.cs @@ -60,6 +60,10 @@ namespace Microsoft.DotNet.Cli.Build CrossGenAllManagedAssemblies(SharedFrameworkNameAndVersionRoot); } + else + { + c.Warn("Shared framework will not be crossgen'd because mscorlib.ni.dll does not exist."); + } return c.Success(); } From 9f3feda606197af37469a1781e6ae6477c1c567c Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Fri, 11 Mar 2016 14:24:09 -0800 Subject: [PATCH 15/15] Add sharedframework and sharedhost debian installer tests These are basic tests for now, which validate installation, upgrade, uninstall, etc. of the debian package itself. When the shared framework is fully functional, we will add more tests that cover real functionality. --- .../dotnet-sharedframework-debian_config.json | 2 +- .../package/package-sharedframework-debian.sh | 22 +++++++++++++++++++ scripts/package/package-sharedhost-debian.sh | 22 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json b/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json index 866a67515..93d32d198 100644 --- a/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json +++ b/packaging/sharedframework/debian/dotnet-sharedframework-debian_config.json @@ -29,7 +29,7 @@ }, "debian_dependencies":{ - "libssl-dev" : {}, + "libssl1.0.0" : {}, "libcurl3" : {} } } diff --git a/scripts/package/package-sharedframework-debian.sh b/scripts/package/package-sharedframework-debian.sh index f4d993c98..ef904c0ee 100755 --- a/scripts/package/package-sharedframework-debian.sh +++ b/scripts/package/package-sharedframework-debian.sh @@ -79,6 +79,7 @@ PACKAGING_TOOL_DIR="$REPOROOT/tools/DebianPackageTool" PACKAGE_OUTPUT_DIR="$OBJECT_DIR/deb_output" PACKAGE_LAYOUT_DIR="$OBJECT_DIR/deb_intermediate" +TEST_STAGE_DIR="$OBJECT_DIR/debian_tests" execute_build(){ create_empty_debian_layout @@ -125,8 +126,29 @@ update_debian_json() sed -i "s/%SHARED_FRAMEWORK_NUGET_VERSION%/$SHARED_FRAMEWORK_NUGET_VERSION/g" "$PACKAGE_LAYOUT_DIR"/debian_config.json } +test_debian_package(){ + header "Testing debian package" + + install_bats + run_package_integrity_tests +} + +install_bats() { + rm -rf $TEST_STAGE_DIR + git clone https://github.com/sstephenson/bats.git $TEST_STAGE_DIR +} + +run_package_integrity_tests() { + # Set LAST_VERSION_URL to enable upgrade tests + # export LAST_VERSION_URL="$PREVIOUS_VERSION_URL" + + $TEST_STAGE_DIR/bin/bats $PACKAGE_OUTPUT_DIR/test_package.bats +} + execute_build DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") +test_debian_package + mv -f "$DEBIAN_FILE" "$OUTPUT_DEBIAN_FILE" diff --git a/scripts/package/package-sharedhost-debian.sh b/scripts/package/package-sharedhost-debian.sh index 6ab255dc9..4c4ecb8db 100755 --- a/scripts/package/package-sharedhost-debian.sh +++ b/scripts/package/package-sharedhost-debian.sh @@ -64,6 +64,7 @@ PACKAGING_TOOL_DIR="$REPOROOT/tools/DebianPackageTool" PACKAGE_OUTPUT_DIR="$OBJECT_DIR/deb_output" PACKAGE_LAYOUT_DIR="$OBJECT_DIR/deb_intermediate" +TEST_STAGE_DIR="$OBJECT_DIR/debian_tests" execute_build(){ create_empty_debian_layout @@ -101,8 +102,29 @@ create_debian_package(){ "$PACKAGING_TOOL_DIR/package_tool" -i "$PACKAGE_LAYOUT_DIR" -o "$PACKAGE_OUTPUT_DIR" -v "$SHARED_HOST_DEBIAN_VERSION" } +test_debian_package(){ + header "Testing debian package" + + install_bats + run_package_integrity_tests +} + +install_bats() { + rm -rf $TEST_STAGE_DIR + git clone https://github.com/sstephenson/bats.git $TEST_STAGE_DIR +} + +run_package_integrity_tests() { + # Set LAST_VERSION_URL to enable upgrade tests + # export LAST_VERSION_URL="$PREVIOUS_VERSION_URL" + + $TEST_STAGE_DIR/bin/bats $PACKAGE_OUTPUT_DIR/test_package.bats +} + execute_build DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb") +test_debian_package + mv -f "$DEBIAN_FILE" "$OUTPUT_DEBIAN_FILE"