Merge pull request #3710 from eerhardt/msbuild-Prepare
Convert 'Init' to MSBuild.
This commit is contained in:
commit
0d37da4d0d
11 changed files with 360 additions and 344 deletions
|
@ -124,6 +124,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Archive",
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-build3.Tests", "test\dotnet-build3.Tests\dotnet-build3.Tests.xproj", "{49D7318E-D198-4E2B-BBEA-3A24D805F88D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{89905EC4-BC0F-443B-8ADF-691321F10108}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build\Microsoft.DotNet.Cli.Prepare.targets = build\Microsoft.DotNet.Cli.Prepare.targets
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
12
build.proj
12
build.proj
|
@ -1,7 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="BuildTheWholeCli" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="build/Microsoft.DotNet.Cli.Prepare.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
$(OS) is set to Unix/Windows_NT. This comes from an environment variable on Windows and MSBuild on Unix.
|
||||
|
@ -21,6 +19,10 @@
|
|||
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
|
||||
|
||||
<SharedFrameworkVersion>1.0.0</SharedFrameworkVersion>
|
||||
<SharedHostVersion>1.0.1</SharedHostVersion>
|
||||
<HostFxrVersion>1.0.1</HostFxrVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -36,16 +38,11 @@
|
|||
|
||||
<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">
|
||||
<PrepareTargets />
|
||||
</Target>
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Compile">
|
||||
<CompileTargets />
|
||||
</Target>
|
||||
|
@ -62,4 +59,5 @@
|
|||
<PublishTargets />
|
||||
</Target>
|
||||
|
||||
<Import Project="build/Microsoft.DotNet.Cli.Prepare.targets" />
|
||||
</Project>
|
|
@ -1,18 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Layout" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<UsingTask TaskName="Rid" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="Architecture" AssemblyFile="$(CLIBuildDll)" />
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<UsingTask TaskName="PrepareTargets" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GenerateBuildVersionInfo" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="CheckPrereqs" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="SetEnvVar" AssemblyFile="$(CLIBuildDll)" />
|
||||
|
||||
<Target DependsOnTargets="BuildDotnetCliBuildFramework" Name="Prepare">
|
||||
<PrepareTargets />
|
||||
</Target>
|
||||
|
||||
<Target Name="Init" >
|
||||
<!-- Current Runtime Information -->
|
||||
<Rid>
|
||||
<Output TaskParameter="OutputRid" PropertyName="Rid" />
|
||||
</Rid>
|
||||
<Architecture>
|
||||
<Output TaskParameter="OutputArchitecture" PropertyName="Architecture" />
|
||||
</Architecture>
|
||||
<GetCurrentRuntimeInformation>
|
||||
<Output TaskParameter="Rid" PropertyName="Rid" />
|
||||
<Output TaskParameter="Architecture" PropertyName="Architecture" />
|
||||
<Output TaskParameter="OSName" PropertyName="OSName" />
|
||||
</GetCurrentRuntimeInformation>
|
||||
|
||||
<!-- Common Properties -->
|
||||
<PropertyGroup>
|
||||
|
@ -20,28 +24,75 @@
|
|||
<OutputDirectory>$(BaseOutputDirectory)/stage2</OutputDirectory>
|
||||
<Stage2CompilationDirectory>$(BaseOutputDirectory)/stage2compilation</Stage2CompilationDirectory>
|
||||
<IntermediateDirectory>$(BaseOutputDirectory)/intermediate</IntermediateDirectory>
|
||||
<PackagesDirectory>$(BaseOutputDirectory)/packages</PackagesDirectory>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Generates BuildVersion Item
|
||||
BuildVersion Metadata:
|
||||
- Major
|
||||
- Minor
|
||||
- Patch
|
||||
- ReleaseSuffix
|
||||
- CommitHash
|
||||
- CommitCount
|
||||
- VersionSuffix
|
||||
- SimpleVersion
|
||||
- NugetVersion
|
||||
- MsiVersion -->
|
||||
<GenerateBuildVersionInfo RepoRoot="$(RepoRoot)">
|
||||
<Output TaskParameter="OutputBuildVersionInfo"
|
||||
ItemName="BuildVersion" />
|
||||
<Output TaskParameter="VersionMajor" PropertyName="VersionMajor" />
|
||||
<Output TaskParameter="VersionMinor" PropertyName="VersionMinor" />
|
||||
<Output TaskParameter="VersionPatch" PropertyName="VersionPatch" />
|
||||
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
|
||||
<Output TaskParameter="CommitCount" PropertyName="CommitCount" />
|
||||
<Output TaskParameter="ReleaseSuffix" PropertyName="ReleaseSuffix" />
|
||||
<Output TaskParameter="VersionSuffix" PropertyName="VersionSuffix" />
|
||||
<Output TaskParameter="SimpleVersion" PropertyName="SimpleVersion" />
|
||||
<Output TaskParameter="NugetVersion" PropertyName="NugetVersion" />
|
||||
<Output TaskParameter="MsiVersion" PropertyName="MsiVersion" />
|
||||
<Output TaskParameter="VersionBadgeMoniker" PropertyName="VersionBadgeMoniker" />
|
||||
<Output TaskParameter="Channel" PropertyName="Channel" />
|
||||
<Output TaskParameter="BranchName" PropertyName="BranchName" />
|
||||
</GenerateBuildVersionInfo>
|
||||
|
||||
<PropertyGroup>
|
||||
<SdkVersion>@(BuildVersion ->'%(NugetVersion)')</SdkVersion>
|
||||
<VersionBadge>$(BaseOutputDirectory)/$(VersionBadgeMoniker)_$(Configuration)_version_badge.svg</VersionBadge>
|
||||
<SdkVersion>$(NugetVersion)</SdkVersion>
|
||||
|
||||
<ArchiveExtension Condition=" '$(OSName)' == 'win' ">.zip</ArchiveExtension>
|
||||
<ArchiveExtension Condition=" '$(OSName)' != 'win' ">.tar.gz</ArchiveExtension>
|
||||
|
||||
<InstallerExtension Condition=" '$(OSName)' == 'win' ">.msi</InstallerExtension>
|
||||
<InstallerExtension Condition=" '$(OSName)' == 'osx' ">.pkg</InstallerExtension>
|
||||
<InstallerExtension Condition=" '$(OSName)' == 'ubuntu' ">.deb</InstallerExtension>
|
||||
|
||||
<BundleExtension Condition=" '$(OSName)' == 'win' ">.exe</BundleExtension>
|
||||
<BundleExtension Condition=" '$(OSName)' == 'osx' ">$(InstallerExtension)</BundleExtension>
|
||||
<BundleExtension Condition=" '$(OSName)' == 'ubuntu' ">$(InstallerExtension)</BundleExtension>
|
||||
|
||||
<ProductMonikerRid Condition=" '$(Rid)' == 'ubuntu.16.04-x64' Or '$(Rid)' == 'fedora.23-x64' Or '$(Rid)' == 'opensuse.13.2-x64' ">$(Rid)</ProductMonikerRid>
|
||||
<ProductMonikerRid Condition=" '$(ProductMonikerRid)' == '' ">$(OSName)-$(Architecture)</ProductMonikerRid>
|
||||
|
||||
<!-- Generated Installers + Archives -->
|
||||
<SdkCompressedFile>$(PackagesDirectory)/dotnet-sdk-$(ProductMonikerRid).$(SdkVersion)$(ArchiveExtension)</SdkCompressedFile>
|
||||
<SdkInstallerFile Condition=" '$(InstallerExtension)' != '' ">$(PackagesDirectory)/dotnet-sdk-$(ProductMonikerRid).$(SdkVersion)$(InstallerExtension)</SdkInstallerFile>
|
||||
|
||||
<CombinedFrameworkSDKHostCompressedFile>$(PackagesDirectory)/dotnet-dev-$(ProductMonikerRid).$(SdkVersion)$(ArchiveExtension)</CombinedFrameworkSDKHostCompressedFile>
|
||||
<CombinedFrameworkSDKHostInstallerFile Condition=" '$(BundleExtension)' != '' ">$(PackagesDirectory)/dotnet-dev-$(ProductMonikerRid).$(SdkVersion)$(BundleExtension)</CombinedFrameworkSDKHostInstallerFile>
|
||||
|
||||
<CombinedFrameworkSDKCompressedFile>$(PackagesDirectory)/dotnet-sharedframework-sdk-$(ProductMonikerRid).$(SdkVersion)$(ArchiveExtension)</CombinedFrameworkSDKCompressedFile>
|
||||
<CombinedFrameworkSDKInstallerFile Condition=" '$(BundleExtension)' != '' ">$(PackagesDirectory)/dotnet-sharedframework-sdk-$(ProductMonikerRid).$(SdkVersion)$(BundleExtension)</CombinedFrameworkSDKInstallerFile>
|
||||
|
||||
<SdkSymbolsCompressedFile>$(PackagesDirectory)/dotnet-sdk-debug-$(ProductMonikerRid).$(SdkVersion)$(ArchiveExtension)</SdkSymbolsCompressedFile>
|
||||
<SdkSymbolsInstallerFile Condition=" '$(InstallerExtension)' != '' ">$(PackagesDirectory)/dotnet-sdk-debug-$(ProductMonikerRid).$(SdkVersion)$(InstallerExtension)</SdkSymbolsInstallerFile>
|
||||
|
||||
<!-- Downloaded Installers + Archives -->
|
||||
<SharedHostCompressedFile>$(PackagesDirectory)/dotnet-host-$(ProductMonikerRid).$(SharedHostVersion)$(ArchiveExtension)</SharedHostCompressedFile>
|
||||
<SharedHostInstallerFile Condition=" '$(InstallerExtension)' != '' ">$(PackagesDirectory)/dotnet-host-$(ProductMonikerRid).$(SharedHostVersion)$(InstallerExtension)</SharedHostInstallerFile>
|
||||
|
||||
<HostFxrCompressedFile>$(PackagesDirectory)/dotnet-hostfxr-$(ProductMonikerRid).$(HostFxrVersion)$(ArchiveExtension)</HostFxrCompressedFile>
|
||||
<HostFxrInstallerFile Condition=" '$(InstallerExtension)' != '' ">$(PackagesDirectory)/dotnet-hostfxr-$(ProductMonikerRid).$(HostFxrVersion)$(InstallerExtension)</HostFxrInstallerFile>
|
||||
|
||||
<SharedFrameworkCompressedFile>$(PackagesDirectory)/dotnet-sharedframework-$(ProductMonikerRid).$(SharedFrameworkVersion)$(ArchiveExtension)</SharedFrameworkCompressedFile>
|
||||
<SharedFrameworkInstallerFile Condition=" '$(InstallerExtension)' != '' ">$(PackagesDirectory)/dotnet-sharedframework-$(ProductMonikerRid).$(SharedFrameworkVersion)$(InstallerExtension)</SharedFrameworkInstallerFile>
|
||||
|
||||
<CombinedFrameworkHostCompressedFile>$(PackagesDirectory)/dotnet-$(ProductMonikerRid).$(SharedFrameworkVersion)$(ArchiveExtension)</CombinedFrameworkHostCompressedFile>
|
||||
<CombinedFrameworkHostInstallerFile Condition=" '$(BundleExtension)' != '' ">$(PackagesDirectory)/dotnet-$(ProductMonikerRid).$(SharedFrameworkVersion)$(BundleExtension)</CombinedFrameworkHostInstallerFile>
|
||||
|
||||
<SdkBrandName>Microsoft .NET Core 1.0.0 - SDK Preview 2</SdkBrandName>
|
||||
</PropertyGroup>
|
||||
|
||||
<CheckPrereqs />
|
||||
|
||||
<!-- SetTelemetryProfile -->
|
||||
<SetEnvVar Name="DOTNET_CLI_TELEMETRY_PROFILE" Value="https://github.com/dotnet/cli;$(CommitHash)" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class Architecture : Task
|
||||
{
|
||||
[Output]
|
||||
public string OutputArchitecture { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
OutputArchitecture = RuntimeEnvironment.RuntimeArchitecture;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
136
build_projects/dotnet-cli-build/CheckPrereqs.cs
Normal file
136
build_projects/dotnet-cli-build/CheckPrereqs.cs
Normal file
|
@ -0,0 +1,136 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class CheckPrereqs : Task
|
||||
{
|
||||
public override bool Execute()
|
||||
{
|
||||
Run(s => Log.LogMessage(s));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Run(Action<string> logInfo)
|
||||
{
|
||||
CheckCoreclrPlatformDependencies();
|
||||
CheckInstallerBuildPlatformDependencies();
|
||||
|
||||
LocateStage0(logInfo);
|
||||
}
|
||||
|
||||
private static void CheckCoreclrPlatformDependencies()
|
||||
{
|
||||
CheckUbuntuCoreclrAndCoreFxDependencies();
|
||||
CheckCentOSCoreclrAndCoreFxDependencies();
|
||||
}
|
||||
|
||||
private static void CheckInstallerBuildPlatformDependencies()
|
||||
{
|
||||
CheckUbuntuDebianPackageBuildDependencies();
|
||||
}
|
||||
|
||||
private static void CheckUbuntuCoreclrAndCoreFxDependencies()
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu, "14.04"))
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
var stage0 = DotNetCli.Stage0.BinPath;
|
||||
|
||||
foreach (var package in PackageDependencies.UbuntuCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new BuildFailureException(errorMessageBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckCentOSCoreclrAndCoreFxDependencies()
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.CentOS))
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
|
||||
foreach (var package in PackageDependencies.CentosCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new BuildFailureException(errorMessageBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckUbuntuDebianPackageBuildDependencies()
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu, "14.04"))
|
||||
{
|
||||
var messageBuilder = new StringBuilder();
|
||||
var aptDependencyUtility = new AptDependencyUtility();
|
||||
|
||||
|
||||
foreach (var package in PackageDependencies.DebianPackageBuildDependencies)
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new BuildFailureException(messageBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void LocateStage0(Action<string> logInfo)
|
||||
{
|
||||
// We should have been run in the repo root, so locate the stage 0 relative to current directory
|
||||
var stage0 = DotNetCli.Stage0.BinPath;
|
||||
|
||||
if (!Directory.Exists(stage0))
|
||||
{
|
||||
throw new BuildFailureException($"Stage 0 directory does not exist: {stage0}");
|
||||
}
|
||||
|
||||
// Identify the version
|
||||
string versionFile = Directory.GetFiles(stage0, ".version", SearchOption.AllDirectories).FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrEmpty(versionFile))
|
||||
{
|
||||
throw new Exception($"'.version' file not found in '{stage0}' folder");
|
||||
}
|
||||
|
||||
var version = File.ReadAllLines(versionFile);
|
||||
logInfo($"Using Stage 0 Version: {version[1]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class GenerateBuildVersionInfo : Task
|
||||
{
|
||||
[Required]
|
||||
public string RepoRoot { get; set; }
|
||||
|
||||
[Output]
|
||||
public ITaskItem OutputBuildVersionInfo { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
var branchInfo = new BranchInfo(RepoRoot);
|
||||
|
||||
var commitCount = GitUtils.GetCommitCount();
|
||||
var commitHash = GitUtils.GetCommitHash();
|
||||
|
||||
var buildVersion = new BuildVersion()
|
||||
{
|
||||
Major = int.Parse(branchInfo.Entries["MAJOR_VERSION"]),
|
||||
Minor = int.Parse(branchInfo.Entries["MINOR_VERSION"]),
|
||||
Patch = int.Parse(branchInfo.Entries["PATCH_VERSION"]),
|
||||
ReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"],
|
||||
CommitCount = commitCount
|
||||
};
|
||||
|
||||
OutputBuildVersionInfo = ConstructBuildVersionInfoItem(buildVersion, commitHash);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private ITaskItem ConstructBuildVersionInfoItem(BuildVersion buildVersion, string commitHash)
|
||||
{
|
||||
var versionInfo = new TaskItem();
|
||||
versionInfo.ItemSpec = "BuildVersionInfo";
|
||||
|
||||
versionInfo.SetMetadata("CommitHash", commitHash);
|
||||
versionInfo.SetMetadata("Major", buildVersion.Major.ToString());
|
||||
versionInfo.SetMetadata("Minor", buildVersion.Minor.ToString());
|
||||
versionInfo.SetMetadata("Patch", buildVersion.Patch.ToString());
|
||||
versionInfo.SetMetadata("ReleaseSuffix", buildVersion.ReleaseSuffix);
|
||||
versionInfo.SetMetadata("CommitCount", buildVersion.CommitCountString);
|
||||
versionInfo.SetMetadata("VersionSuffix", buildVersion.VersionSuffix);
|
||||
versionInfo.SetMetadata("SimpleVersion", buildVersion.SimpleVersion);
|
||||
versionInfo.SetMetadata("NugetVersion", buildVersion.NuGetVersion);
|
||||
versionInfo.SetMetadata("MsiVersion", buildVersion.GenerateMsiVersion());
|
||||
|
||||
return versionInfo;
|
||||
}
|
||||
}
|
||||
}
|
84
build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs
Normal file
84
build_projects/dotnet-cli-build/GenerateBuildVersionInfo.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System.Globalization;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class GenerateBuildVersionInfo : Task
|
||||
{
|
||||
[Required]
|
||||
public string RepoRoot { get; set; }
|
||||
|
||||
[Output]
|
||||
public int VersionMajor { get; set; }
|
||||
|
||||
[Output]
|
||||
public int VersionMinor { get; set; }
|
||||
|
||||
[Output]
|
||||
public int VersionPatch { get; set; }
|
||||
|
||||
[Output]
|
||||
public string CommitHash { get; set; }
|
||||
|
||||
[Output]
|
||||
public int CommitCount { get; set; }
|
||||
|
||||
[Output]
|
||||
public string ReleaseSuffix { get; set; }
|
||||
|
||||
[Output]
|
||||
public string VersionSuffix { get; set; }
|
||||
|
||||
[Output]
|
||||
public string SimpleVersion { get; set; }
|
||||
|
||||
[Output]
|
||||
public string NugetVersion { get; set; }
|
||||
|
||||
[Output]
|
||||
public string MsiVersion { get; set; }
|
||||
|
||||
[Output]
|
||||
public string VersionBadgeMoniker { get; set; }
|
||||
|
||||
[Output]
|
||||
public string Channel { get; set; }
|
||||
|
||||
[Output]
|
||||
public string BranchName { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
var branchInfo = new BranchInfo(RepoRoot);
|
||||
|
||||
var commitCount = GitUtils.GetCommitCount();
|
||||
var commitHash = GitUtils.GetCommitHash();
|
||||
|
||||
var buildVersion = new BuildVersion()
|
||||
{
|
||||
Major = int.Parse(branchInfo.Entries["MAJOR_VERSION"]),
|
||||
Minor = int.Parse(branchInfo.Entries["MINOR_VERSION"]),
|
||||
Patch = int.Parse(branchInfo.Entries["PATCH_VERSION"]),
|
||||
ReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"],
|
||||
CommitCount = commitCount
|
||||
};
|
||||
|
||||
VersionMajor = buildVersion.Major;
|
||||
VersionMinor = buildVersion.Minor;
|
||||
VersionPatch = buildVersion.Patch;
|
||||
CommitHash = commitHash;
|
||||
CommitCount = commitCount;
|
||||
ReleaseSuffix = buildVersion.ReleaseSuffix;
|
||||
VersionSuffix = buildVersion.VersionSuffix;
|
||||
SimpleVersion = buildVersion.SimpleVersion;
|
||||
NugetVersion = buildVersion.NuGetVersion;
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
VersionBadgeMoniker = Monikers.GetBadgeMoniker();
|
||||
Channel = branchInfo.Entries["CHANNEL"];
|
||||
BranchName= branchInfo.Entries["BRANCH_NAME"];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class GetCurrentRuntimeInformation : Task
|
||||
{
|
||||
[Output]
|
||||
public string Rid { get; set; }
|
||||
|
||||
[Output]
|
||||
public string Architecture { get; set; }
|
||||
|
||||
[Output]
|
||||
public string OSName { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
Rid = RuntimeEnvironment.GetRuntimeIdentifier();
|
||||
Architecture = RuntimeEnvironment.RuntimeArchitecture;
|
||||
OSName = Monikers.GetOSShortName();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,18 +2,13 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO.Compression;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
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
|
||||
{
|
||||
|
@ -38,43 +33,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return 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
|
||||
public static BuildTargetResult Init(BuildTargetContext c)
|
||||
{
|
||||
GenerateVersions(c);
|
||||
CheckPrereqs(c);
|
||||
LocateStage0(c);
|
||||
CheckPrereqs.Run(s => c.Info(s));
|
||||
ExpectedBuildArtifacts(c);
|
||||
SetTelemetryProfile(c);
|
||||
|
||||
|
@ -140,29 +103,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult LocateStage0(BuildTargetContext c)
|
||||
{
|
||||
// We should have been run in the repo root, so locate the stage 0 relative to current directory
|
||||
var stage0 = DotNetCli.Stage0.BinPath;
|
||||
|
||||
if (!Directory.Exists(stage0))
|
||||
{
|
||||
return c.Failed($"Stage 0 directory does not exist: {stage0}");
|
||||
}
|
||||
|
||||
// Identify the version
|
||||
string versionFile = Directory.GetFiles(stage0, ".version", SearchOption.AllDirectories).FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrEmpty(versionFile))
|
||||
{
|
||||
throw new Exception($"'.version' file not found in '{stage0}' folder");
|
||||
}
|
||||
|
||||
var version = File.ReadAllLines(versionFile);
|
||||
c.Info($"Using Stage 0 Version: {version[1]}");
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
||||
public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c)
|
||||
{
|
||||
|
@ -379,130 +320,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckUbuntuDebianPackageBuildDependencies(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu, "14.04"))
|
||||
{
|
||||
var messageBuilder = new StringBuilder();
|
||||
var aptDependencyUtility = new AptDependencyUtility();
|
||||
|
||||
|
||||
foreach (var package in PackageDependencies.DebianPackageBuildDependencies)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckUbuntuCoreclrAndCoreFxDependencies(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.Ubuntu, "14.04"))
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
var stage0 = DotNetCli.Stage0.BinPath;
|
||||
|
||||
foreach (var package in PackageDependencies.UbuntuCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckCentOSCoreclrAndCoreFxDependencies(BuildTargetContext c)
|
||||
{
|
||||
if (CurrentPlatform.IsPlatform(BuildPlatform.CentOS))
|
||||
{
|
||||
var errorMessageBuilder = new StringBuilder();
|
||||
|
||||
foreach (var package in PackageDependencies.CentosCoreclrAndCoreFxDependencies)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult CheckPrereqCmakePresent(BuildTargetContext c)
|
||||
{
|
||||
try
|
||||
{
|
||||
Command.Create("cmake", "--version")
|
||||
.CaptureStdOut()
|
||||
.CaptureStdErr()
|
||||
.Execute();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string message = $@"Error running cmake: {ex.Message}
|
||||
cmake is required to build the native host 'corehost'";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
message += Environment.NewLine + "Download it from https://www.cmake.org";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
message += Environment.NewLine + "Ubuntu: 'sudo apt-get install cmake'";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
message += Environment.NewLine + "OS X w/Homebrew: 'brew install cmake'";
|
||||
}
|
||||
return c.Failed(message);
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
public static BuildTargetResult SetTelemetryProfile(BuildTargetContext c)
|
||||
{
|
||||
var gitResult = Cmd("git", "rev-parse", "HEAD")
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class Rid : Task
|
||||
{
|
||||
[Output]
|
||||
public string OutputRid { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
OutputRid = RuntimeEnvironment.GetRuntimeIdentifier();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
22
build_projects/dotnet-cli-build/SetEnvVar.cs
Normal file
22
build_projects/dotnet-cli-build/SetEnvVar.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class SetEnvVar : Task
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Value { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
Environment.SetEnvironmentVariable(Name, Value);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue