dotnet-installer/scripts/dotnet-cli-build/DebTargets.cs

202 lines
7.9 KiB
C#
Raw Normal View History

2016-03-15 23:41:18 +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 DebTargets
{
[Target(nameof(GenerateSharedHostDeb),
nameof(GenerateSharedFrameworkDeb),
nameof(GenerateSdkDeb))]
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult GenerateDebs(BuildTargetContext c)
{
return c.Success();
}
[Target(nameof(InstallSharedFramework))]
2016-03-15 23:41:18 +00:00
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult GenerateSdkDeb(BuildTargetContext c)
{
var channel = c.BuildContext.Get<string>("Channel").ToLower();
var packageName = Monikers.GetSdkDebianPackageName(c);
2016-03-24 23:35:42 +00:00
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
2016-03-15 23:41:18 +00:00
var debFile = c.BuildContext.Get<string>("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";
var sdkPublishRoot = c.BuildContext.Get<string>("CLISDKRoot");
var sharedFxDebianPackageName = Monikers.GetDebianSharedFrameworkPackageName(c);
2016-03-15 23:41:18 +00:00
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", sdkPublishRoot,
"-o", debFile,
2016-04-28 18:35:31 +00:00
"-p", packageName,
"-b", Monikers.CLISdkBrandName,
"-m", manPagesDir,
"--framework-debian-package-name", sharedFxDebianPackageName,
"--framework-nuget-name", Monikers.SharedFrameworkName,
"--framework-nuget-version", c.BuildContext.Get<string>("SharedFrameworkNugetVersion"),
"--previous-version-url", previousVersionURL,
"--obj-root", objRoot)
2016-03-15 23:41:18 +00:00
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult GenerateSharedHostDeb(BuildTargetContext c)
{
var packageName = Monikers.GetDebianSharedHostPackageName(c);
2016-03-24 23:35:42 +00:00
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
2016-03-15 23:41:18 +00:00
var inputRoot = c.BuildContext.Get<string>("SharedHostPublishRoot");
var debFile = c.BuildContext.Get<string>("SharedHostInstallerFile");
var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sharedhost");
var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages");
2016-03-15 23:41:18 +00:00
if (Directory.Exists(objRoot))
{
Directory.Delete(objRoot, true);
}
Directory.CreateDirectory(objRoot);
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-sharedhost-debian.sh"),
2016-04-28 18:35:31 +00:00
"--input", inputRoot, "--output", debFile, "-b", Monikers.SharedFxBrandName,
"--obj-root", objRoot, "--version", version, "-m", manPagesDir)
2016-03-15 23:41:18 +00:00
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target(nameof(InstallSharedHost))]
2016-03-15 23:41:18 +00:00
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult GenerateSharedFrameworkDeb(BuildTargetContext c)
{
var packageName = Monikers.GetDebianSharedFrameworkPackageName(c);
2016-03-24 23:35:42 +00:00
var version = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
2016-03-15 23:41:18 +00:00
var inputRoot = c.BuildContext.Get<string>("SharedFrameworkPublishRoot");
var debFile = c.BuildContext.Get<string>("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"),
2016-04-28 18:35:31 +00:00
"--input", inputRoot, "--output", debFile, "--package-name", packageName, "-b", Monikers.SharedFxBrandName,
2016-03-15 23:41:18 +00:00
"--framework-nuget-name", Monikers.SharedFrameworkName,
"--framework-nuget-version", c.BuildContext.Get<string>("SharedFrameworkNugetVersion"),
"--obj-root", objRoot, "--version", version)
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target(nameof(InstallSDK),
2016-03-15 23:41:18 +00:00
nameof(RunE2ETest),
nameof(RemovePackages))]
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult TestDebInstaller(BuildTargetContext c)
{
return c.Success();
}
[Target]
public static BuildTargetResult InstallSharedHost(BuildTargetContext c)
2016-03-15 23:41:18 +00:00
{
InstallPackage(c.BuildContext.Get<string>("SharedHostInstallerFile"));
2016-03-15 23:41:18 +00:00
return c.Success();
}
Extract dotnet-compile-fsc into a standalone command Add basic Tests for dotnet-compile-fsc Package Targets execute before TestTargets. Use Generated Nuget Packages in TestTargets. Generate Nuget packages on all platforms, and in C# Fix bug in dotnet-restore, change fsharp new template, add support for native assets in DependencyContextCsvReader copy fsc.exe to temp directory instead of package cache fix rebase error fix issue fixes fixes fix temporarily disable debian package e2e testing fixes bump fsc version update fsc version fix rebase errors WIP update fsc tool WIP, rebased and working again, need to solve issues with System.CommandLine Working state for packaged, command, fsc.exe bugging out with dlopen(, 1): no suitable image found. execute fsc like a unpublished standalone app fixup after rebase working? internet is out working cleanup More cleanup, and run the debian package tests during the Test phase of the build. update FSharp Test Projects NetStandard Library Version Update Version Suffix when packing TestPackages. This will enable packing with the right dependency versions on Windows. update dotnet-test version Undo the reordering of the build fix test package project pathsj ignore net451 build failures for test packages which we need to build on non-windows update dependency of desktop test app add dotnetcli feed to nuget config for fsharp dotnet new update deps after rebase update dependency of dotnet-compile-fsc pass args before commandPath when using muxer for tools adjust testpackage cleaning not to clean packages which are also generated as part of the product from the nuget cache. undo Pass projectJson to pack instead of using WorkingDirectory fix path separators using depsjsoncommandresolver on windows, fix building only specific frameworks for testpackages on non-windows. PR Feedback rebase overwrite fsc runtimeconfig
2016-03-12 00:41:00 +00:00
[Target(nameof(InstallSharedHost))]
public static BuildTargetResult InstallSharedFramework(BuildTargetContext c)
{
InstallPackage(c.BuildContext.Get<string>("SharedFrameworkInstallerFile"));
return c.Success();
}
Extract dotnet-compile-fsc into a standalone command Add basic Tests for dotnet-compile-fsc Package Targets execute before TestTargets. Use Generated Nuget Packages in TestTargets. Generate Nuget packages on all platforms, and in C# Fix bug in dotnet-restore, change fsharp new template, add support for native assets in DependencyContextCsvReader copy fsc.exe to temp directory instead of package cache fix rebase error fix issue fixes fixes fix temporarily disable debian package e2e testing fixes bump fsc version update fsc version fix rebase errors WIP update fsc tool WIP, rebased and working again, need to solve issues with System.CommandLine Working state for packaged, command, fsc.exe bugging out with dlopen(, 1): no suitable image found. execute fsc like a unpublished standalone app fixup after rebase working? internet is out working cleanup More cleanup, and run the debian package tests during the Test phase of the build. update FSharp Test Projects NetStandard Library Version Update Version Suffix when packing TestPackages. This will enable packing with the right dependency versions on Windows. update dotnet-test version Undo the reordering of the build fix test package project pathsj ignore net451 build failures for test packages which we need to build on non-windows update dependency of desktop test app add dotnetcli feed to nuget config for fsharp dotnet new update deps after rebase update dependency of dotnet-compile-fsc pass args before commandPath when using muxer for tools adjust testpackage cleaning not to clean packages which are also generated as part of the product from the nuget cache. undo Pass projectJson to pack instead of using WorkingDirectory fix path separators using depsjsoncommandresolver on windows, fix building only specific frameworks for testpackages on non-windows. PR Feedback rebase overwrite fsc runtimeconfig
2016-03-12 00:41:00 +00:00
[Target(nameof(InstallSharedFramework))]
public static BuildTargetResult InstallSDK(BuildTargetContext c)
{
InstallPackage(c.BuildContext.Get<string>("SdkInstallerFile"));
2016-03-15 23:41:18 +00:00
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult RunE2ETest(BuildTargetContext c)
{
Directory.SetCurrentDirectory(Path.Combine(Dirs.RepoRoot, "test", "EndToEnd"));
Cmd("dotnet", "build")
.Execute()
.EnsureSuccessful();
var testResultsPath = Path.Combine(Dirs.Output, "obj", "debian", "test", "debian-endtoend-testResults.xml");
Cmd("dotnet", "test", "-xml", testResultsPath)
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.Ubuntu)]
public static BuildTargetResult RemovePackages(BuildTargetContext c)
{
IEnumerable<string> orderedPackageNames = new List<string>()
2016-03-15 23:41:18 +00:00
{
Monikers.GetSdkDebianPackageName(c),
2016-03-15 23:41:18 +00:00
Monikers.GetDebianSharedFrameworkPackageName(c),
Monikers.GetDebianSharedHostPackageName(c)
};
foreach(var packageName in orderedPackageNames)
2016-03-15 23:41:18 +00:00
{
RemovePackage(packageName);
2016-03-15 23:41:18 +00:00
}
return c.Success();
}
private static void InstallPackage(string packagePath)
{
Cmd("sudo", "dpkg", "-i", packagePath)
.Execute()
.EnsureSuccessful();
}
private static void RemovePackage(string packageName)
{
Cmd("sudo", "dpkg", "-r", packageName)
.Execute()
.EnsureSuccessful();
}
2016-03-15 23:41:18 +00:00
}
}