2016-03-09 21:26:37 +00:00
|
|
|
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>("BuildVersion").SimpleVersion;
|
2016-03-17 01:16:51 +00:00
|
|
|
var pkg = c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile");
|
|
|
|
var input = c.BuildContext.Get<string>("CLISDKRoot");
|
2016-03-09 21:26:37 +00:00
|
|
|
|
|
|
|
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
|
2016-03-17 01:16:51 +00:00
|
|
|
"-v", version, "-i", input, "-o", pkg)
|
2016-03-09 21:26:37 +00:00
|
|
|
.Execute()
|
|
|
|
.EnsureSuccessful();
|
|
|
|
return c.Success();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Target(nameof(GenerateSharedFrameworkPkg), nameof(GenerateSharedHostPkg))]
|
|
|
|
[BuildPlatforms(BuildPlatform.OSX)]
|
|
|
|
public static BuildTargetResult GenerateSharedFrameworkProductArchive(BuildTargetContext c)
|
|
|
|
{
|
2016-03-17 00:54:44 +00:00
|
|
|
string sharedFrameworkNugetName = Monikers.SharedFrameworkName;
|
2016-03-09 21:26:37 +00:00
|
|
|
string sharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
|
|
|
|
string version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
2016-03-10 23:19:54 +00:00
|
|
|
string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.osx.x64";
|
2016-03-09 21:26:37 +00:00
|
|
|
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");
|
2016-03-17 00:54:44 +00:00
|
|
|
string formattedDistContents =
|
2016-03-09 21:26:37 +00:00
|
|
|
distTemplate.Replace("{SharedFrameworkNugetVersion}", sharedFrameworkNugetVersion)
|
2016-03-17 00:54:44 +00:00
|
|
|
.Replace("{SharedFrameworkNugetName}", Monikers.SharedFrameworkName)
|
2016-03-09 21:26:37 +00:00
|
|
|
.Replace("{VERSION}", version);
|
|
|
|
File.WriteAllText(distributionPath, formattedDistContents);
|
|
|
|
|
|
|
|
Cmd("productbuild",
|
|
|
|
"--version", version,
|
|
|
|
"--identifier", id,
|
|
|
|
"--package-path", packageIntermediatesPath,
|
2016-03-17 00:54:44 +00:00
|
|
|
"--resources", resourcePath,
|
2016-03-09 21:26:37 +00:00
|
|
|
"--distribution", distributionPath,
|
2016-03-10 23:19:54 +00:00
|
|
|
outFilePath)
|
2016-03-09 21:26:37 +00:00
|
|
|
.Execute()
|
|
|
|
.EnsureSuccessful();
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Target]
|
|
|
|
[BuildPlatforms(BuildPlatform.OSX)]
|
|
|
|
public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c)
|
|
|
|
{
|
2016-03-17 00:54:44 +00:00
|
|
|
string sharedFrameworkNugetName = Monikers.SharedFrameworkName;
|
2016-03-09 21:26:37 +00:00
|
|
|
string sharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
|
|
|
|
Directory.CreateDirectory(Path.Combine(Dirs.Output, "obj", "pkg"));
|
|
|
|
string version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
2016-03-10 23:19:54 +00:00
|
|
|
string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{sharedFrameworkNugetVersion}.component.osx.x64";
|
2016-03-09 21:26:37 +00:00
|
|
|
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<string>("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>("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<string>("SharedHostPublishRoot"),
|
|
|
|
"--identifier", id,
|
|
|
|
"--version", version,
|
|
|
|
"--install-location", installLocation,
|
|
|
|
"--scripts", scriptsLocation,
|
|
|
|
outFilePath)
|
|
|
|
.Execute()
|
|
|
|
.EnsureSuccessful();
|
|
|
|
|
|
|
|
return c.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|