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