Convert all CLI build targets to MSBuild Tasks. (#3690)
This commit is contained in:
parent
0c9617559e
commit
15b2a9d9db
17 changed files with 687 additions and 565 deletions
|
@ -1,12 +1,13 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
VisualStudioVersion = 14.0.25402.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED2FE3E2-F7E7-4389-8231-B65123F2076F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5A29E8E3-A0FC-4C57-81DD-297B56D1A119}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build.proj = build.proj
|
||||
global.json = global.json
|
||||
NuGet.Config = NuGet.Config
|
||||
EndProjectSection
|
||||
|
|
29
build.proj
29
build.proj
|
@ -11,39 +11,44 @@
|
|||
<PlatformScriptExtension Condition=" '$(OS)' == 'Windows_NT' ">.ps1</PlatformScriptExtension>
|
||||
<PlatformScriptExtension Condition=" '$(OS)' != 'Windows_NT' ">.sh</PlatformScriptExtension>
|
||||
|
||||
<PlatformExeExtension Condition=" '$(OS)' == 'Windows_NT' ">.exe</PlatformExeExtension>
|
||||
<PlatformExeExtension Condition=" '$(OS)' != 'Windows_NT' "></PlatformExeExtension>
|
||||
<NoRunArg Condition=" '$(OS)' == 'Windows_NT' ">-NoRun</NoRunArg>
|
||||
<NoRunArg Condition=" '$(OS)' != 'Windows_NT' ">--norun</NoRunArg>
|
||||
|
||||
<CLITargets Condition=" '$(CLITargets)' == '' ">Prepare;Compile;Test;Package;Publish</CLITargets>
|
||||
<CLIBuildFileName>$(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/bin/dotnet-cli-build</CLIBuildFileName>
|
||||
<CLIBuildDll>$(CLIBuildFileName).dll</CLIBuildDll>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="BuildDotnetCliBuildFramework" Inputs="" Outputs="">
|
||||
<Exec Command="$(PlatformScriptHost) $(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/build$(PlatformScriptExtension)" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
|
||||
<PropertyGroup>
|
||||
<CliBuildFrameworkExe>$(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/bin/dotnet-cli-build$(PlatformExeExtension)</CliBuildFrameworkExe>
|
||||
</PropertyGroup>
|
||||
<Exec Command="$(PlatformScriptHost) $(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/build$(PlatformScriptExtension) $(NoRunArg)" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
|
||||
</Target>
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework;$(CLITargets)" Name="BuildTheWholeCli"></Target>
|
||||
<Target DependsOnTargets="$(CLITargets)" Name="BuildTheWholeCli"></Target>
|
||||
|
||||
<UsingTask TaskName="PrepareTargets" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="CompileTargets" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="TestTargets" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="PackageTargets" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="PublishTargets" AssemblyFile="$(CLIBuildDll)" />
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Prepare">
|
||||
<Exec Command="$(CliBuildFrameworkExe) Prepare" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
|
||||
<PrepareTargets />
|
||||
</Target>
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Compile">
|
||||
<Exec Command="$(CliBuildFrameworkExe) Compile" WorkingDirectory="$(MSBuildThisFileDirectory)" />
|
||||
<CompileTargets />
|
||||
</Target>
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Test">
|
||||
<Exec Command="$(CliBuildFrameworkExe) Test" WorkingDirectory="$(MSBuildThisFileDirectory)" />
|
||||
<TestTargets />
|
||||
</Target>
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Package">
|
||||
<Exec Command="$(CliBuildFrameworkExe) Package" WorkingDirectory="$(MSBuildThisFileDirectory)" />
|
||||
<PackageTargets />
|
||||
</Target>
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Publish">
|
||||
<Exec Command="$(CliBuildFrameworkExe) Publish" WorkingDirectory="$(MSBuildThisFileDirectory)" />
|
||||
<PublishTargets />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -50,6 +50,11 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
return UseTargets(CollectTargets(typeof(T)));
|
||||
}
|
||||
|
||||
public BuildContext CreateBuildContext()
|
||||
{
|
||||
return new BuildContext(_targets, Directory.GetCurrentDirectory());
|
||||
}
|
||||
|
||||
public int Run(string[] args)
|
||||
{
|
||||
var targets = new[] { BuildContext.DefaultTarget };
|
||||
|
@ -68,7 +73,7 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
}
|
||||
}
|
||||
|
||||
var context = new BuildContext(_targets, Directory.GetCurrentDirectory());
|
||||
var context = CreateBuildContext();
|
||||
BuildTargetResult result = null;
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
|
||||
|
@ -105,6 +106,11 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
return IsPlatform(platform) && (version == null || IsVersion(version));
|
||||
}
|
||||
|
||||
public static bool IsAnyPlatform(params BuildPlatform[] platforms)
|
||||
{
|
||||
return platforms.Any(p => IsPlatform(p));
|
||||
}
|
||||
|
||||
public static bool IsPlatform(BuildPlatform platform)
|
||||
{
|
||||
switch (platform)
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -13,7 +11,7 @@ using static Microsoft.DotNet.Cli.Build.FS;
|
|||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class CompileTargets
|
||||
public class CompileTargets : Task
|
||||
{
|
||||
public static readonly bool IsWinx86 = CurrentPlatform.IsWindows && CurrentArchitecture.Isx86;
|
||||
|
||||
|
@ -58,20 +56,24 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion);
|
||||
|
||||
// Updates the stage 2 with recent changes.
|
||||
[Target(nameof(PrepareTargets.Init), nameof(CompileStage2))]
|
||||
public static BuildTargetResult UpdateBuild(BuildTargetContext c)
|
||||
public override bool Execute()
|
||||
{
|
||||
return c.Success();
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<CompileTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
return Compile(c).Success;
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init), nameof(CompileStage1), nameof(CompileStage2))]
|
||||
[Target]
|
||||
public static BuildTargetResult Compile(BuildTargetContext c)
|
||||
{
|
||||
PrepareTargets.Init(c);
|
||||
CompileStage1(c);
|
||||
CompileStage2(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init))]
|
||||
public static BuildTargetResult CompileStage1(BuildTargetContext c)
|
||||
{
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
|
||||
|
@ -94,7 +96,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return result;
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init))]
|
||||
public static BuildTargetResult CompileStage2(BuildTargetContext c)
|
||||
{
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
|
|
|
@ -12,71 +12,80 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public class DebTargets
|
||||
{
|
||||
[Target(nameof(GenerateSdkDeb))]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult GenerateDebs(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
GenerateSdkDeb(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(InstallSharedFramework))]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult GenerateSdkDeb(BuildTargetContext c)
|
||||
{
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
if (DebuildNotPresent())
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||
var packageName = CliMonikers.GetSdkDebianPackageName(c);
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
|
||||
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(CliDependencyVersions.SharedFrameworkVersion);
|
||||
InstallSharedFramework(c);
|
||||
|
||||
var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sdk");
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
if (DebuildNotPresent())
|
||||
{
|
||||
c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
if (Directory.Exists(objRoot))
|
||||
{
|
||||
Directory.Delete(objRoot, true);
|
||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||
var packageName = CliMonikers.GetSdkDebianPackageName(c);
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
|
||||
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(CliDependencyVersions.SharedFrameworkVersion);
|
||||
|
||||
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,
|
||||
"-p", packageName,
|
||||
"-b", Monikers.CLISdkBrandName,
|
||||
"-m", manPagesDir,
|
||||
"--framework-debian-package-name", sharedFxDebianPackageName,
|
||||
"--framework-nuget-name", Monikers.SharedFrameworkName,
|
||||
"--framework-nuget-version", CliDependencyVersions.SharedFrameworkVersion,
|
||||
"--previous-version-url", previousVersionURL,
|
||||
"--obj-root", objRoot)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(objRoot);
|
||||
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"),
|
||||
"-v", version,
|
||||
"-i", sdkPublishRoot,
|
||||
"-o", debFile,
|
||||
"-p", packageName,
|
||||
"-b", Monikers.CLISdkBrandName,
|
||||
"-m", manPagesDir,
|
||||
"--framework-debian-package-name", sharedFxDebianPackageName,
|
||||
"--framework-nuget-name", Monikers.SharedFrameworkName,
|
||||
"--framework-nuget-version", CliDependencyVersions.SharedFrameworkVersion,
|
||||
"--previous-version-url", previousVersionURL,
|
||||
"--obj-root", objRoot)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(InstallSDK),
|
||||
nameof(RunE2ETest),
|
||||
nameof(RemovePackages))]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult TestDebInstaller(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
InstallSDK(c);
|
||||
RunE2ETest(c);
|
||||
RemovePackages(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult InstallSharedHost(BuildTargetContext c)
|
||||
{
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
|
@ -93,9 +102,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(InstallSharedHost))]
|
||||
public static BuildTargetResult InstallHostFxr(BuildTargetContext c)
|
||||
{
|
||||
InstallSharedHost(c);
|
||||
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
|
@ -110,9 +120,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(InstallHostFxr))]
|
||||
public static BuildTargetResult InstallSharedFramework(BuildTargetContext c)
|
||||
{
|
||||
InstallHostFxr(c);
|
||||
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
|
@ -127,9 +138,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(InstallSharedFramework))]
|
||||
public static BuildTargetResult InstallSDK(BuildTargetContext c)
|
||||
{
|
||||
InstallSharedFramework(c);
|
||||
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
|
@ -144,58 +156,60 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult RunE2ETest(BuildTargetContext c)
|
||||
{
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
if (DebuildNotPresent())
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}");
|
||||
return c.Success();
|
||||
}
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
if (DebuildNotPresent())
|
||||
{
|
||||
c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
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();
|
||||
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)
|
||||
{
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
if (DebuildNotPresent())
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}");
|
||||
return c.Success();
|
||||
}
|
||||
// Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools
|
||||
// So we need to skip this target if the tools aren't present.
|
||||
// https://github.com/dotnet/core-setup/issues/167
|
||||
if (DebuildNotPresent())
|
||||
{
|
||||
c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
IEnumerable<string> orderedPackageNames = new List<string>()
|
||||
{
|
||||
CliMonikers.GetSdkDebianPackageName(c),
|
||||
Monikers.GetDebianSharedFrameworkPackageName(CliDependencyVersions.SharedFrameworkVersion),
|
||||
Monikers.GetDebianHostFxrPackageName(CliDependencyVersions.HostFxrVersion),
|
||||
Monikers.GetDebianSharedHostPackageName(c)
|
||||
};
|
||||
|
||||
foreach(var packageName in orderedPackageNames)
|
||||
{
|
||||
RemovePackage(packageName);
|
||||
IEnumerable<string> orderedPackageNames = new List<string>()
|
||||
{
|
||||
CliMonikers.GetSdkDebianPackageName(c),
|
||||
Monikers.GetDebianSharedFrameworkPackageName(CliDependencyVersions.SharedFrameworkVersion),
|
||||
Monikers.GetDebianHostFxrPackageName(CliDependencyVersions.HostFxrVersion),
|
||||
Monikers.GetDebianSharedHostPackageName(c)
|
||||
};
|
||||
|
||||
foreach (var packageName in orderedPackageNames)
|
||||
{
|
||||
RemovePackage(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
|
|
|
@ -4,19 +4,19 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public class InstallerTargets
|
||||
{
|
||||
[Target(nameof(MsiTargets.GenerateMsis),
|
||||
nameof(MsiTargets.GenerateBundles),
|
||||
nameof(PkgTargets.GeneratePkgs),
|
||||
nameof(DebTargets.GenerateDebs))]
|
||||
public static BuildTargetResult GenerateInstaller(BuildTargetContext c)
|
||||
{
|
||||
MsiTargets.GenerateMsisAndBundles(c);
|
||||
PkgTargets.GeneratePkgs(c);
|
||||
DebTargets.GenerateDebs(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(DebTargets.TestDebInstaller))]
|
||||
public static BuildTargetResult TestInstaller(BuildTargetContext c)
|
||||
|
||||
{
|
||||
DebTargets.TestDebInstaller(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,75 +75,78 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult InitMsi(BuildTargetContext c)
|
||||
{
|
||||
SdkBundle = c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile");
|
||||
SdkMsi = Path.ChangeExtension(SdkBundle, "msi");
|
||||
SdkEngine = GetEngineName(SdkBundle);
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
SdkBundle = c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile");
|
||||
SdkMsi = Path.ChangeExtension(SdkBundle, "msi");
|
||||
SdkEngine = GetEngineName(SdkBundle);
|
||||
|
||||
SharedFrameworkMsi = Path.ChangeExtension(c.BuildContext.Get<string>("SharedFrameworkInstallerFile"), "msi");
|
||||
HostFxrMsi = Path.ChangeExtension(c.BuildContext.Get<string>("HostFxrInstallerFile"), "msi");
|
||||
SharedHostMsi = Path.ChangeExtension(c.BuildContext.Get<string>("SharedHostInstallerFile"), "msi");
|
||||
SharedFrameworkMsi = Path.ChangeExtension(c.BuildContext.Get<string>("SharedFrameworkInstallerFile"), "msi");
|
||||
HostFxrMsi = Path.ChangeExtension(c.BuildContext.Get<string>("HostFxrInstallerFile"), "msi");
|
||||
SharedHostMsi = Path.ChangeExtension(c.BuildContext.Get<string>("SharedHostInstallerFile"), "msi");
|
||||
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
CliDisplayVersion = buildVersion.SimpleVersion;
|
||||
CliNugetVersion = buildVersion.NuGetVersion;
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
CliDisplayVersion = buildVersion.SimpleVersion;
|
||||
CliNugetVersion = buildVersion.NuGetVersion;
|
||||
|
||||
AcquireWix(c);
|
||||
}
|
||||
|
||||
AcquireWix(c);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi),
|
||||
nameof(GenerateCliSdkMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateMsis(BuildTargetContext c)
|
||||
public static BuildTargetResult GenerateMsisAndBundles(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
InitMsi(c);
|
||||
GenerateCliSdkMsi(c);
|
||||
GenerateCliSdkBundle(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi),
|
||||
nameof(GenerateCliSdkBundle))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateBundles(BuildTargetContext c)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateCliSdkMsi(BuildTargetContext c)
|
||||
{
|
||||
var cliSdkRoot = c.BuildContext.Get<string>("CLISDKRoot");
|
||||
var upgradeCode = Utils.GenerateGuidFromName(SdkMsi).ToString().ToUpper();
|
||||
var cliSdkBrandName = $"'{Monikers.CLISdkBrandName}'";
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var cliSdkRoot = c.BuildContext.Get<string>("CLISDKRoot");
|
||||
var upgradeCode = Utils.GenerateGuidFromName(SdkMsi).ToString().ToUpper();
|
||||
var cliSdkBrandName = $"'{Monikers.CLISdkBrandName}'";
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "clisdk", "generatemsi.ps1"),
|
||||
cliSdkRoot, SdkMsi, WixRoot, cliSdkBrandName, MsiVersion, CliDisplayVersion, CliNugetVersion, upgradeCode, Arch)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "clisdk", "generatemsi.ps1"),
|
||||
cliSdkRoot, SdkMsi, WixRoot, cliSdkBrandName, MsiVersion, CliDisplayVersion, CliNugetVersion, upgradeCode, Arch)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateCliSdkBundle(BuildTargetContext c)
|
||||
{
|
||||
var upgradeCode = Utils.GenerateGuidFromName(SdkBundle).ToString().ToUpper();
|
||||
var cliSdkBrandName = $"'{Monikers.CLISdkBrandName}'";
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var upgradeCode = Utils.GenerateGuidFromName(SdkBundle).ToString().ToUpper();
|
||||
var cliSdkBrandName = $"'{Monikers.CLISdkBrandName}'";
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "clisdk", "generatebundle.ps1"),
|
||||
SdkMsi, SharedFrameworkMsi, HostFxrMsi, SharedHostMsi, SdkBundle, WixRoot, cliSdkBrandName, MsiVersion, CliDisplayVersion, CliNugetVersion, upgradeCode, Arch)
|
||||
.EnvironmentVariable("Stage2Dir", Dirs.Stage2)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "clisdk", "generatebundle.ps1"),
|
||||
SdkMsi, SharedFrameworkMsi, HostFxrMsi, SharedHostMsi, SdkBundle, WixRoot, cliSdkBrandName, MsiVersion, CliDisplayVersion, CliNugetVersion, upgradeCode, Arch)
|
||||
.EnvironmentVariable("Stage2Dir", Dirs.Stage2)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
// TODO: The following "Engine" tasks need to be separate MSBuild targets so the Windows
|
||||
// VSO build can invoke them directly for signing.
|
||||
[Target(nameof(MsiTargets.InitMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c)
|
||||
|
|
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public static class PackageTargets
|
||||
public class PackageTargets : Task
|
||||
{
|
||||
public static readonly string[] ProjectsToPack = new string[]
|
||||
{
|
||||
|
@ -26,32 +27,44 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
"Microsoft.Extensions.Testing.Abstractions"
|
||||
};
|
||||
|
||||
[Target(nameof(PackageTargets.CopyCLISDKLayout),
|
||||
nameof(PackageTargets.CopySharedHostLayout),
|
||||
nameof(PackageTargets.CopyHostFxrLayout),
|
||||
nameof(PackageTargets.CopySharedFxLayout),
|
||||
nameof(PackageTargets.CopyCombinedFrameworkSDKHostLayout),
|
||||
nameof(PackageTargets.CopyCombinedFrameworkSDKLayout))]
|
||||
public override bool Execute()
|
||||
{
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<PackageTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
return Package(c).Success;
|
||||
}
|
||||
|
||||
public static BuildTargetResult InitPackage(BuildTargetContext c)
|
||||
{
|
||||
CopyCLISDKLayout(c);
|
||||
CopySharedHostLayout(c);
|
||||
CopyHostFxrLayout(c);
|
||||
CopySharedFxLayout(c);
|
||||
CopyCombinedFrameworkSDKHostLayout(c);
|
||||
CopyCombinedFrameworkSDKLayout(c);
|
||||
|
||||
Directory.CreateDirectory(Dirs.Packages);
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PrepareTargets.Init),
|
||||
nameof(PackageTargets.InitPackage),
|
||||
nameof(PackageTargets.GenerateVersionBadge),
|
||||
nameof(PackageTargets.GenerateCompressedFile),
|
||||
nameof(InstallerTargets.GenerateInstaller),
|
||||
nameof(PackageTargets.GenerateNugetPackages),
|
||||
nameof(InstallerTargets.TestInstaller))]
|
||||
[Environment("DOTNET_BUILD_SKIP_PACKAGING", null, "0", "false")]
|
||||
[Target]
|
||||
public static BuildTargetResult Package(BuildTargetContext c)
|
||||
{
|
||||
if (!EnvVars.GetBool("DOTNET_BUILD_SKIP_PACKAGING"))
|
||||
{
|
||||
PrepareTargets.Init(c);
|
||||
InitPackage(c);
|
||||
GenerateVersionBadge(c);
|
||||
GenerateCompressedFile(c);
|
||||
InstallerTargets.GenerateInstaller(c);
|
||||
GenerateNugetPackages(c);
|
||||
InstallerTargets.TestInstaller(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult GenerateVersionBadge(BuildTargetContext c)
|
||||
{
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
|
@ -65,7 +78,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CopyCLISDKLayout(BuildTargetContext c)
|
||||
{
|
||||
var cliSdkRoot = Path.Combine(Dirs.Output, "obj", "clisdk");
|
||||
|
@ -82,7 +94,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CopySharedHostLayout(BuildTargetContext c)
|
||||
{
|
||||
var sharedHostRoot = Path.Combine(Dirs.Output, "obj", "sharedHost");
|
||||
|
@ -104,7 +115,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CopyHostFxrLayout(BuildTargetContext c)
|
||||
{
|
||||
var hostFxrRoot = Path.Combine(Dirs.Output, "obj", "hostFxr");
|
||||
|
@ -121,7 +131,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CopySharedFxLayout(BuildTargetContext c)
|
||||
{
|
||||
var sharedFxRoot = Path.Combine(Dirs.Output, "obj", "sharedFx");
|
||||
|
@ -138,7 +147,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CopyCombinedFrameworkSDKHostLayout(BuildTargetContext c)
|
||||
{
|
||||
var combinedRoot = Path.Combine(Dirs.Output, "obj", "combined-framework-sdk-host");
|
||||
|
@ -163,7 +171,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CopyCombinedFrameworkSDKLayout(BuildTargetContext c)
|
||||
{
|
||||
var combinedRoot = Path.Combine(Dirs.Output, "obj", "combined-framework-sdk");
|
||||
|
@ -182,35 +189,38 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.GenerateZip), nameof(PackageTargets.GenerateTarBall))]
|
||||
public static BuildTargetResult GenerateCompressedFile(BuildTargetContext c)
|
||||
{
|
||||
GenerateZip(c);
|
||||
GenerateTarBall(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.InitPackage))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateZip(BuildTargetContext c)
|
||||
{
|
||||
CreateZipFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile"));
|
||||
CreateZipFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKCompressedFile"));
|
||||
CreateZipFromDirectory(Path.Combine(Dirs.Stage2Symbols, "sdk"), c.BuildContext.Get<string>("SdkSymbolsCompressedFile"));
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
CreateZipFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile"));
|
||||
CreateZipFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKCompressedFile"));
|
||||
CreateZipFromDirectory(Path.Combine(Dirs.Stage2Symbols, "sdk"), c.BuildContext.Get<string>("SdkSymbolsCompressedFile"));
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PackageTargets.InitPackage))]
|
||||
[BuildPlatforms(BuildPlatform.Unix)]
|
||||
public static BuildTargetResult GenerateTarBall(BuildTargetContext c)
|
||||
{
|
||||
CreateTarBallFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile"));
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Unix))
|
||||
{
|
||||
CreateTarBallFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile"));
|
||||
|
||||
CreateTarBallFromDirectory(Path.Combine(Dirs.Stage2Symbols, "sdk"), c.BuildContext.Get<string>("SdkSymbolsCompressedFile"));
|
||||
CreateTarBallFromDirectory(Path.Combine(Dirs.Stage2Symbols, "sdk"), c.BuildContext.Get<string>("SdkSymbolsCompressedFile"));
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult GenerateNugetPackages(BuildTargetContext c)
|
||||
{
|
||||
var versionSuffix = c.BuildContext.Get<BuildVersion>("BuildVersion").CommitCountString;
|
||||
|
|
|
@ -22,102 +22,111 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public static string CLISdkNugetVersion { get; set; }
|
||||
public static string HostFxrComponentId { get; set; }
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.OSX)]
|
||||
public static BuildTargetResult InitPkg(BuildTargetContext c)
|
||||
{
|
||||
PkgsIntermediateDir = Path.Combine(Dirs.Packages, "intermediate");
|
||||
Directory.CreateDirectory(PkgsIntermediateDir);
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.OSX))
|
||||
{
|
||||
PkgsIntermediateDir = Path.Combine(Dirs.Packages, "intermediate");
|
||||
Directory.CreateDirectory(PkgsIntermediateDir);
|
||||
|
||||
SharedHostComponentId = $"com.microsoft.dotnet.sharedhost.component.osx.x64";
|
||||
HostFxrComponentId = $"com.microsoft.dotnet.hostfxr.component.osx.x64";
|
||||
SharedHostComponentId = $"com.microsoft.dotnet.sharedhost.component.osx.x64";
|
||||
HostFxrComponentId = $"com.microsoft.dotnet.hostfxr.component.osx.x64";
|
||||
|
||||
string sharedFrameworkNugetName = Monikers.SharedFrameworkName;
|
||||
SharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion;
|
||||
SharedFxComponentId = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{SharedFrameworkNugetVersion}.component.osx.x64";
|
||||
SharedFxPkgId = $"com.microsoft.dotnet.{sharedFrameworkNugetName}.{SharedFrameworkNugetVersion}.osx.x64";
|
||||
string sharedFrameworkNugetName = Monikers.SharedFrameworkName;
|
||||
SharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion;
|
||||
SharedFxComponentId = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetName}.{SharedFrameworkNugetVersion}.component.osx.x64";
|
||||
SharedFxPkgId = $"com.microsoft.dotnet.{sharedFrameworkNugetName}.{SharedFrameworkNugetVersion}.osx.x64";
|
||||
|
||||
CLISdkNugetVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
|
||||
CLISdkComponentId = $"com.microsoft.dotnet.dev.{CLISdkNugetVersion}.component.osx.x64";
|
||||
CLISdkPkgId = $"com.microsoft.dotnet.dev.{CLISdkNugetVersion}.osx.x64";
|
||||
CLISdkNugetVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
|
||||
CLISdkComponentId = $"com.microsoft.dotnet.dev.{CLISdkNugetVersion}.component.osx.x64";
|
||||
CLISdkPkgId = $"com.microsoft.dotnet.dev.{CLISdkNugetVersion}.osx.x64";
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(InitPkg), nameof(GenerateCLISdkProductArchive))]
|
||||
[BuildPlatforms(BuildPlatform.OSX)]
|
||||
public static BuildTargetResult GeneratePkgs(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.OSX))
|
||||
{
|
||||
InitPkg(c);
|
||||
GenerateCLISdkProductArchive(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(GenerateCLISdkPkg))]
|
||||
[BuildPlatforms(BuildPlatform.OSX)]
|
||||
public static BuildTargetResult GenerateCLISdkProductArchive(BuildTargetContext c)
|
||||
{
|
||||
string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "clisdk", "resources");
|
||||
string outFilePath = Path.Combine(Dirs.Packages, c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile"));
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.OSX))
|
||||
{
|
||||
GenerateCLISdkPkg(c);
|
||||
|
||||
// Copy SharedFX and host installers in the correct place
|
||||
var sharedFrameworkPkgIntermediatePath = Path.Combine(PkgsIntermediateDir, $"{SharedFxComponentId}.pkg");
|
||||
var sharedHostPkgIntermediatePath = Path.Combine(PkgsIntermediateDir, $"{SharedHostComponentId}.pkg");
|
||||
var hostFxrPkgIntermediatePath = Path.Combine(PkgsIntermediateDir, $"{HostFxrComponentId}.pkg");
|
||||
string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "clisdk", "resources");
|
||||
string outFilePath = Path.Combine(Dirs.Packages, c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile"));
|
||||
|
||||
// Copy SharedFX and host installers in the correct place
|
||||
var sharedFrameworkPkgIntermediatePath = Path.Combine(PkgsIntermediateDir, $"{SharedFxComponentId}.pkg");
|
||||
var sharedHostPkgIntermediatePath = Path.Combine(PkgsIntermediateDir, $"{SharedHostComponentId}.pkg");
|
||||
var hostFxrPkgIntermediatePath = Path.Combine(PkgsIntermediateDir, $"{HostFxrComponentId}.pkg");
|
||||
|
||||
|
||||
File.Copy(c.BuildContext.Get<string>("SharedFrameworkInstallerFile"), sharedFrameworkPkgIntermediatePath, true);
|
||||
File.Copy(c.BuildContext.Get<string>("SharedHostInstallerFile"), sharedHostPkgIntermediatePath, true);
|
||||
File.Copy(c.BuildContext.Get<string>("HostFxrInstallerFile"), hostFxrPkgIntermediatePath, true);
|
||||
File.Copy(c.BuildContext.Get<string>("SharedFrameworkInstallerFile"), sharedFrameworkPkgIntermediatePath, true);
|
||||
File.Copy(c.BuildContext.Get<string>("SharedHostInstallerFile"), sharedHostPkgIntermediatePath, true);
|
||||
File.Copy(c.BuildContext.Get<string>("HostFxrInstallerFile"), hostFxrPkgIntermediatePath, true);
|
||||
|
||||
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("{SharedFxComponentId}", SharedFxComponentId)
|
||||
.Replace("{SharedHostComponentId}", SharedHostComponentId)
|
||||
.Replace("{HostFxrComponentId}", HostFxrComponentId)
|
||||
.Replace("{CLISdkComponentId}", CLISdkComponentId)
|
||||
.Replace("{CLISdkNugetVersion}", CLISdkNugetVersion)
|
||||
.Replace("{CLISdkBrandName}", Monikers.CLISdkBrandName)
|
||||
.Replace("{SharedFxBrandName}", Monikers.SharedFxBrandName)
|
||||
.Replace("{SharedHostBrandName}", Monikers.SharedHostBrandName)
|
||||
.Replace("{HostFxrBrandName}", Monikers.HostFxrBrandName);
|
||||
File.WriteAllText(distributionPath, formattedDistContents);
|
||||
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("{SharedFxComponentId}", SharedFxComponentId)
|
||||
.Replace("{SharedHostComponentId}", SharedHostComponentId)
|
||||
.Replace("{HostFxrComponentId}", HostFxrComponentId)
|
||||
.Replace("{CLISdkComponentId}", CLISdkComponentId)
|
||||
.Replace("{CLISdkNugetVersion}", CLISdkNugetVersion)
|
||||
.Replace("{CLISdkBrandName}", Monikers.CLISdkBrandName)
|
||||
.Replace("{SharedFxBrandName}", Monikers.SharedFxBrandName)
|
||||
.Replace("{SharedHostBrandName}", Monikers.SharedHostBrandName)
|
||||
.Replace("{HostFxrBrandName}", Monikers.HostFxrBrandName);
|
||||
File.WriteAllText(distributionPath, formattedDistContents);
|
||||
|
||||
Cmd("productbuild",
|
||||
"--version", CLISdkNugetVersion,
|
||||
"--identifier", CLISdkPkgId,
|
||||
"--package-path", PkgsIntermediateDir,
|
||||
"--resources", resourcePath,
|
||||
"--distribution", distributionPath,
|
||||
outFilePath)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
Cmd("productbuild",
|
||||
"--version", CLISdkNugetVersion,
|
||||
"--identifier", CLISdkPkgId,
|
||||
"--package-path", PkgsIntermediateDir,
|
||||
"--resources", resourcePath,
|
||||
"--distribution", distributionPath,
|
||||
outFilePath)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.OSX)]
|
||||
public static BuildTargetResult GenerateCLISdkPkg(BuildTargetContext c)
|
||||
{
|
||||
string outFilePath = Path.Combine(PkgsIntermediateDir, CLISdkComponentId + ".pkg");
|
||||
string installLocation = "/usr/local/share/dotnet";
|
||||
string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "clisdk", "scripts");
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.OSX))
|
||||
{
|
||||
string outFilePath = Path.Combine(PkgsIntermediateDir, CLISdkComponentId + ".pkg");
|
||||
string installLocation = "/usr/local/share/dotnet";
|
||||
string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "clisdk", "scripts");
|
||||
|
||||
Cmd("pkgbuild",
|
||||
"--root", c.BuildContext.Get<string>("CLISDKRoot"),
|
||||
"--identifier", CLISdkComponentId,
|
||||
"--version", CLISdkNugetVersion,
|
||||
"--install-location", installLocation,
|
||||
"--scripts", scriptsLocation,
|
||||
outFilePath)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
Cmd("pkgbuild",
|
||||
"--root", c.BuildContext.Get<string>("CLISDKRoot"),
|
||||
"--identifier", CLISdkComponentId,
|
||||
"--version", CLISdkNugetVersion,
|
||||
"--install-location", installLocation,
|
||||
"--scripts", scriptsLocation,
|
||||
outFilePath)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
|
|
@ -13,35 +13,71 @@ using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
|||
using static Microsoft.DotNet.Cli.Build.FS;
|
||||
using static Microsoft.DotNet.Cli.Build.Utils;
|
||||
using System.IO.Compression;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class PrepareTargets
|
||||
public class PrepareTargets : Task
|
||||
{
|
||||
[Target(nameof(Init), nameof(DownloadHostAndSharedFxArtifacts), nameof(RestorePackages), nameof(ZipTemplates))]
|
||||
public static BuildTargetResult Prepare(BuildTargetContext c) => c.Success();
|
||||
public override bool Execute()
|
||||
{
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<PrepareTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
[Target(nameof(CheckPrereqCmakePresent), nameof(CheckPlatformDependencies))]
|
||||
public static BuildTargetResult CheckPrereqs(BuildTargetContext c) => c.Success();
|
||||
return Prepare(c).Success;
|
||||
}
|
||||
|
||||
[Target(nameof(CheckCoreclrPlatformDependencies), nameof(CheckInstallerBuildPlatformDependencies))]
|
||||
public static BuildTargetResult CheckPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
[Target]
|
||||
public static BuildTargetResult Prepare(BuildTargetContext c)
|
||||
{
|
||||
Init(c);
|
||||
DownloadHostAndSharedFxArtifacts(c);
|
||||
RestorePackages(c);
|
||||
ZipTemplates(c);
|
||||
|
||||
[Target(nameof(CheckUbuntuCoreclrAndCoreFxDependencies), nameof(CheckCentOSCoreclrAndCoreFxDependencies))]
|
||||
public static BuildTargetResult CheckCoreclrPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(CheckUbuntuDebianPackageBuildDependencies))]
|
||||
public static BuildTargetResult CheckInstallerBuildPlatformDependencies(BuildTargetContext c) => c.Success();
|
||||
public static BuildTargetResult CheckPrereqs(BuildTargetContext c)
|
||||
{
|
||||
CheckPrereqCmakePresent(c);
|
||||
CheckPlatformDependencies(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckPlatformDependencies(BuildTargetContext c)
|
||||
{
|
||||
CheckCoreclrPlatformDependencies(c);
|
||||
CheckInstallerBuildPlatformDependencies(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckCoreclrPlatformDependencies(BuildTargetContext c)
|
||||
{
|
||||
CheckUbuntuCoreclrAndCoreFxDependencies(c);
|
||||
CheckCentOSCoreclrAndCoreFxDependencies(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckInstallerBuildPlatformDependencies(BuildTargetContext c)
|
||||
{
|
||||
CheckUbuntuDebianPackageBuildDependencies(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
// All major targets will depend on this in order to ensure variables are set up right if they are run independently
|
||||
[Target(
|
||||
nameof(GenerateVersions),
|
||||
nameof(CheckPrereqs),
|
||||
nameof(LocateStage0),
|
||||
nameof(ExpectedBuildArtifacts),
|
||||
nameof(SetTelemetryProfile))]
|
||||
public static BuildTargetResult Init(BuildTargetContext c)
|
||||
{
|
||||
GenerateVersions(c);
|
||||
CheckPrereqs(c);
|
||||
LocateStage0(c);
|
||||
ExpectedBuildArtifacts(c);
|
||||
SetTelemetryProfile(c);
|
||||
|
||||
var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION");
|
||||
|
||||
if (string.IsNullOrEmpty(configEnv))
|
||||
|
@ -60,7 +96,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult GenerateVersions(BuildTargetContext c)
|
||||
{
|
||||
var commitCount = GitUtils.GetCommitCount();
|
||||
|
@ -86,7 +121,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult ZipTemplates(BuildTargetContext c)
|
||||
{
|
||||
var templateDirectories = Directory.GetDirectories(
|
||||
|
@ -106,7 +140,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult LocateStage0(BuildTargetContext c)
|
||||
{
|
||||
// We should have been run in the repo root, so locate the stage 0 relative to current directory
|
||||
|
@ -131,7 +164,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c)
|
||||
{
|
||||
var config = Environment.GetEnvironmentVariable("CONFIGURATION");
|
||||
|
@ -158,13 +190,15 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(
|
||||
nameof(ExpectedBuildArtifacts),
|
||||
nameof(DownloadHostAndSharedFxArchives),
|
||||
nameof(DownloadHostAndSharedFxInstallers))]
|
||||
public static BuildTargetResult DownloadHostAndSharedFxArtifacts(BuildTargetContext c) => c.Success();
|
||||
public static BuildTargetResult DownloadHostAndSharedFxArtifacts(BuildTargetContext c)
|
||||
{
|
||||
ExpectedBuildArtifacts(c);
|
||||
DownloadHostAndSharedFxArchives(c);
|
||||
DownloadHostAndSharedFxInstallers(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult DownloadHostAndSharedFxArchives(BuildTargetContext c)
|
||||
{
|
||||
var sharedFrameworkVersion = CliDependencyVersions.SharedFrameworkVersion;
|
||||
|
@ -205,75 +239,75 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult DownloadHostAndSharedFxInstallers(BuildTargetContext c)
|
||||
{
|
||||
var sharedFrameworkVersion = CliDependencyVersions.SharedFrameworkVersion;
|
||||
var hostVersion = CliDependencyVersions.SharedHostVersion;
|
||||
var hostFxrVersion = CliDependencyVersions.HostFxrVersion;
|
||||
|
||||
var sharedFrameworkChannel = CliDependencyVersions.SharedFrameworkChannel;
|
||||
var sharedHostChannel = CliDependencyVersions.SharedHostChannel;
|
||||
var hostFxrChannel = CliDependencyVersions.HostFxrChannel;
|
||||
|
||||
var sharedFrameworkInstallerDownloadFile = Path.Combine(CliDirs.CoreSetupDownload, "sharedFrameworkInstaller");
|
||||
var sharedHostInstallerDownloadFile = Path.Combine(CliDirs.CoreSetupDownload, "sharedHostInstaller");
|
||||
var hostFxrInstallerDownloadFile = Path.Combine(CliDirs.CoreSetupDownload, "hostFxrInstaller");
|
||||
|
||||
Mkdirp(Path.GetDirectoryName(sharedFrameworkInstallerDownloadFile));
|
||||
Mkdirp(Path.GetDirectoryName(sharedHostInstallerDownloadFile));
|
||||
Mkdirp(Path.GetDirectoryName(hostFxrInstallerDownloadFile));
|
||||
|
||||
if (!File.Exists(sharedFrameworkInstallerDownloadFile))
|
||||
if (CurrentPlatform.IsAnyPlatform(BuildPlatform.Windows, BuildPlatform.OSX, BuildPlatform.Ubuntu))
|
||||
{
|
||||
var sharedFrameworkInstallerDestinationFile = c.BuildContext.Get<string>("SharedFrameworkInstallerFile");
|
||||
Mkdirp(Path.GetDirectoryName(sharedFrameworkInstallerDestinationFile));
|
||||
var sharedFrameworkVersion = CliDependencyVersions.SharedFrameworkVersion;
|
||||
var hostVersion = CliDependencyVersions.SharedHostVersion;
|
||||
var hostFxrVersion = CliDependencyVersions.HostFxrVersion;
|
||||
|
||||
AzurePublisher.DownloadFile(
|
||||
CalculateInstallerBlob(
|
||||
sharedFrameworkInstallerDestinationFile,
|
||||
sharedFrameworkChannel,
|
||||
sharedFrameworkVersion),
|
||||
sharedFrameworkInstallerDownloadFile).Wait();
|
||||
var sharedFrameworkChannel = CliDependencyVersions.SharedFrameworkChannel;
|
||||
var sharedHostChannel = CliDependencyVersions.SharedHostChannel;
|
||||
var hostFxrChannel = CliDependencyVersions.HostFxrChannel;
|
||||
|
||||
File.Copy(sharedFrameworkInstallerDownloadFile, sharedFrameworkInstallerDestinationFile, true);
|
||||
}
|
||||
var sharedFrameworkInstallerDownloadFile = Path.Combine(CliDirs.CoreSetupDownload, "sharedFrameworkInstaller");
|
||||
var sharedHostInstallerDownloadFile = Path.Combine(CliDirs.CoreSetupDownload, "sharedHostInstaller");
|
||||
var hostFxrInstallerDownloadFile = Path.Combine(CliDirs.CoreSetupDownload, "hostFxrInstaller");
|
||||
|
||||
if (!File.Exists(sharedHostInstallerDownloadFile))
|
||||
{
|
||||
var sharedHostInstallerDestinationFile = c.BuildContext.Get<string>("SharedHostInstallerFile");
|
||||
Mkdirp(Path.GetDirectoryName(sharedHostInstallerDestinationFile));
|
||||
Mkdirp(Path.GetDirectoryName(sharedFrameworkInstallerDownloadFile));
|
||||
Mkdirp(Path.GetDirectoryName(sharedHostInstallerDownloadFile));
|
||||
Mkdirp(Path.GetDirectoryName(hostFxrInstallerDownloadFile));
|
||||
|
||||
AzurePublisher.DownloadFile(
|
||||
CalculateInstallerBlob(
|
||||
sharedHostInstallerDestinationFile,
|
||||
sharedHostChannel,
|
||||
hostVersion),
|
||||
sharedHostInstallerDownloadFile).Wait();
|
||||
if (!File.Exists(sharedFrameworkInstallerDownloadFile))
|
||||
{
|
||||
var sharedFrameworkInstallerDestinationFile = c.BuildContext.Get<string>("SharedFrameworkInstallerFile");
|
||||
Mkdirp(Path.GetDirectoryName(sharedFrameworkInstallerDestinationFile));
|
||||
|
||||
File.Copy(sharedHostInstallerDownloadFile, sharedHostInstallerDestinationFile, true);
|
||||
}
|
||||
AzurePublisher.DownloadFile(
|
||||
CalculateInstallerBlob(
|
||||
sharedFrameworkInstallerDestinationFile,
|
||||
sharedFrameworkChannel,
|
||||
sharedFrameworkVersion),
|
||||
sharedFrameworkInstallerDownloadFile).Wait();
|
||||
|
||||
if (!File.Exists(hostFxrInstallerDownloadFile))
|
||||
{
|
||||
var hostFxrInstallerDestinationFile = c.BuildContext.Get<string>("HostFxrInstallerFile");
|
||||
Mkdirp(Path.GetDirectoryName(hostFxrInstallerDestinationFile));
|
||||
File.Copy(sharedFrameworkInstallerDownloadFile, sharedFrameworkInstallerDestinationFile, true);
|
||||
}
|
||||
|
||||
AzurePublisher.DownloadFile(
|
||||
CalculateInstallerBlob(
|
||||
hostFxrInstallerDestinationFile,
|
||||
hostFxrChannel,
|
||||
hostFxrVersion),
|
||||
hostFxrInstallerDownloadFile).Wait();
|
||||
if (!File.Exists(sharedHostInstallerDownloadFile))
|
||||
{
|
||||
var sharedHostInstallerDestinationFile = c.BuildContext.Get<string>("SharedHostInstallerFile");
|
||||
Mkdirp(Path.GetDirectoryName(sharedHostInstallerDestinationFile));
|
||||
|
||||
File.Copy(hostFxrInstallerDownloadFile, hostFxrInstallerDestinationFile, true);
|
||||
AzurePublisher.DownloadFile(
|
||||
CalculateInstallerBlob(
|
||||
sharedHostInstallerDestinationFile,
|
||||
sharedHostChannel,
|
||||
hostVersion),
|
||||
sharedHostInstallerDownloadFile).Wait();
|
||||
|
||||
File.Copy(sharedHostInstallerDownloadFile, sharedHostInstallerDestinationFile, true);
|
||||
}
|
||||
|
||||
if (!File.Exists(hostFxrInstallerDownloadFile))
|
||||
{
|
||||
var hostFxrInstallerDestinationFile = c.BuildContext.Get<string>("HostFxrInstallerFile");
|
||||
Mkdirp(Path.GetDirectoryName(hostFxrInstallerDestinationFile));
|
||||
|
||||
AzurePublisher.DownloadFile(
|
||||
CalculateInstallerBlob(
|
||||
hostFxrInstallerDestinationFile,
|
||||
hostFxrChannel,
|
||||
hostFxrVersion),
|
||||
hostFxrInstallerDownloadFile).Wait();
|
||||
|
||||
File.Copy(hostFxrInstallerDownloadFile, hostFxrInstallerDestinationFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CheckPackageCache(BuildTargetContext c)
|
||||
{
|
||||
var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal);
|
||||
|
@ -327,9 +361,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(CheckPackageCache))]
|
||||
public static BuildTargetResult RestorePackages(BuildTargetContext c)
|
||||
{
|
||||
CheckPackageCache(c);
|
||||
|
||||
var dotnet = DotNetCli.Stage0;
|
||||
|
||||
dotnet.Restore("--verbosity", "verbose", "--disable-parallel")
|
||||
|
@ -344,92 +379,99 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu, "14.04")]
|
||||
public static BuildTargetResult CheckUbuntuDebianPackageBuildDependencies(BuildTargetContext c)
|
||||
{
|
||||
|
||||
var messageBuilder = new StringBuilder();
|
||||
var aptDependencyUtility = new AptDependencyUtility();
|
||||
|
||||
|
||||
foreach (var package in PackageDependencies.DebianPackageBuildDependencies)
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu, "14.04"))
|
||||
{
|
||||
if (!AptDependencyUtility.PackageIsInstalled(package))
|
||||
var messageBuilder = new StringBuilder();
|
||||
var aptDependencyUtility = new AptDependencyUtility();
|
||||
|
||||
|
||||
foreach (var package in PackageDependencies.DebianPackageBuildDependencies)
|
||||
{
|
||||
messageBuilder.Append($"Error: Debian package build dependency {package} missing.");
|
||||
messageBuilder.Append(Environment.NewLine);
|
||||
messageBuilder.Append($"-> install with apt-get install {package}");
|
||||
messageBuilder.Append(Environment.NewLine);
|
||||
if (!AptDependencyUtility.PackageIsInstalled(package))
|
||||
{
|
||||
messageBuilder.Append($"Error: Debian package build dependency {package} missing.");
|
||||
messageBuilder.Append(Environment.NewLine);
|
||||
messageBuilder.Append($"-> install with apt-get install {package}");
|
||||
messageBuilder.Append(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (messageBuilder.Length == 0)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed(messageBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (messageBuilder.Length == 0)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed(messageBuilder.ToString());
|
||||
}
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu, "14.04")]
|
||||
public static BuildTargetResult CheckUbuntuCoreclrAndCoreFxDependencies(BuildTargetContext c)
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
var stage0 = DotNetCli.Stage0.BinPath;
|
||||
|
||||
foreach (var package in PackageDependencies.UbuntuCoreclrAndCoreFxDependencies)
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu, "14.04"))
|
||||
{
|
||||
if (!AptDependencyUtility.PackageIsInstalled(package))
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
var stage0 = DotNetCli.Stage0.BinPath;
|
||||
|
||||
foreach (var package in PackageDependencies.UbuntuCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
errorMessageBuilder.Append($"Error: Coreclr package dependency {package} missing.");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
errorMessageBuilder.Append($"-> install with apt-get install {package}");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
if (!AptDependencyUtility.PackageIsInstalled(package))
|
||||
{
|
||||
errorMessageBuilder.Append($"Error: Coreclr package dependency {package} missing.");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
errorMessageBuilder.Append($"-> install with apt-get install {package}");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessageBuilder.Length == 0)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed(errorMessageBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessageBuilder.Length == 0)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed(errorMessageBuilder.ToString());
|
||||
}
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.CentOS)]
|
||||
public static BuildTargetResult CheckCentOSCoreclrAndCoreFxDependencies(BuildTargetContext c)
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
|
||||
foreach (var package in PackageDependencies.CentosCoreclrAndCoreFxDependencies)
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.CentOS))
|
||||
{
|
||||
if (!YumDependencyUtility.PackageIsInstalled(package))
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
|
||||
foreach (var package in PackageDependencies.CentosCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
errorMessageBuilder.Append($"Error: Coreclr package dependency {package} missing.");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
errorMessageBuilder.Append($"-> install with yum install {package}");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
if (!YumDependencyUtility.PackageIsInstalled(package))
|
||||
{
|
||||
errorMessageBuilder.Append($"Error: Coreclr package dependency {package} missing.");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
errorMessageBuilder.Append($"-> install with yum install {package}");
|
||||
errorMessageBuilder.Append(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessageBuilder.Length == 0)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed(errorMessageBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessageBuilder.Length == 0)
|
||||
{
|
||||
return c.Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c.Failed(errorMessageBuilder.ToString());
|
||||
}
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CheckPrereqCmakePresent(BuildTargetContext c)
|
||||
{
|
||||
try
|
||||
|
@ -461,7 +503,6 @@ cmake is required to build the native host 'corehost'";
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult SetTelemetryProfile(BuildTargetContext c)
|
||||
{
|
||||
var gitResult = Cmd("git", "rev-parse", "HEAD")
|
||||
|
@ -476,23 +517,6 @@ cmake is required to build the native host 'corehost'";
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
private static string GetVersionFromProjectJson(string pathToProjectJson)
|
||||
{
|
||||
Regex r = new Regex($"\"{Regex.Escape(Monikers.SharedFrameworkName)}\"\\s*:\\s*\"(?'version'[^\"]*)\"");
|
||||
|
||||
foreach (var line in File.ReadAllLines(pathToProjectJson))
|
||||
{
|
||||
var m = r.Match(line);
|
||||
|
||||
if (m.Success)
|
||||
{
|
||||
return m.Groups["version"].Value;
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unable to match the version name from " + pathToProjectJson);
|
||||
}
|
||||
|
||||
private static IDictionary<string, string> ReadBranchInfo(BuildTargetContext c, string path)
|
||||
{
|
||||
var lines = File.ReadAllLines(path);
|
||||
|
|
|
@ -4,10 +4,11 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public static class PublishTargets
|
||||
public class PublishTargets : Task
|
||||
{
|
||||
private static AzurePublisher AzurePublisherTool { get; set; }
|
||||
|
||||
|
@ -21,7 +22,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
private static string SharedFrameworkNugetVersion { get; set; }
|
||||
|
||||
[Target]
|
||||
public override bool Execute()
|
||||
{
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<PublishTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
return Publish(c).Success;
|
||||
}
|
||||
|
||||
public static BuildTargetResult InitPublish(BuildTargetContext c)
|
||||
{
|
||||
AzurePublisherTool = new AzurePublisher();
|
||||
|
@ -35,18 +43,21 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(
|
||||
nameof(PrepareTargets.Init),
|
||||
nameof(PublishTargets.InitPublish),
|
||||
nameof(PublishTargets.PublishArtifacts),
|
||||
nameof(PublishTargets.FinalizeBuild))]
|
||||
[Environment("PUBLISH_TO_AZURE_BLOB", "1", "true")] // This is set by CI systems
|
||||
[Target]
|
||||
public static BuildTargetResult Publish(BuildTargetContext c)
|
||||
{
|
||||
if (EnvVars.GetBool("PUBLISH_TO_AZURE_BLOB")) // This is set by CI systems
|
||||
{
|
||||
PrepareTargets.Init(c);
|
||||
|
||||
InitPublish(c);
|
||||
PublishArtifacts(c);
|
||||
FinalizeBuild(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult FinalizeBuild(BuildTargetContext c)
|
||||
{
|
||||
if (CheckIfAllBuildsHavePublished())
|
||||
|
@ -148,33 +159,43 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return badges.Values.All(v => v);
|
||||
}
|
||||
|
||||
[Target(
|
||||
nameof(PublishTargets.PublishInstallerFilesToAzure),
|
||||
nameof(PublishTargets.PublishArchivesToAzure),
|
||||
nameof(PublishTargets.PublishDebFilesToDebianRepo),
|
||||
nameof(PublishTargets.PublishCliVersionBadge))]
|
||||
public static BuildTargetResult PublishArtifacts(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(
|
||||
nameof(PublishTargets.PublishSdkInstallerFileToAzure),
|
||||
nameof(PublishTargets.PublishCombinedFrameworkSDKHostInstallerFileToAzure))]
|
||||
public static BuildTargetResult PublishInstallerFilesToAzure(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(
|
||||
nameof(PublishTargets.PublishCombinedHostFrameworkSdkArchiveToAzure),
|
||||
nameof(PublishTargets.PublishCombinedFrameworkSDKArchiveToAzure),
|
||||
nameof(PublishTargets.PublishSDKSymbolsArchiveToAzure))]
|
||||
public static BuildTargetResult PublishArchivesToAzure(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(
|
||||
nameof(PublishSdkDebToDebianRepo))]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishDebFilesToDebianRepo(BuildTargetContext c)
|
||||
public static BuildTargetResult PublishArtifacts(BuildTargetContext c)
|
||||
{
|
||||
PublishInstallerFilesToAzure(c);
|
||||
PublishArchivesToAzure(c);
|
||||
PublishDebFilesToDebianRepo(c);
|
||||
PublishCliVersionBadge(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult PublishInstallerFilesToAzure(BuildTargetContext c)
|
||||
{
|
||||
PublishSdkInstallerFileToAzure(c);
|
||||
PublishCombinedFrameworkSDKHostInstallerFileToAzure(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult PublishArchivesToAzure(BuildTargetContext c)
|
||||
{
|
||||
PublishCombinedHostFrameworkSdkArchiveToAzure(c);
|
||||
PublishCombinedFrameworkSDKArchiveToAzure(c);
|
||||
PublishSDKSymbolsArchiveToAzure(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult PublishDebFilesToDebianRepo(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
PublishSdkDebToDebianRepo(c);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishCliVersionBadge(BuildTargetContext c)
|
||||
{
|
||||
var versionBadge = c.BuildContext.Get<string>("VersionBadge");
|
||||
|
@ -183,37 +204,39 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishSdkInstallerFileToAzure(BuildTargetContext c)
|
||||
{
|
||||
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||
UploadFile(installerFile);
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||
UploadFile(installerFile);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows, BuildPlatform.OSX)]
|
||||
public static BuildTargetResult PublishCombinedFrameworkSDKHostInstallerFileToAzure(BuildTargetContext c)
|
||||
{
|
||||
var installerFile = c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile");
|
||||
UploadFile(installerFile);
|
||||
if (CurrentPlatform.IsAnyPlatform(BuildPlatform.Windows, BuildPlatform.OSX))
|
||||
{
|
||||
var installerFile = c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile");
|
||||
UploadFile(installerFile);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult PublishCombinedFrameworkSDKArchiveToAzure(BuildTargetContext c)
|
||||
{
|
||||
var archiveFile = c.BuildContext.Get<string>("CombinedFrameworkSDKCompressedFile");
|
||||
UploadFile(archiveFile);
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var archiveFile = c.BuildContext.Get<string>("CombinedFrameworkSDKCompressedFile");
|
||||
UploadFile(archiveFile);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishCombinedHostFrameworkSdkArchiveToAzure(BuildTargetContext c)
|
||||
{
|
||||
var archiveFile = c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile");
|
||||
|
@ -222,7 +245,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishSDKSymbolsArchiveToAzure(BuildTargetContext c)
|
||||
{
|
||||
var archiveFile = c.BuildContext.Get<string>("SdkSymbolsCompressedFile");
|
||||
|
@ -231,20 +253,21 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishSdkDebToDebianRepo(BuildTargetContext c)
|
||||
{
|
||||
var version = CliNuGetVersion;
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu))
|
||||
{
|
||||
var version = CliNuGetVersion;
|
||||
|
||||
var packageName = CliMonikers.GetSdkDebianPackageName(c);
|
||||
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||
var uploadUrl = AzurePublisher.CalculateFullUrlForFile(installerFile, AzurePublisher.Product.Sdk, version);
|
||||
var packageName = CliMonikers.GetSdkDebianPackageName(c);
|
||||
var installerFile = c.BuildContext.Get<string>("SdkInstallerFile");
|
||||
var uploadUrl = AzurePublisher.CalculateFullUrlForFile(installerFile, AzurePublisher.Product.Sdk, version);
|
||||
|
||||
DebRepoPublisherTool.PublishDebFileToDebianRepo(
|
||||
packageName,
|
||||
version,
|
||||
uploadUrl);
|
||||
DebRepoPublisherTool.PublishDebFileToDebianRepo(
|
||||
packageName,
|
||||
version,
|
||||
uploadUrl);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,11 @@ using Microsoft.DotNet.Cli.Build.Framework;
|
|||
using static Microsoft.DotNet.Cli.Build.FS;
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
using static Microsoft.DotNet.Cli.Build.Utils;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class TestTargets
|
||||
public class TestTargets : Task
|
||||
{
|
||||
private static string s_testPackageBuildVersionSuffix = "<buildversion>";
|
||||
|
||||
|
@ -57,28 +58,53 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
new { Path = "AppWithDirectDependencyDesktopAndPortable", Skip = new Func<bool>(() => !CurrentPlatform.IsWindows) }
|
||||
};
|
||||
|
||||
[Target(
|
||||
nameof(PrepareTargets.Init),
|
||||
nameof(SetupTests),
|
||||
nameof(RestoreTests),
|
||||
nameof(BuildTests),
|
||||
nameof(RunTests),
|
||||
nameof(ValidateDependencies))]
|
||||
public static BuildTargetResult Test(BuildTargetContext c) => c.Success();
|
||||
public override bool Execute()
|
||||
{
|
||||
BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly<TestTargets>().CreateBuildContext();
|
||||
BuildTargetContext c = new BuildTargetContext(context, null, null);
|
||||
|
||||
[Target(nameof(SetupTestPackages), nameof(SetupTestProjects))]
|
||||
public static BuildTargetResult SetupTests(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(RestoreTestAssetPackages), nameof(BuildTestAssetPackages))]
|
||||
public static BuildTargetResult SetupTestPackages(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(RestoreTestAssetProjects),
|
||||
nameof(RestoreDesktopTestAssetProjects),
|
||||
nameof(BuildTestAssetProjects),
|
||||
nameof(BuildDesktopTestAssetProjects))]
|
||||
public static BuildTargetResult SetupTestProjects(BuildTargetContext c) => c.Success();
|
||||
return Test(c).Success;
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult Test(BuildTargetContext c)
|
||||
{
|
||||
PrepareTargets.Init(c);
|
||||
SetupTests(c);
|
||||
RestoreTests(c);
|
||||
BuildTests(c);
|
||||
RunTests(c);
|
||||
ValidateDependencies(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult SetupTests(BuildTargetContext c)
|
||||
{
|
||||
SetupTestPackages(c);
|
||||
SetupTestProjects(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult SetupTestPackages(BuildTargetContext c)
|
||||
{
|
||||
RestoreTestAssetPackages(c);
|
||||
BuildTestAssetPackages(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult SetupTestProjects(BuildTargetContext c)
|
||||
{
|
||||
RestoreTestAssetProjects(c);
|
||||
RestoreDesktopTestAssetProjects(c);
|
||||
BuildTestAssetProjects(c);
|
||||
BuildDesktopTestAssetProjects(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult RestoreTestAssetPackages(BuildTargetContext c)
|
||||
{
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
|
||||
|
@ -95,7 +121,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult RestoreTestAssetProjects(BuildTargetContext c)
|
||||
{
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
|
||||
|
@ -127,24 +152,27 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult RestoreDesktopTestAssetProjects(BuildTargetContext c)
|
||||
{
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
||||
dotnet.Restore("--verbosity", "verbose",
|
||||
"--infer-runtimes",
|
||||
"--fallbacksource", Dirs.TestPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "DesktopTestProjects"))
|
||||
.Execute().EnsureSuccessful();
|
||||
dotnet.Restore("--verbosity", "verbose",
|
||||
"--infer-runtimes",
|
||||
"--fallbacksource", Dirs.TestPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "DesktopTestProjects"))
|
||||
.Execute().EnsureSuccessful();
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(CleanTestPackages), nameof(CleanProductPackages))]
|
||||
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c)
|
||||
{
|
||||
CleanTestPackages(c);
|
||||
CleanProductPackages(c);
|
||||
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages"));
|
||||
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
@ -209,7 +237,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CleanProductPackages(BuildTargetContext c)
|
||||
{
|
||||
foreach (var packageName in PackageTargets.ProjectsToPack)
|
||||
|
@ -220,7 +247,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult CleanTestPackages(BuildTargetContext c)
|
||||
{
|
||||
foreach (var packageProject in TestPackageProjects.Projects.Where(p => p.IsApplicable && p.Clean))
|
||||
|
@ -234,7 +260,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult BuildTestAssetProjects(BuildTargetContext c)
|
||||
{
|
||||
var testAssetsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects");
|
||||
|
@ -244,18 +269,20 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return BuildTestAssets(c, testAssetsRoot, dotnet, framework);
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult BuildDesktopTestAssetProjects(BuildTargetContext c)
|
||||
{
|
||||
var testAssetsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "DesktopTestProjects");
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
var framework = "net451";
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Windows))
|
||||
{
|
||||
var testAssetsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "DesktopTestProjects");
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
var framework = "net451";
|
||||
|
||||
return BuildTestAssets(c, testAssetsRoot, dotnet, framework);
|
||||
return BuildTestAssets(c, testAssetsRoot, dotnet, framework);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult RestoreTests(BuildTargetContext c)
|
||||
{
|
||||
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
|
||||
|
@ -270,7 +297,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult BuildTests(BuildTargetContext c)
|
||||
{
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
@ -288,10 +314,13 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(RunXUnitTests))]
|
||||
public static BuildTargetResult RunTests(BuildTargetContext c) => c.Success();
|
||||
public static BuildTargetResult RunTests(BuildTargetContext c)
|
||||
{
|
||||
RunXUnitTests(c);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult RunXUnitTests(BuildTargetContext c)
|
||||
{
|
||||
// Need to load up the VS Vars
|
||||
|
@ -335,7 +364,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult ValidateDependencies(BuildTargetContext c)
|
||||
{
|
||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||
|
|
|
@ -8,23 +8,9 @@ param(
|
|||
[string[]]$Targets=@("Default"),
|
||||
[string]$Architecture="x64",
|
||||
[switch]$NoPackage,
|
||||
[switch]$NoRun,
|
||||
[switch]$Help)
|
||||
|
||||
function RemoveDirectory([string] $path)
|
||||
{
|
||||
if (Test-Path $path)
|
||||
{
|
||||
Remove-Item $path -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
function CleanNuGet()
|
||||
{
|
||||
RemoveDirectory($env:LocalAppData + "\NuGet\Cache")
|
||||
RemoveDirectory($env:LocalAppData + "\NuGet\v3-cache")
|
||||
RemoveDirectory($env:NUGET_PACKAGES)
|
||||
}
|
||||
|
||||
if($Help)
|
||||
{
|
||||
Write-Host "Usage: .\build.ps1 [-Configuration <CONFIGURATION>] [-Targets <TARGETS...>] [-Architecture <ARCHITECTURE>] [-NoPackage] [-Help]"
|
||||
|
@ -34,6 +20,7 @@ if($Help)
|
|||
Write-Host " -Targets <TARGETS...> Comma separated build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)"
|
||||
Write-Host " -Architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
|
||||
Write-Host " -NoPackage Skip packaging targets"
|
||||
Write-Host " -NoRun Skip running the build"
|
||||
Write-Host " -Help Display this help message"
|
||||
exit 0
|
||||
}
|
||||
|
@ -79,9 +66,6 @@ if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
|
|||
# Put the stage0 on the path
|
||||
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
||||
|
||||
# Ensure clean package folder and caches
|
||||
CleanNuGet
|
||||
|
||||
# Disable first run since we want to control all package sources
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
|
@ -97,8 +81,11 @@ Write-Host "Compiling Build Scripts..."
|
|||
dotnet publish "$PSScriptRoot" -o "$PSScriptRoot\bin" --framework netcoreapp1.0
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to compile build scripts" }
|
||||
|
||||
# Run the builder
|
||||
Write-Host "Invoking Build Scripts..."
|
||||
Write-Host " Configuration: $env:CONFIGURATION"
|
||||
& "$PSScriptRoot\bin\dotnet-cli-build.exe" @Targets
|
||||
if($LASTEXITCODE -ne 0) { throw "Build failed" }
|
||||
if(!$NoRun)
|
||||
{
|
||||
# Run the builder
|
||||
Write-Host "Invoking Build Scripts..."
|
||||
Write-Host " Configuration: $env:CONFIGURATION"
|
||||
& "$PSScriptRoot\bin\dotnet-cli-build.exe" @Targets
|
||||
if($LASTEXITCODE -ne 0) { throw "Build failed" }
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ while [[ $# > 0 ]]; do
|
|||
--nopackage)
|
||||
export DOTNET_BUILD_SKIP_PACKAGING=1
|
||||
;;
|
||||
--norun)
|
||||
export DOTNET_BUILD_SKIP_RUN=1
|
||||
;;
|
||||
--skip-prereqs)
|
||||
# Allow CI to disable prereqs check since the CI has the pre-reqs but not ldconfig it seems
|
||||
export DOTNET_INSTALL_SKIP_PREREQS=1
|
||||
|
@ -44,6 +47,7 @@ while [[ $# > 0 ]]; do
|
|||
echo " --targets <TARGETS...> Comma separated build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)"
|
||||
echo " --skip-prereqs Skip checks for pre-reqs in dotnet_install"
|
||||
echo " --nopackage Skip packaging targets"
|
||||
echo " --norun Skip running the build"
|
||||
echo " --docker <IMAGENAME> Build in Docker using the Dockerfile located in scripts/docker/IMAGENAME"
|
||||
echo " --help Display this help message"
|
||||
exit 0
|
||||
|
@ -100,11 +104,6 @@ then
|
|||
ulimit -n 1024
|
||||
fi
|
||||
|
||||
# Clean old NuGet packages
|
||||
rm -rf "$HOME/.local/share/NuGet/Cache"
|
||||
rm -rf "$HOME/.local/share/NuGet/v3-cache"
|
||||
rm -rf "$NUGET_PACKAGES"
|
||||
|
||||
# Disable first run since we want to control all package sources
|
||||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
|
@ -119,10 +118,13 @@ echo "Restoring Build Script projects..."
|
|||
echo "Compiling Build Scripts..."
|
||||
dotnet publish "$DIR" -o "$DIR/bin" --framework netcoreapp1.0
|
||||
|
||||
export PATH="$OLDPATH"
|
||||
# Run the builder
|
||||
echo "Invoking Build Scripts..."
|
||||
echo "Configuration: $CONFIGURATION"
|
||||
if [-z "$DOTNET_BUILD_SKIP_RUN" ]
|
||||
then
|
||||
export PATH="$OLDPATH"
|
||||
# Run the builder
|
||||
echo "Invoking Build Scripts..."
|
||||
echo "Configuration: $CONFIGURATION"
|
||||
fi
|
||||
|
||||
$DIR/bin/dotnet-cli-build ${targets[@]}
|
||||
exit $?
|
||||
|
|
|
@ -2,7 +2,15 @@
|
|||
"version": "1.0.0-*",
|
||||
"description": "Build scripts for dotnet-cli",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
"emitEntryPoint": true,
|
||||
"allowUnsafe": true,
|
||||
"compile": [
|
||||
"../Microsoft.DotNet.Cli.Build.Framework/**/*.cs",
|
||||
"../shared-build-targets-utils/**/*.cs",
|
||||
"../../src/Microsoft.DotNet.InternalAbstractions/RuntimeEnvironment.cs",
|
||||
"../../src/Microsoft.DotNet.InternalAbstractions/Platform.cs",
|
||||
"../../src/Microsoft.DotNet.InternalAbstractions/Native/*.cs"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.6.0",
|
||||
|
@ -14,12 +22,8 @@
|
|||
"System.Xml.XmlSerializer": "4.0.11",
|
||||
"WindowsAzure.Storage": "6.2.2-preview",
|
||||
"NuGet.CommandLine.XPlat": "3.5.0-beta2-1484",
|
||||
"Microsoft.DotNet.Cli.Build.Framework": {
|
||||
"target": "project"
|
||||
},
|
||||
"shared-build-targets-utils": {
|
||||
"target": "project"
|
||||
}
|
||||
"Microsoft.Build.Framework": "0.1.0-preview-00024-160610",
|
||||
"Microsoft.Build.Utilities.Core": "0.1.0-preview-00024-160610"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public static readonly bool Verbose = GetBool("DOTNET_BUILD_VERBOSE");
|
||||
|
||||
private static bool GetBool(string name, bool defaultValue = false)
|
||||
public static bool GetBool(string name, bool defaultValue = false)
|
||||
{
|
||||
var str = Environment.GetEnvironmentVariable(name);
|
||||
if (string.IsNullOrEmpty(str))
|
||||
|
|
Loading…
Reference in a new issue