diff --git a/packaging/osx/Distribution-Template b/packaging/osx/Distribution-Template deleted file mode 100644 index c220fa5ac..000000000 --- a/packaging/osx/Distribution-Template +++ /dev/null @@ -1,22 +0,0 @@ - - - .NET CLI {VERSION} - - - - - - - - - - - - - - - - - - dotnet-osx-x64.{VERSION}.pkg - diff --git a/packaging/osx/clisdk/Distribution-Template b/packaging/osx/clisdk/Distribution-Template new file mode 100644 index 000000000..7e3f3b7ad --- /dev/null +++ b/packaging/osx/clisdk/Distribution-Template @@ -0,0 +1,33 @@ + + + .NET CLI {VERSION} + + + + + + + + + + + + + + + + + + + + + + + + + + + com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetName}.{SharedFrameworkNugetVersion}.component.osx.x64.pkg + com.microsoft.dotnet.sharedhost.osx.x64.pkg + com.microsoft.dotnet.sdk.osx.x64.pkg + diff --git a/packaging/osx/scripts/postinstall b/packaging/osx/clisdk/scripts/postinstall similarity index 86% rename from packaging/osx/scripts/postinstall rename to packaging/osx/clisdk/scripts/postinstall index 0a649953a..428b79064 100755 --- a/packaging/osx/scripts/postinstall +++ b/packaging/osx/clisdk/scripts/postinstall @@ -12,7 +12,7 @@ INSTALL_DESTINATION=$2 chmod -R 755 $INSTALL_DESTINATION # Add the installation bin directory to the system-wide paths -echo $INSTALL_DESTINATION/bin | tee -a /etc/paths.d/dotnet +echo $INSTALL_DESTINATION | tee -a /etc/paths.d/dotnet exit 0 diff --git a/packaging/osx/package-osx.sh b/packaging/osx/package-osx.sh deleted file mode 100755 index 819a7e1f6..000000000 --- a/packaging/osx/package-osx.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# -# Copyright (c) .NET Foundation and contributors. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. -# - -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -help(){ - echo "Usage: $0 [--version ] [--input ] [--output ] [--help]" - echo "" - echo "Options:" - echo " --version Specify a version for the package. Version format is 4 '.' separated numbers - ..." - echo " --input Package the entire contents of the directory tree." - echo " --output The path to where the package will be written." - exit 1 -} - -while [[ $# > 0 ]]; do - lowerI="$(echo $1 | awk '{print tolower($0)}')" - case $lowerI in - -v|--version) - DOTNET_CLI_VERSION=$2 - shift - ;; - -o|--output) - OUTPUT_PKG=$2 - shift - ;; - -i|--input) - INPUT_DIR=$2 - shift - ;; - --help) - help - ;; - *) - break - ;; - esac - shift -done - -if [ -z "$DOTNET_CLI_VERSION" ]; then - echo "Provide a version number. Missing option '--version'" && help -fi - -if [ -z "$OUTPUT_PKG" ]; then - echo "Provide an output pkg. Missing option '--output'" && help -fi - -if [ -z "$INPUT_DIR" ]; then - echo "Provide an input directory. Missing option '--input'" && help -fi - -if [ ! -d "$INPUT_DIR" ]; then - echo "'$INPUT_DIR' - is either missing or not a directory" 1>&2 - exit 1 -fi - -PACKAGE_DIR=$(dirname "${OUTPUT_PKG}") -[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR - -PACKAGE_ID=$(basename "${OUTPUT_PKG}") - -#chmod -R 755 $INPUT_DIR -pkgbuild --root $INPUT_DIR \ - --version $DOTNET_CLI_VERSION \ - --scripts $DIR/scripts \ - --identifier com.microsoft.dotnet.cli.pkg.dotnet-osx-x64 \ - --install-location /usr/local/share/dotnet \ - $DIR/$PACKAGE_ID - -cat $DIR/Distribution-Template | sed "/{VERSION}/s//$DOTNET_CLI_VERSION/g" > $DIR/Dist - -productbuild --version $DOTNET_CLI_VERSION --identifier com.microsoft.dotnet.cli --package-path $DIR --resources $DIR/resources --distribution $DIR/Dist $OUTPUT_PKG - -#Clean temp files -rm $DIR/$PACKAGE_ID -rm $DIR/Dist diff --git a/scripts/dotnet-cli-build/PkgTargets.cs b/scripts/dotnet-cli-build/PkgTargets.cs index 55b1ebe33..34220aac1 100644 --- a/scripts/dotnet-cli-build/PkgTargets.cs +++ b/scripts/dotnet-cli-build/PkgTargets.cs @@ -12,25 +12,80 @@ namespace Microsoft.DotNet.Cli.Build { public class PkgTargets { - [Target(nameof(GenerateSdkProductArchive), nameof(GenerateSharedFrameworkProductArchive))] + public static string PkgsIntermediateDir { get; set; } + [Target] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult InitPkg(BuildTargetContext c) + { + PkgsIntermediateDir = Path.Combine(Dirs.Packages, "intermediate"); + Directory.CreateDirectory(PkgsIntermediateDir); + return c.Success(); + } + + [Target(nameof(InitPkg), nameof(GenerateSharedFrameworkProductArchive), nameof(GenerateCLISdkProductArchive))] [BuildPlatforms(BuildPlatform.OSX)] public static BuildTargetResult GeneratePkgs(BuildTargetContext c) { return c.Success(); } + [Target(nameof(GenerateCLISdkPkg))] + [BuildPlatforms(BuildPlatform.OSX)] + public static BuildTargetResult GenerateCLISdkProductArchive(BuildTargetContext c) + { + string sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); + string version = c.BuildContext.Get("BuildVersion").SimpleVersion; + string id = $"com.microsoft.dotnet.dev.{version}.osx.x64"; + string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "resources"); + string outFilePath = Path.Combine(Dirs.Packages, c.BuildContext.Get("CombinedFrameworkSDKHostInstallerFile")); + + string inputDistTemplatePath = Path.Combine( + Dirs.RepoRoot, + "packaging", + "osx", + "clisdk", + "Distribution-Template"); + string distTemplate = File.ReadAllText(inputDistTemplatePath); + string distributionPath = Path.Combine(PkgsIntermediateDir, "CLI-SDK-Formatted-Distribution-Template.xml"); + string formattedDistContents = + distTemplate.Replace("{SharedFrameworkNugetVersion}", sharedFrameworkNugetVersion) + .Replace("{SharedFrameworkNugetName}", Monikers.SharedFrameworkName) + .Replace("{VERSION}", version); + File.WriteAllText(distributionPath, formattedDistContents); + + Cmd("productbuild", + "--version", version, + "--identifier", id, + "--package-path", PkgsIntermediateDir, + "--resources", resourcePath, + "--distribution", distributionPath, + outFilePath) + .Execute() + .EnsureSuccessful(); + + return c.Success(); + } + [Target] [BuildPlatforms(BuildPlatform.OSX)] - public static BuildTargetResult GenerateSdkProductArchive(BuildTargetContext c) + public static BuildTargetResult GenerateCLISdkPkg(BuildTargetContext c) { - var version = c.BuildContext.Get("BuildVersion").SimpleVersion; - var pkg = c.BuildContext.Get("CombinedFrameworkSDKHostInstallerFile"); - var input = c.BuildContext.Get("CLISDKRoot"); + string version = c.BuildContext.Get("BuildVersion").SimpleVersion; + string id = $"com.microsoft.dotnet.sdk.osx.x64"; + string outFilePath = Path.Combine(PkgsIntermediateDir, id + ".pkg"); + string installLocation = "/usr/local/share/dotnet"; + string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "clisdk", "scripts"); + + Cmd("pkgbuild", + "--root", c.BuildContext.Get("CLISDKRoot"), + "--identifier", id, + "--version", version, + "--install-location", installLocation, + "--scripts", scriptsLocation, + outFilePath) + .Execute() + .EnsureSuccessful(); - Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"), - "-v", version, "-i", input, "-o", pkg) - .Execute() - .EnsureSuccessful(); return c.Success(); } @@ -41,10 +96,9 @@ namespace Microsoft.DotNet.Cli.Build string sharedFrameworkNugetName = Monikers.SharedFrameworkName; string sharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); string version = c.BuildContext.Get("BuildVersion").SimpleVersion; - string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.osx.x64"; - string packageIntermediatesPath = Path.Combine(Dirs.Output, "obj", "pkg"); + string id = $"com.microsoft.dotnet.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.osx.x64"; string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "resources"); - string outFilePath = Path.Combine(packageIntermediatesPath, id + ".pkg"); + string outFilePath = Path.Combine(PkgsIntermediateDir, c.BuildContext.Get("CombinedFrameworkHostInstallerFile")); string inputDistTemplatePath = Path.Combine( Dirs.RepoRoot, @@ -53,7 +107,7 @@ namespace Microsoft.DotNet.Cli.Build "sharedframework", "shared-framework-distribution-template.xml"); string distTemplate = File.ReadAllText(inputDistTemplatePath); - string distributionPath = Path.Combine(packageIntermediatesPath, "shared-framework-formatted-distribution.xml"); + string distributionPath = Path.Combine(PkgsIntermediateDir, "shared-framework-formatted-distribution.xml"); string formattedDistContents = distTemplate.Replace("{SharedFrameworkNugetVersion}", sharedFrameworkNugetVersion) .Replace("{SharedFrameworkNugetName}", Monikers.SharedFrameworkName) @@ -63,7 +117,7 @@ namespace Microsoft.DotNet.Cli.Build Cmd("productbuild", "--version", version, "--identifier", id, - "--package-path", packageIntermediatesPath, + "--package-path", PkgsIntermediateDir, "--resources", resourcePath, "--distribution", distributionPath, outFilePath) @@ -79,10 +133,9 @@ namespace Microsoft.DotNet.Cli.Build { string sharedFrameworkNugetName = Monikers.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.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.component.osx.x64"; - string outFilePath = Path.Combine(Dirs.Output, "obj", "pkg", id + ".pkg"); + string outFilePath = Path.Combine(PkgsIntermediateDir, id + ".pkg"); string installLocation = "/usr/local/share/dotnet"; string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedframework", "scripts"); @@ -103,10 +156,9 @@ namespace Microsoft.DotNet.Cli.Build [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 outFilePath = Path.Combine(PkgsIntermediateDir, id + ".pkg"); string installLocation = "/usr/local/share/dotnet"; string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedhost", "scripts"); @@ -123,4 +175,4 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } } -} \ No newline at end of file +}