From 76728be4cbd925d81f4bafd0cf148cd9083c802d Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 29 Jun 2016 14:10:55 -0700 Subject: [PATCH 01/11] CompileTargets moved to MSBuild CompileTargets moved to MSBuild. Still need to work on input/outputs, refactoring of targets, specially around CompileStage and moving some of the tasks back to msbuild instead of C# code. --- build.proj | 14 +- build/Microsoft.DotNet.Cli.Compile.targets | 189 ++++++++ build/Microsoft.DotNet.Cli.Prepare.targets | 13 +- .../Microsoft.DotNet.Cli.Archive.targets | 43 ++ .../Microsoft.DotNet.Cli.Nupkg.targets | 11 + .../ChangeEntryPointLibraryName.cs | 30 ++ .../dotnet-cli-build/CleanPublishOutput.cs | 34 ++ .../dotnet-cli-build/CompileTargets.cs | 402 ------------------ .../dotnet-cli-build/CrossgenDirectory.cs | 32 ++ .../dotnet-cli-build/FixModeFlags.cs | 28 ++ .../RemoveAssetFromDepsPackages.cs | 68 +++ .../SharedFrameworkNameVersionPath.cs | 34 ++ 12 files changed, 489 insertions(+), 409 deletions(-) create mode 100644 build/Microsoft.DotNet.Cli.Compile.targets create mode 100644 build/compile/Microsoft.DotNet.Cli.Archive.targets create mode 100644 build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs create mode 100644 build_projects/dotnet-cli-build/CleanPublishOutput.cs delete mode 100644 build_projects/dotnet-cli-build/CompileTargets.cs create mode 100644 build_projects/dotnet-cli-build/CrossgenDirectory.cs create mode 100644 build_projects/dotnet-cli-build/FixModeFlags.cs create mode 100644 build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs create mode 100644 build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs diff --git a/build.proj b/build.proj index 61ba87e7e..c1bd8e2af 100644 --- a/build.proj +++ b/build.proj @@ -10,10 +10,15 @@ .ps1 - .sh + .sh -NoRun --norun + + %0D + %0A + $(LF) + $(CR)$(LF) Prepare;Compile;Test;Package;Publish $(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/bin/dotnet-cli-build @@ -49,12 +54,12 @@ - + - - + + @@ -66,5 +71,6 @@ + diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets new file mode 100644 index 000000000..299152f19 --- /dev/null +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + $(Stage1Directory) + $(Stage1SymbolsDirectory) + $(Stage0Path)/dotnet.exe + + + + + + + + + $(Stage2Directory) + $(Stage2SymbolsDirectory) + $(DotnetStage1) + + + + + + $(StageDirectory)/sdk/$(NugetVersion) + runtimes/any/native + $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) + $(SdkOutputDirectory)/runtimes/any/native + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(RepoRoot)/src + + .exe + + + + lib + + .dll + .dylib + .so + + dotnet$(ExeSuffix) + $(DynamicLibPrefix)hostfxr$(DynamicLibSuffix) + $(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index ed97b2f28..8e5ddf2ff 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -27,9 +27,16 @@ $(RepoRoot)/.dotnet_stage0/Darwin $(RepoRoot)/.dotnet_stage0/Linux $(Stage0Path) - + $(RepoRoot)/artifacts/$(Rid) - $(BaseOutputDirectory)/stage2/ + $(BaseOutputDirectory)/tools + $(BaseOutputDirectory)/stage1 + $(BaseOutputDirectory)/stage1symbols + $(Stage1Directory)/dotnet.exe + $(BaseOutputDirectory)/stage2 + $(BaseOutputDirectory)/stage2symbols + $(Stage2Directory)/dotnet.exe + $(Stage2Directory) $(BaseOutputDirectory)/stage2compilation $(BaseOutputDirectory)/intermediate $(BaseOutputDirectory)/packages @@ -197,4 +204,4 @@ ForceZipArchive="true" /> - + \ No newline at end of file diff --git a/build/compile/Microsoft.DotNet.Cli.Archive.targets b/build/compile/Microsoft.DotNet.Cli.Archive.targets new file mode 100644 index 000000000..f52d76cfc --- /dev/null +++ b/build/compile/Microsoft.DotNet.Cli.Archive.targets @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + $(IntermediateDirectory)/NuGetPackagesArchiveProject + $(IntermediateDirectory)/NuGetPackagesArchiveFolder + $(ToolsOutputDirectory)/Archiver + $(IntermediateDirectory)/nuGetPackagesArchive.lzma + $(Stage2Directory)/nuGetPackagesArchive.lzma + + + \ No newline at end of file diff --git a/build/package/Microsoft.DotNet.Cli.Nupkg.targets b/build/package/Microsoft.DotNet.Cli.Nupkg.targets index deb65b3c7..3cace9f53 100644 --- a/build/package/Microsoft.DotNet.Cli.Nupkg.targets +++ b/build/package/Microsoft.DotNet.Cli.Nupkg.targets @@ -66,4 +66,15 @@ --configuration $(Configuration) --version-suffix $(NupkgVersionSuffix)" /> + + + + + + diff --git a/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs b/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs new file mode 100644 index 000000000..535427c8f --- /dev/null +++ b/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs @@ -0,0 +1,30 @@ +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 ChangeEntryPointLibraryName : Task + { + public string DepsFile { get; set; } + + public string NewName { get; set; } + + public override bool Execute() + { + PublishMutationUtilties.ChangeEntryPointLibraryName(DepsFile, NewName); + + return true; + } + } +} diff --git a/build_projects/dotnet-cli-build/CleanPublishOutput.cs b/build_projects/dotnet-cli-build/CleanPublishOutput.cs new file mode 100644 index 000000000..77ab0d008 --- /dev/null +++ b/build_projects/dotnet-cli-build/CleanPublishOutput.cs @@ -0,0 +1,34 @@ +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 CleanPublishOutput : Task + { + public string Path { get; set; } + + public string Name { get; set; } + + public bool DeleteRuntimeConfigJson { get; set; } + + public bool DeleteDepsJson { get; set; } + + public override bool Execute() + { + PublishMutationUtilties.CleanPublishOutput(Path, Name, DeleteRuntimeConfigJson, DeleteDepsJson); + + return true; + } + } +} diff --git a/build_projects/dotnet-cli-build/CompileTargets.cs b/build_projects/dotnet-cli-build/CompileTargets.cs deleted file mode 100644 index 6ed367568..000000000 --- a/build_projects/dotnet-cli-build/CompileTargets.cs +++ /dev/null @@ -1,402 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Build.Utilities; -using Microsoft.DotNet.Cli.Build.Framework; -using Microsoft.DotNet.InternalAbstractions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; -using static Microsoft.DotNet.Cli.Build.FS; - -namespace Microsoft.DotNet.Cli.Build -{ - public class CompileTargets : Task - { - public static readonly bool IsWinx86 = CurrentPlatform.IsWindows && CurrentArchitecture.Isx86; - - public static readonly string[] BinariesForCoreHost = new[] - { - "csc" - }; - - public static readonly string[] ProjectsToPublish = new[] - { - "dotnet" - }; - - public static readonly string[] FilesToClean = new[] - { - "vbc.exe" - }; - - public static string HostPackagePlatformRid => HostPackageSupportedRids[ - (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) - ? $"win7-{RuntimeEnvironment.RuntimeArchitecture}" - : RuntimeEnvironment.GetRuntimeIdentifier()]; - - public static readonly Dictionary HostPackageSupportedRids = new Dictionary() - { - // Key: Current platform RID. Value: The actual publishable (non-dummy) package name produced by the build system for this RID. - { "win7-x64", "win7-x64" }, - { "win7-x86", "win7-x86" }, - { "osx.10.10-x64", "osx.10.10-x64" }, - { "osx.10.11-x64", "osx.10.10-x64" }, - { "ubuntu.14.04-x64", "ubuntu.14.04-x64" }, - { "ubuntu.16.04-x64", "ubuntu.16.04-x64" }, - { "centos.7-x64", "rhel.7-x64" }, - { "rhel.7-x64", "rhel.7-x64" }, - { "rhel.7.2-x64", "rhel.7-x64" }, - { "debian.8-x64", "debian.8-x64" }, - { "fedora.23-x64", "fedora.23-x64" }, - { "opensuse.13.2-x64", "opensuse.13.2-x64" } - }; - - public const string SharedFrameworkName = "Microsoft.NETCore.App"; - - public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); - - public override bool Execute() - { - BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly().CreateBuildContext(); - BuildTargetContext c = new BuildTargetContext(context, null, null); - - return Compile(c).Success; - } - - [Target] - public static BuildTargetResult Compile(BuildTargetContext c) - { - PrepareTargets.Init(c); - CompileStage1(c); - CompileStage2(c); - - return c.Success(); - } - - public static BuildTargetResult CompileStage1(BuildTargetContext c) - { - CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); - - if (Directory.Exists(Dirs.Stage1)) - { - Utils.DeleteDirectory(Dirs.Stage1); - } - Directory.CreateDirectory(Dirs.Stage1); - - var result = CompileCliSdk(c, - dotnet: DotNetCli.Stage0, - rootOutputDirectory: Dirs.Stage1); - - CleanOutputDir(Path.Combine(Dirs.Stage1, "sdk")); - FS.CopyRecursive(Dirs.Stage1, Dirs.Stage1Symbols); - - RemovePdbsFromDir(Path.Combine(Dirs.Stage1, "sdk")); - - return result; - } - - public static BuildTargetResult CompileStage2(BuildTargetContext c) - { - var configuration = c.BuildContext.Get("Configuration"); - - CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); - - if (Directory.Exists(Dirs.Stage2)) - { - Utils.DeleteDirectory(Dirs.Stage2); - } - Directory.CreateDirectory(Dirs.Stage2); - - var result = CompileCliSdk(c, - dotnet: DotNetCli.Stage1, - rootOutputDirectory: Dirs.Stage2, - generateNugetPackagesArchive: true); - - if (!result.Success) - { - return result; - } - - if (CurrentPlatform.IsWindows) - { - // build projects for nuget packages - var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging"); - Mkdirp(packagingOutputDir); - foreach (var project in PackageTargets.ProjectsToPack) - { - // Just build them, we'll pack later - var packBuildResult = DotNetCli.Stage1.Build( - "--build-base-path", - packagingOutputDir, - "--configuration", - configuration, - Path.Combine(c.BuildContext.BuildDirectory, "src", project)) - .Execute(); - - packBuildResult.EnsureSuccessful(); - } - } - - CleanOutputDir(Path.Combine(Dirs.Stage2, "sdk")); - FS.CopyRecursive(Dirs.Stage2, Dirs.Stage2Symbols); - - RemovePdbsFromDir(Path.Combine(Dirs.Stage2, "sdk")); - - return c.Success(); - } - - private static void CleanOutputDir(string directory) - { - foreach (var file in FilesToClean) - { - FS.RmFilesInDirRecursive(directory, file); - } - } - - private static void RemovePdbsFromDir(string directory) - { - FS.RmFilesInDirRecursive(directory, "*.pdb"); - } - - private static BuildTargetResult CompileCliSdk( - BuildTargetContext c, - DotNetCli dotnet, - string rootOutputDirectory, - bool generateNugetPackagesArchive = false) - { - var configuration = c.BuildContext.Get("Configuration"); - var buildVersion = c.BuildContext.Get("BuildVersion"); - var srcDir = Path.Combine(c.BuildContext.BuildDirectory, "src"); - var sdkOutputDirectory = Path.Combine(rootOutputDirectory, "sdk", buildVersion.NuGetVersion); - - CopySharedFramework(Dirs.SharedFrameworkPublish, rootOutputDirectory); - - FS.CleanBinObj(c, srcDir); - Rmdir(sdkOutputDirectory); - Mkdirp(sdkOutputDirectory); - - foreach (var project in ProjectsToPublish) - { - dotnet.Publish( - "--native-subdirectory", - "--output", sdkOutputDirectory, - "--configuration", configuration, - "--version-suffix", buildVersion.CommitCountString, - Path.Combine(srcDir, project)) - .Execute() - .EnsureSuccessful(); - } - - FixModeFlags(sdkOutputDirectory); - - string compilersProject = Path.Combine(Dirs.RepoRoot, "src", "compilers"); - dotnet.Publish(compilersProject, - "--output", - sdkOutputDirectory, - "--framework", - "netcoreapp1.0") - .Execute() - .EnsureSuccessful(); - - var compilersDeps = Path.Combine(sdkOutputDirectory, "compilers.deps.json"); - var compilersRuntimeConfig = Path.Combine(sdkOutputDirectory, "compilers.runtimeconfig.json"); - - var binaryToCorehostifyRelDir = Path.Combine("runtimes", "any", "native"); - var binaryToCorehostifyOutDir = Path.Combine(sdkOutputDirectory, binaryToCorehostifyRelDir); - // Corehostify binaries - foreach (var binaryToCorehostify in BinariesForCoreHost) - { - try - { - // Yes, it is .exe even on Linux. This is the managed exe we're working with - File.Copy(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.dll")); - File.Move(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.exe")); - var binaryToCoreHostifyDeps = Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json"); - - File.Copy(compilersDeps, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json")); - File.Copy(compilersRuntimeConfig, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".runtimeconfig.json")); - PublishMutationUtilties.ChangeEntryPointLibraryName(binaryToCoreHostifyDeps, binaryToCorehostify); - foreach (var binaryToRemove in new string[] { "csc", "vbc" }) - { - var assetPath = Path.Combine(binaryToCorehostifyRelDir, $"{binaryToRemove}.exe").Replace(Path.DirectorySeparatorChar, '/'); - RemoveAssetFromDepsPackages(binaryToCoreHostifyDeps, "runtimeTargets", assetPath); - RemoveAssetFromDepsPackages( - Path.Combine(sdkOutputDirectory, "dotnet.deps.json"), "runtimeTargets", assetPath); - } - } - catch (Exception ex) - { - return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}"); - } - } - - // cleanup compilers project output we don't need - PublishMutationUtilties.CleanPublishOutput( - sdkOutputDirectory, - "compilers", - deleteRuntimeConfigJson: true, - deleteDepsJson: true); - - // Crossgen SDK directory - var sharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion; - var sharedFrameworkNameVersionPath = SharedFrameworkPublisher.GetSharedFrameworkPublishPath( - rootOutputDirectory, - sharedFrameworkNugetVersion); - - // Copy Host to SDK Directory - File.Copy( - Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostBaseName), - Path.Combine(sdkOutputDirectory, $"corehost{Constants.ExeSuffix}"), - overwrite: true); - File.Copy( - Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostFxrBaseName), - Path.Combine(sdkOutputDirectory, HostArtifactNames.DotnetHostFxrBaseName), - overwrite: true); - File.Copy( - Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.HostPolicyBaseName), - Path.Combine(sdkOutputDirectory, HostArtifactNames.HostPolicyBaseName), - overwrite: true); - - CrossgenUtil.CrossgenDirectory( - sharedFrameworkNameVersionPath, - sdkOutputDirectory); - - // Generate .version file - var version = buildVersion.NuGetVersion; - var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; - File.WriteAllText(Path.Combine(sdkOutputDirectory, ".version"), content); - - if(generateNugetPackagesArchive) - { - GenerateNuGetPackagesArchive(c, dotnet, sdkOutputDirectory); - } - - CopyMSBuildTargetsToSDKRoot(sdkOutputDirectory); - - return c.Success(); - } - - private static void CopyMSBuildTargetsToSDKRoot(string sdkOutputDirectory) - { - var msbuildTargetsDirectory = Path.Combine(sdkOutputDirectory, "runtimes", "any", "native"); - - var filesToCopy = new List(); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.targets", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.Targets", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.props", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.overridetasks", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.tasks", SearchOption.AllDirectories)); - - foreach (var fileFullPath in filesToCopy) - { - var fileRelativePath = fileFullPath.Substring(msbuildTargetsDirectory.Length + 1); - var destinationFilePath = Path.Combine(sdkOutputDirectory, fileRelativePath); - - File.Copy(fileFullPath, destinationFilePath, true); - } - } - - private static void GenerateNuGetPackagesArchive( - BuildTargetContext c, - DotNetCli dotnet, - string sdkOutputDirectory) - { - var nuGetPackagesArchiveProject = Path.Combine(Dirs.Intermediate, "NuGetPackagesArchiveProject"); - var nuGetPackagesArchiveFolder = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchiveFolder"); - - RestoreNuGetPackagesArchive(dotnet, nuGetPackagesArchiveProject, nuGetPackagesArchiveFolder); - - CompressNuGetPackagesArchive(c, dotnet, nuGetPackagesArchiveFolder, sdkOutputDirectory); - } - - private static void RestoreNuGetPackagesArchive( - DotNetCli dotnet, - string nuGetPackagesArchiveProject, - string nuGetPackagesArchiveFolder) - { - Rmdir(nuGetPackagesArchiveProject); - Mkdirp(nuGetPackagesArchiveProject); - - Rmdir(nuGetPackagesArchiveFolder); - Mkdirp(nuGetPackagesArchiveFolder); - - dotnet.New() - .WorkingDirectory(nuGetPackagesArchiveProject) - .Execute() - .EnsureSuccessful(); - - dotnet.Restore("--packages", nuGetPackagesArchiveFolder) - .WorkingDirectory(nuGetPackagesArchiveProject) - .Execute() - .EnsureSuccessful(); - } - - private static void CompressNuGetPackagesArchive( - BuildTargetContext c, - DotNetCli dotnet, - string nuGetPackagesArchiveFolder, - string sdkOutputDirectory) - { - var configuration = c.BuildContext.Get("Configuration"); - var archiverExe = Path.Combine(Dirs.Output, "tools", $"Archiver{Constants.ExeSuffix}"); - var intermediateArchive = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchive.lzma"); - var finalArchive = Path.Combine(sdkOutputDirectory, "nuGetPackagesArchive.lzma"); - - Rm(intermediateArchive); - Rm($"{intermediateArchive}.zip"); - - c.Info("Publishing Archiver"); - dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) - .WorkingDirectory(Path.Combine(Dirs.RepoRoot, "tools", "Archiver")) - .Execute() - .EnsureSuccessful(); - - Cmd(archiverExe, - "-a", intermediateArchive, - nuGetPackagesArchiveFolder) - .Execute(); - - File.Copy(intermediateArchive, finalArchive); - } - - private static void RemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath) - { - JToken deps; - using (var file = File.OpenText(depsFile)) - using (JsonTextReader reader = new JsonTextReader(file)) - { - deps = JObject.ReadFrom(reader); - } - - foreach (JProperty target in deps["targets"]) - { - foreach (JProperty pv in target.Value.Children()) - { - var section = pv.Value[sectionName]; - if (section != null) - { - foreach (JProperty relPath in section) - { - if (assetPath.Equals(relPath.Name)) - { - relPath.Remove(); - break; - } - } - } - } - } - using (var file = File.CreateText(depsFile)) - using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) - { - deps.WriteTo(writer); - } - } - - private static void CopySharedFramework(string sharedFrameworkPublish, string rootOutputDirectory) - { - CopyRecursive(sharedFrameworkPublish, rootOutputDirectory); - } - } -} diff --git a/build_projects/dotnet-cli-build/CrossgenDirectory.cs b/build_projects/dotnet-cli-build/CrossgenDirectory.cs new file mode 100644 index 000000000..5010295e3 --- /dev/null +++ b/build_projects/dotnet-cli-build/CrossgenDirectory.cs @@ -0,0 +1,32 @@ +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 CrossgenDirectory : Task + { + private static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); + + public string SharedFrameworkNameVersionPath { get; set; } + + public string SdkOutputDirectory { get; set; } + + public override bool Execute() + { + CrossgenUtil.CrossgenDirectory(SharedFrameworkNameVersionPath, SdkOutputDirectory); + + return true; + } + } +} diff --git a/build_projects/dotnet-cli-build/FixModeFlags.cs b/build_projects/dotnet-cli-build/FixModeFlags.cs new file mode 100644 index 000000000..225a82a6e --- /dev/null +++ b/build_projects/dotnet-cli-build/FixModeFlags.cs @@ -0,0 +1,28 @@ +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 FixModeFlags : Task + { + public string Dir { get; set; } + + public override bool Execute() + { + FS.FixModeFlags(Dir); + + return true; + } + } +} diff --git a/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs b/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs new file mode 100644 index 000000000..9d37583fd --- /dev/null +++ b/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs @@ -0,0 +1,68 @@ +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 Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Cli.Build +{ + public class RemoveAssetFromDepsPackages : Task + { + public string DepsFile { get; set; } + + public string SectionName { get; set; } + + public string AssetPath { get; set; } + + public override bool Execute() + { + DoRemoveAssetFromDepsPackages(DepsFile, SectionName, AssetPath); + + return true; + } + + private static void DoRemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath) + { + JToken deps; + using (var file = File.OpenText(depsFile)) + using (JsonTextReader reader = new JsonTextReader(file)) + { + deps = JObject.ReadFrom(reader); + } + + foreach (JProperty target in deps["targets"]) + { + foreach (JProperty pv in target.Value.Children()) + { + var section = pv.Value[sectionName]; + if (section != null) + { + foreach (JProperty relPath in section) + { + if (assetPath.Equals(relPath.Name)) + { + relPath.Remove(); + break; + } + } + } + } + } + using (var file = File.CreateText(depsFile)) + using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) + { + deps.WriteTo(writer); + } + } + } +} diff --git a/build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs b/build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs new file mode 100644 index 000000000..59bb39e49 --- /dev/null +++ b/build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs @@ -0,0 +1,34 @@ +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 SharedFrameworkNameVersionPath : Task + { + public string RootOutputDirectory { get; set; } + + [Output] + public string OutputSharedFrameworkNameVersionPath { get; set; } + + public override bool Execute() + { + var sharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion; + OutputSharedFrameworkNameVersionPath = SharedFrameworkPublisher.GetSharedFrameworkPublishPath( + RootOutputDirectory, + sharedFrameworkNugetVersion); + + return true; + } + } +} From b91160ef0641782865fa2a25d502d20a2977de47 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 29 Jun 2016 14:01:16 -0700 Subject: [PATCH 02/11] Fixing some paths, moving the compile.targets to the end of build.proj. --- build.proj | 1 - build/Microsoft.DotNet.Cli.Compile.targets | 24 +++++++++++++------ .../Microsoft.DotNet.Cli.Archive.targets | 6 +++++ .../Microsoft.DotNet.Cli.Nupkg.targets | 3 ++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/build.proj b/build.proj index c1bd8e2af..7259a73cc 100644 --- a/build.proj +++ b/build.proj @@ -1,7 +1,6 @@ - - - @@ -138,46 +160,13 @@ - - - - - $(RepoRoot)/src - - .exe - - - - lib - - .dll - .dylib - .so - - dotnet$(ExeSuffix) - $(DynamicLibPrefix)hostfxr$(DynamicLibSuffix) - $(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix) - - - - - + + - - - + - - - - - - - - @@ -188,12 +177,4 @@ - - - - - - - - \ No newline at end of file diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 8e5ddf2ff..98abda5b3 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -27,7 +27,7 @@ $(RepoRoot)/.dotnet_stage0/Darwin $(RepoRoot)/.dotnet_stage0/Linux $(Stage0Path) - + $(RepoRoot)/artifacts/$(Rid) $(BaseOutputDirectory)/tools $(BaseOutputDirectory)/stage1 From 514a17894c86c3ac0af8606e1b04e5ad5a5bf762 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 29 Jun 2016 17:54:42 -0700 Subject: [PATCH 04/11] Cleanup after the rebase --- build.proj | 1 - 1 file changed, 1 deletion(-) diff --git a/build.proj b/build.proj index 3e374fae6..868aed26f 100644 --- a/build.proj +++ b/build.proj @@ -53,7 +53,6 @@ - From b8ccb0d1aeca0446119d624888c959a2b1b0b93e Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 30 Jun 2016 10:04:39 -0700 Subject: [PATCH 05/11] Adding CompileTargets.cs back. I got ahead of myself by removing it. We haven't switched our official builds to msbuild yet. --- .../dotnet-cli-build/CompileTargets.cs | 402 ++++++++++++++++++ 1 file changed, 402 insertions(+) create mode 100644 build_projects/dotnet-cli-build/CompileTargets.cs diff --git a/build_projects/dotnet-cli-build/CompileTargets.cs b/build_projects/dotnet-cli-build/CompileTargets.cs new file mode 100644 index 000000000..bd635ed90 --- /dev/null +++ b/build_projects/dotnet-cli-build/CompileTargets.cs @@ -0,0 +1,402 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.Build.Utilities; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.DotNet.InternalAbstractions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; +using static Microsoft.DotNet.Cli.Build.FS; + +namespace Microsoft.DotNet.Cli.Build +{ + public class CompileTargets : Task + { + public static readonly bool IsWinx86 = CurrentPlatform.IsWindows && CurrentArchitecture.Isx86; + + public static readonly string[] BinariesForCoreHost = new[] + { + "csc" + }; + + public static readonly string[] ProjectsToPublish = new[] + { + "dotnet" + }; + + public static readonly string[] FilesToClean = new[] + { + "vbc.exe" + }; + + public static string HostPackagePlatformRid => HostPackageSupportedRids[ + (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) + ? $"win7-{RuntimeEnvironment.RuntimeArchitecture}" + : RuntimeEnvironment.GetRuntimeIdentifier()]; + + public static readonly Dictionary HostPackageSupportedRids = new Dictionary() + { + // Key: Current platform RID. Value: The actual publishable (non-dummy) package name produced by the build system for this RID. + { "win7-x64", "win7-x64" }, + { "win7-x86", "win7-x86" }, + { "osx.10.10-x64", "osx.10.10-x64" }, + { "osx.10.11-x64", "osx.10.10-x64" }, + { "ubuntu.14.04-x64", "ubuntu.14.04-x64" }, + { "ubuntu.16.04-x64", "ubuntu.16.04-x64" }, + { "centos.7-x64", "rhel.7-x64" }, + { "rhel.7-x64", "rhel.7-x64" }, + { "rhel.7.2-x64", "rhel.7-x64" }, + { "debian.8-x64", "debian.8-x64" }, + { "fedora.23-x64", "fedora.23-x64" }, + { "opensuse.13.2-x64", "opensuse.13.2-x64" } + }; + + public const string SharedFrameworkName = "Microsoft.NETCore.App"; + + public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); + + public override bool Execute() + { + BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly().CreateBuildContext(); + BuildTargetContext c = new BuildTargetContext(context, null, null); + + return Compile(c).Success; + } + + [Target] + public static BuildTargetResult Compile(BuildTargetContext c) + { + PrepareTargets.Init(c); + CompileStage1(c); + CompileStage2(c); + + return c.Success(); + } + + public static BuildTargetResult CompileStage1(BuildTargetContext c) + { + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + + if (Directory.Exists(Dirs.Stage1)) + { + Utils.DeleteDirectory(Dirs.Stage1); + } + Directory.CreateDirectory(Dirs.Stage1); + + var result = CompileCliSdk(c, + dotnet: DotNetCli.Stage0, + rootOutputDirectory: Dirs.Stage1); + + CleanOutputDir(Path.Combine(Dirs.Stage1, "sdk")); + FS.CopyRecursive(Dirs.Stage1, Dirs.Stage1Symbols); + + RemovePdbsFromDir(Path.Combine(Dirs.Stage1, "sdk")); + + return result; + } + + public static BuildTargetResult CompileStage2(BuildTargetContext c) + { + var configuration = c.BuildContext.Get("Configuration"); + + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + + if (Directory.Exists(Dirs.Stage2)) + { + Utils.DeleteDirectory(Dirs.Stage2); + } + Directory.CreateDirectory(Dirs.Stage2); + + var result = CompileCliSdk(c, + dotnet: DotNetCli.Stage1, + rootOutputDirectory: Dirs.Stage2, + generateNugetPackagesArchive: true); + + if (!result.Success) + { + return result; + } + + if (CurrentPlatform.IsWindows) + { + // build projects for nuget packages + var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging"); + Mkdirp(packagingOutputDir); + foreach (var project in PackageTargets.ProjectsToPack) + { + // Just build them, we'll pack later + var packBuildResult = DotNetCli.Stage1.Build( + "--build-base-path", + packagingOutputDir, + "--configuration", + configuration, + Path.Combine(c.BuildContext.BuildDirectory, "src", project)) + .Execute(); + + packBuildResult.EnsureSuccessful(); + } + } + + CleanOutputDir(Path.Combine(Dirs.Stage2, "sdk")); + FS.CopyRecursive(Dirs.Stage2, Dirs.Stage2Symbols); + + RemovePdbsFromDir(Path.Combine(Dirs.Stage2, "sdk")); + + return c.Success(); + } + + private static void CleanOutputDir(string directory) + { + foreach (var file in FilesToClean) + { + FS.RmFilesInDirRecursive(directory, file); + } + } + + private static void RemovePdbsFromDir(string directory) + { + FS.RmFilesInDirRecursive(directory, "*.pdb"); + } + + private static BuildTargetResult CompileCliSdk( + BuildTargetContext c, + DotNetCli dotnet, + string rootOutputDirectory, + bool generateNugetPackagesArchive = false) + { + var configuration = c.BuildContext.Get("Configuration"); + var buildVersion = c.BuildContext.Get("BuildVersion"); + var srcDir = Path.Combine(c.BuildContext.BuildDirectory, "src"); + var sdkOutputDirectory = Path.Combine(rootOutputDirectory, "sdk", buildVersion.NuGetVersion); + + CopySharedFramework(Dirs.SharedFrameworkPublish, rootOutputDirectory); + + FS.CleanBinObj(c, srcDir); + Rmdir(sdkOutputDirectory); + Mkdirp(sdkOutputDirectory); + + foreach (var project in ProjectsToPublish) + { + dotnet.Publish( + "--native-subdirectory", + "--output", sdkOutputDirectory, + "--configuration", configuration, + "--version-suffix", buildVersion.CommitCountString, + Path.Combine(srcDir, project)) + .Execute() + .EnsureSuccessful(); + } + + FixModeFlags(sdkOutputDirectory); + + string compilersProject = Path.Combine(Dirs.RepoRoot, "src", "compilers"); + dotnet.Publish(compilersProject, + "--output", + sdkOutputDirectory, + "--framework", + "netcoreapp1.0") + .Execute() + .EnsureSuccessful(); + + var compilersDeps = Path.Combine(sdkOutputDirectory, "compilers.deps.json"); + var compilersRuntimeConfig = Path.Combine(sdkOutputDirectory, "compilers.runtimeconfig.json"); + + var binaryToCorehostifyRelDir = Path.Combine("runtimes", "any", "native"); + var binaryToCorehostifyOutDir = Path.Combine(sdkOutputDirectory, binaryToCorehostifyRelDir); + // Corehostify binaries + foreach (var binaryToCorehostify in BinariesForCoreHost) + { + try + { + // Yes, it is .exe even on Linux. This is the managed exe we're working with + File.Copy(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.dll")); + File.Move(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.exe")); + var binaryToCoreHostifyDeps = Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json"); + + File.Copy(compilersDeps, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json")); + File.Copy(compilersRuntimeConfig, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".runtimeconfig.json")); + PublishMutationUtilties.ChangeEntryPointLibraryName(binaryToCoreHostifyDeps, binaryToCorehostify); + foreach (var binaryToRemove in new string[] { "csc", "vbc" }) + { + var assetPath = Path.Combine(binaryToCorehostifyRelDir, $"{binaryToRemove}.exe").Replace(Path.DirectorySeparatorChar, '/'); + RemoveAssetFromDepsPackages(binaryToCoreHostifyDeps, "runtimeTargets", assetPath); + RemoveAssetFromDepsPackages( + Path.Combine(sdkOutputDirectory, "dotnet.deps.json"), "runtimeTargets", assetPath); + } + } + catch (Exception ex) + { + return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}"); + } + } + + // cleanup compilers project output we don't need + PublishMutationUtilties.CleanPublishOutput( + sdkOutputDirectory, + "compilers", + deleteRuntimeConfigJson: true, + deleteDepsJson: true); + + // Crossgen SDK directory + var sharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion; + var sharedFrameworkNameVersionPath = SharedFrameworkPublisher.GetSharedFrameworkPublishPath( + rootOutputDirectory, + sharedFrameworkNugetVersion); + + // Copy Host to SDK Directory + File.Copy( + Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostBaseName), + Path.Combine(sdkOutputDirectory, $"corehost{Constants.ExeSuffix}"), + overwrite: true); + File.Copy( + Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostFxrBaseName), + Path.Combine(sdkOutputDirectory, HostArtifactNames.DotnetHostFxrBaseName), + overwrite: true); + File.Copy( + Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.HostPolicyBaseName), + Path.Combine(sdkOutputDirectory, HostArtifactNames.HostPolicyBaseName), + overwrite: true); + + CrossgenUtil.CrossgenDirectory( + sharedFrameworkNameVersionPath, + sdkOutputDirectory); + + // Generate .version file + var version = buildVersion.NuGetVersion; + var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; + File.WriteAllText(Path.Combine(sdkOutputDirectory, ".version"), content); + + if(generateNugetPackagesArchive) + { + GenerateNuGetPackagesArchive(c, dotnet, sdkOutputDirectory); + } + + CopyMSBuildTargetsToSDKRoot(sdkOutputDirectory); + + return c.Success(); + } + + private static void CopyMSBuildTargetsToSDKRoot(string sdkOutputDirectory) + { + var msbuildTargetsDirectory = Path.Combine(sdkOutputDirectory, "runtimes", "any", "native"); + + var filesToCopy = new List(); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.targets", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.Targets", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.props", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.overridetasks", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.tasks", SearchOption.AllDirectories)); + + foreach (var fileFullPath in filesToCopy) + { + var fileRelativePath = fileFullPath.Substring(msbuildTargetsDirectory.Length + 1); + var destinationFilePath = Path.Combine(sdkOutputDirectory, fileRelativePath); + + File.Copy(fileFullPath, destinationFilePath, true); + } + } + + private static void GenerateNuGetPackagesArchive( + BuildTargetContext c, + DotNetCli dotnet, + string sdkOutputDirectory) + { + var nuGetPackagesArchiveProject = Path.Combine(Dirs.Intermediate, "NuGetPackagesArchiveProject"); + var nuGetPackagesArchiveFolder = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchiveFolder"); + + RestoreNuGetPackagesArchive(dotnet, nuGetPackagesArchiveProject, nuGetPackagesArchiveFolder); + + CompressNuGetPackagesArchive(c, dotnet, nuGetPackagesArchiveFolder, sdkOutputDirectory); + } + + private static void RestoreNuGetPackagesArchive( + DotNetCli dotnet, + string nuGetPackagesArchiveProject, + string nuGetPackagesArchiveFolder) + { + Rmdir(nuGetPackagesArchiveProject); + Mkdirp(nuGetPackagesArchiveProject); + + Rmdir(nuGetPackagesArchiveFolder); + Mkdirp(nuGetPackagesArchiveFolder); + + dotnet.New() + .WorkingDirectory(nuGetPackagesArchiveProject) + .Execute() + .EnsureSuccessful(); + + dotnet.Restore("--packages", nuGetPackagesArchiveFolder) + .WorkingDirectory(nuGetPackagesArchiveProject) + .Execute() + .EnsureSuccessful(); + } + + private static void CompressNuGetPackagesArchive( + BuildTargetContext c, + DotNetCli dotnet, + string nuGetPackagesArchiveFolder, + string sdkOutputDirectory) + { + var configuration = c.BuildContext.Get("Configuration"); + var archiverExe = Path.Combine(Dirs.Output, "tools", $"Archiver{Constants.ExeSuffix}"); + var intermediateArchive = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchive.lzma"); + var finalArchive = Path.Combine(sdkOutputDirectory, "nuGetPackagesArchive.lzma"); + + Rm(intermediateArchive); + Rm($"{intermediateArchive}.zip"); + + c.Info("Publishing Archiver"); + dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) + .WorkingDirectory(Path.Combine(Dirs.RepoRoot, "tools", "Archiver")) + .Execute() + .EnsureSuccessful(); + + Cmd(archiverExe, + "-a", intermediateArchive, + nuGetPackagesArchiveFolder) + .Execute(); + + File.Copy(intermediateArchive, finalArchive); + } + + private static void RemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath) + { + JToken deps; + using (var file = File.OpenText(depsFile)) + using (JsonTextReader reader = new JsonTextReader(file)) + { + deps = JObject.ReadFrom(reader); + } + + foreach (JProperty target in deps["targets"]) + { + foreach (JProperty pv in target.Value.Children()) + { + var section = pv.Value[sectionName]; + if (section != null) + { + foreach (JProperty relPath in section) + { + if (assetPath.Equals(relPath.Name)) + { + relPath.Remove(); + break; + } + } + } + } + } + using (var file = File.CreateText(depsFile)) + using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) + { + deps.WriteTo(writer); + } + } + + private static void CopySharedFramework(string sharedFrameworkPublish, string rootOutputDirectory) + { + CopyRecursive(sharedFrameworkPublish, rootOutputDirectory); + } + } +} \ No newline at end of file From 52e9475be8e9dd9d6715a1f0787da3faa1137f8a Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 30 Jun 2016 10:39:39 -0700 Subject: [PATCH 06/11] Fixed tabs to 2 spaces instead of 4 for our targets files --- build/Microsoft.DotNet.Cli.Compile.targets | 282 +++++++++--------- .../Microsoft.DotNet.Cli.Archive.targets | 48 +-- 2 files changed, 165 insertions(+), 165 deletions(-) diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index c85690d8b..c421443e5 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -1,180 +1,180 @@ - + - - - - - - + + + + + + - - - - - - - + + - - @(CompileStageInputs) - $(Stage1Directory) - $(Stage1SymbolsDirectory) - $(Stage0Path)/dotnet.exe - - - @(CompileStageInputs) - $(Stage2Directory) - $(Stage2SymbolsDirectory) - $(DotnetStage1) - - - + + + + - - - $(RepoRoot)/src + + @(CompileStageInputs) + $(Stage1Directory) + $(Stage1SymbolsDirectory) + $(Stage0Path)/dotnet.exe + + + @(CompileStageInputs) + $(Stage2Directory) + $(Stage2SymbolsDirectory) + $(DotnetStage1) + + + - .exe - + + + $(RepoRoot)/src - - lib + .exe + - .dll - .dylib - .so + + lib - dotnet$(ExeSuffix) - $(DynamicLibPrefix)hostfxr$(DynamicLibSuffix) - $(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix) + .dll + .dylib + .so - %(Stage.StageDirectory) - %(Stage.StageSymbolsDirectory) - $(StageDirectory)/sdk/$(NugetVersion) - runtimes/any/native - $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) - $(SdkOutputDirectory)/runtimes/any/native - + dotnet$(ExeSuffix) + $(DynamicLibPrefix)hostfxr$(DynamicLibSuffix) + $(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix) - - - - + %(Stage.StageDirectory) + %(Stage.StageSymbolsDirectory) + $(StageDirectory)/sdk/$(NugetVersion) + runtimes/any/native + $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) + $(SdkOutputDirectory)/runtimes/any/native + - + + + + - - + - - - - - - + + - - - + + + + + + - + + + - - - + - - - - - + + + - - + + + + + - + + - + - + - + - + - + - - + - - + + - - + + - + + - + - + - - + - + + - - - + - + + + - - - - + - + + + + - - + + + + \ No newline at end of file diff --git a/build/compile/Microsoft.DotNet.Cli.Archive.targets b/build/compile/Microsoft.DotNet.Cli.Archive.targets index ce8bb9240..08039528b 100644 --- a/build/compile/Microsoft.DotNet.Cli.Archive.targets +++ b/build/compile/Microsoft.DotNet.Cli.Archive.targets @@ -4,46 +4,46 @@ CompressNuGetPackagesArchive" Inputs="$(Stage2Directory)/sdk/**/dotnet.dll" Outputs="$(FinalArchive)"> - + - - - - + + + + - - - + + + - - + + - + - - + + - + - + - - $(IntermediateDirectory)/NuGetPackagesArchiveProject - $(IntermediateDirectory)/NuGetPackagesArchiveFolder - $(ToolsOutputDirectory)/Archiver - $(IntermediateDirectory)/nuGetPackagesArchive.lzma - $(Stage2Directory)/nuGetPackagesArchive.lzma - + + $(IntermediateDirectory)/NuGetPackagesArchiveProject + $(IntermediateDirectory)/NuGetPackagesArchiveFolder + $(ToolsOutputDirectory)/Archiver + $(IntermediateDirectory)/nuGetPackagesArchive.lzma + $(Stage2Directory)/nuGetPackagesArchive.lzma + \ No newline at end of file From 9135be75f4cb471777f79f0c57ecd3ecc3161547 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 30 Jun 2016 14:17:47 -0700 Subject: [PATCH 07/11] Addressing code review comments and making incremental build work. --- build.proj | 5 - build/Microsoft.DotNet.Cli.Compile.targets | 46 +- build/Microsoft.DotNet.Cli.Prepare.targets | 6 +- ... Microsoft.DotNet.Cli.LzmaArchive.targets} | 17 +- .../Microsoft.DotNet.Cli.Layout.targets | 6 +- .../ChangeEntryPointLibraryName.cs | 2 + .../dotnet-cli-build/CleanPublishOutput.cs | 4 + .../dotnet-cli-build/CompileTargets.cs | 775 +++++++++--------- .../dotnet-cli-build/CrossgenDirectory.cs | 12 +- .../dotnet-cli-build/FixModeFlags.cs | 1 + .../RemoveAssetFromDepsPackages.cs | 5 +- .../SharedFrameworkNameVersionPath.cs | 34 - tools/Archiver/project.json | 13 + tools/MultiProjectValidator/project.json | 13 + 14 files changed, 458 insertions(+), 481 deletions(-) rename build/compile/{Microsoft.DotNet.Cli.Archive.targets => Microsoft.DotNet.Cli.LzmaArchive.targets} (74%) delete mode 100644 build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs diff --git a/build.proj b/build.proj index 868aed26f..fcfaa460e 100644 --- a/build.proj +++ b/build.proj @@ -14,11 +14,6 @@ -NoRun --norun - %0D - %0A - $(LF) - $(CR)$(LF) - Prepare;Compile;Test;Package;Publish $(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/bin/dotnet-cli-build $(CLIBuildFileName).dll diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index c421443e5..cfd97e5be 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -1,15 +1,13 @@ - + - - + + $(RepoRoot)/src + + - - + + @(CompileStageInputs) @@ -33,15 +35,13 @@ $(Stage2SymbolsDirectory) $(DotnetStage1) - + - - $(RepoRoot)/src - + Inputs="%(Stage.Inputs)" + Outputs="%(StageDirectory)/sdk/$(SdkVersion)/dotnet.dll"> + .exe @@ -58,10 +58,16 @@ %(Stage.StageDirectory) %(Stage.StageSymbolsDirectory) - $(StageDirectory)/sdk/$(NugetVersion) + $(StageDirectory)/sdk/$(SdkVersion) runtimes/any/native $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) $(SdkOutputDirectory)/runtimes/any/native + + Microsoft.NETCore.App + 1.0.0 + + $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkNuGetVersion) + @@ -69,7 +75,7 @@ - + @@ -81,10 +87,6 @@ - - - - @@ -150,12 +152,14 @@ - - + diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 98abda5b3..bb8441ae6 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -39,8 +39,7 @@ $(Stage2Directory) $(BaseOutputDirectory)/stage2compilation $(BaseOutputDirectory)/intermediate - $(BaseOutputDirectory)/packages - $(BaseOutputDirectory)/stage2symbols + $(BaseOutputDirectory)/packages $(IntermediateDirectory)/sharedFrameworkPublish @@ -68,6 +67,9 @@ $(VersionMajor).$(VersionMinor).$(VersionPatch)-rc4-$(CommitCount) $(VersionMajor).$(VersionMinor).1-beta-$(CommitCount) + 1.0.2 + 1.0.2 + .zip .tar.gz diff --git a/build/compile/Microsoft.DotNet.Cli.Archive.targets b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets similarity index 74% rename from build/compile/Microsoft.DotNet.Cli.Archive.targets rename to build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets index 08039528b..531cb000b 100644 --- a/build/compile/Microsoft.DotNet.Cli.Archive.targets +++ b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets @@ -1,14 +1,8 @@ - + - - - - @@ -21,10 +15,7 @@ - - @@ -43,7 +34,7 @@ $(IntermediateDirectory)/NuGetPackagesArchiveFolder $(ToolsOutputDirectory)/Archiver $(IntermediateDirectory)/nuGetPackagesArchive.lzma - $(Stage2Directory)/nuGetPackagesArchive.lzma + $(Stage2Directory)/sdk/$(SdkVersion)/nuGetPackagesArchive.lzma \ No newline at end of file diff --git a/build/package/Microsoft.DotNet.Cli.Layout.targets b/build/package/Microsoft.DotNet.Cli.Layout.targets index 694da724c..4c6036a4d 100644 --- a/build/package/Microsoft.DotNet.Cli.Layout.targets +++ b/build/package/Microsoft.DotNet.Cli.Layout.targets @@ -11,7 +11,7 @@ - + @@ -56,7 +56,11 @@ @(SdkDebugLayoutInput) +<<<<<<< 52e9475be8e9dd9d6715a1f0787da3faa1137f8a @(SdkDebugRelativeOutputFiles -> '$(SdkDebugLayoutOutputDirectory)/%(Identity)') +======= + @(SdkDebugLayoutInput -> '$(SdkDebugLayoutOutputDirectory)/$([MSBuild]::MakeRelative($(Stage2SymbolsDirectory), '%(Identity)'))') +>>>>>>> Addressing code review comments and making incremental build work. $(ArtifactNameWithVersionSdkDebug) $(ArtifactNameSdkDebug) diff --git a/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs b/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs index 535427c8f..d309f8856 100644 --- a/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs +++ b/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs @@ -16,8 +16,10 @@ namespace Microsoft.DotNet.Cli.Build { public class ChangeEntryPointLibraryName : Task { + [Required] public string DepsFile { get; set; } + [Required] public string NewName { get; set; } public override bool Execute() diff --git a/build_projects/dotnet-cli-build/CleanPublishOutput.cs b/build_projects/dotnet-cli-build/CleanPublishOutput.cs index 77ab0d008..02528b749 100644 --- a/build_projects/dotnet-cli-build/CleanPublishOutput.cs +++ b/build_projects/dotnet-cli-build/CleanPublishOutput.cs @@ -16,12 +16,16 @@ namespace Microsoft.DotNet.Cli.Build { public class CleanPublishOutput : Task { + [Required] public string Path { get; set; } + [Required] public string Name { get; set; } + [Required] public bool DeleteRuntimeConfigJson { get; set; } + [Required] public bool DeleteDepsJson { get; set; } public override bool Execute() diff --git a/build_projects/dotnet-cli-build/CompileTargets.cs b/build_projects/dotnet-cli-build/CompileTargets.cs index bd635ed90..3d0c84c87 100644 --- a/build_projects/dotnet-cli-build/CompileTargets.cs +++ b/build_projects/dotnet-cli-build/CompileTargets.cs @@ -1,402 +1,373 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Build.Utilities; -using Microsoft.DotNet.Cli.Build.Framework; -using Microsoft.DotNet.InternalAbstractions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; -using static Microsoft.DotNet.Cli.Build.FS; - -namespace Microsoft.DotNet.Cli.Build -{ - public class CompileTargets : Task - { - public static readonly bool IsWinx86 = CurrentPlatform.IsWindows && CurrentArchitecture.Isx86; - - public static readonly string[] BinariesForCoreHost = new[] - { - "csc" - }; - - public static readonly string[] ProjectsToPublish = new[] - { - "dotnet" - }; - - public static readonly string[] FilesToClean = new[] - { - "vbc.exe" - }; - - public static string HostPackagePlatformRid => HostPackageSupportedRids[ - (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) - ? $"win7-{RuntimeEnvironment.RuntimeArchitecture}" - : RuntimeEnvironment.GetRuntimeIdentifier()]; - - public static readonly Dictionary HostPackageSupportedRids = new Dictionary() - { - // Key: Current platform RID. Value: The actual publishable (non-dummy) package name produced by the build system for this RID. - { "win7-x64", "win7-x64" }, - { "win7-x86", "win7-x86" }, - { "osx.10.10-x64", "osx.10.10-x64" }, - { "osx.10.11-x64", "osx.10.10-x64" }, - { "ubuntu.14.04-x64", "ubuntu.14.04-x64" }, - { "ubuntu.16.04-x64", "ubuntu.16.04-x64" }, - { "centos.7-x64", "rhel.7-x64" }, - { "rhel.7-x64", "rhel.7-x64" }, - { "rhel.7.2-x64", "rhel.7-x64" }, - { "debian.8-x64", "debian.8-x64" }, - { "fedora.23-x64", "fedora.23-x64" }, - { "opensuse.13.2-x64", "opensuse.13.2-x64" } - }; - - public const string SharedFrameworkName = "Microsoft.NETCore.App"; - - public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); - - public override bool Execute() - { - BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly().CreateBuildContext(); - BuildTargetContext c = new BuildTargetContext(context, null, null); - - return Compile(c).Success; - } - - [Target] - public static BuildTargetResult Compile(BuildTargetContext c) - { - PrepareTargets.Init(c); - CompileStage1(c); - CompileStage2(c); - - return c.Success(); - } - - public static BuildTargetResult CompileStage1(BuildTargetContext c) - { - CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); - - if (Directory.Exists(Dirs.Stage1)) - { - Utils.DeleteDirectory(Dirs.Stage1); - } - Directory.CreateDirectory(Dirs.Stage1); - - var result = CompileCliSdk(c, - dotnet: DotNetCli.Stage0, - rootOutputDirectory: Dirs.Stage1); - - CleanOutputDir(Path.Combine(Dirs.Stage1, "sdk")); - FS.CopyRecursive(Dirs.Stage1, Dirs.Stage1Symbols); - - RemovePdbsFromDir(Path.Combine(Dirs.Stage1, "sdk")); - - return result; - } - - public static BuildTargetResult CompileStage2(BuildTargetContext c) - { - var configuration = c.BuildContext.Get("Configuration"); - - CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); - - if (Directory.Exists(Dirs.Stage2)) - { - Utils.DeleteDirectory(Dirs.Stage2); - } - Directory.CreateDirectory(Dirs.Stage2); - - var result = CompileCliSdk(c, - dotnet: DotNetCli.Stage1, - rootOutputDirectory: Dirs.Stage2, - generateNugetPackagesArchive: true); - - if (!result.Success) - { - return result; - } - - if (CurrentPlatform.IsWindows) - { - // build projects for nuget packages - var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging"); - Mkdirp(packagingOutputDir); - foreach (var project in PackageTargets.ProjectsToPack) - { - // Just build them, we'll pack later - var packBuildResult = DotNetCli.Stage1.Build( - "--build-base-path", - packagingOutputDir, - "--configuration", - configuration, - Path.Combine(c.BuildContext.BuildDirectory, "src", project)) - .Execute(); - - packBuildResult.EnsureSuccessful(); - } - } - - CleanOutputDir(Path.Combine(Dirs.Stage2, "sdk")); - FS.CopyRecursive(Dirs.Stage2, Dirs.Stage2Symbols); - - RemovePdbsFromDir(Path.Combine(Dirs.Stage2, "sdk")); - - return c.Success(); - } - - private static void CleanOutputDir(string directory) - { - foreach (var file in FilesToClean) - { - FS.RmFilesInDirRecursive(directory, file); - } - } - - private static void RemovePdbsFromDir(string directory) - { - FS.RmFilesInDirRecursive(directory, "*.pdb"); - } - - private static BuildTargetResult CompileCliSdk( - BuildTargetContext c, - DotNetCli dotnet, - string rootOutputDirectory, - bool generateNugetPackagesArchive = false) - { - var configuration = c.BuildContext.Get("Configuration"); - var buildVersion = c.BuildContext.Get("BuildVersion"); - var srcDir = Path.Combine(c.BuildContext.BuildDirectory, "src"); - var sdkOutputDirectory = Path.Combine(rootOutputDirectory, "sdk", buildVersion.NuGetVersion); - - CopySharedFramework(Dirs.SharedFrameworkPublish, rootOutputDirectory); - - FS.CleanBinObj(c, srcDir); - Rmdir(sdkOutputDirectory); - Mkdirp(sdkOutputDirectory); - - foreach (var project in ProjectsToPublish) - { - dotnet.Publish( - "--native-subdirectory", - "--output", sdkOutputDirectory, - "--configuration", configuration, - "--version-suffix", buildVersion.CommitCountString, - Path.Combine(srcDir, project)) - .Execute() - .EnsureSuccessful(); - } - - FixModeFlags(sdkOutputDirectory); - - string compilersProject = Path.Combine(Dirs.RepoRoot, "src", "compilers"); - dotnet.Publish(compilersProject, - "--output", - sdkOutputDirectory, - "--framework", - "netcoreapp1.0") - .Execute() - .EnsureSuccessful(); - - var compilersDeps = Path.Combine(sdkOutputDirectory, "compilers.deps.json"); - var compilersRuntimeConfig = Path.Combine(sdkOutputDirectory, "compilers.runtimeconfig.json"); - - var binaryToCorehostifyRelDir = Path.Combine("runtimes", "any", "native"); - var binaryToCorehostifyOutDir = Path.Combine(sdkOutputDirectory, binaryToCorehostifyRelDir); - // Corehostify binaries - foreach (var binaryToCorehostify in BinariesForCoreHost) - { - try - { - // Yes, it is .exe even on Linux. This is the managed exe we're working with - File.Copy(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.dll")); - File.Move(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.exe")); - var binaryToCoreHostifyDeps = Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json"); - - File.Copy(compilersDeps, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json")); - File.Copy(compilersRuntimeConfig, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".runtimeconfig.json")); - PublishMutationUtilties.ChangeEntryPointLibraryName(binaryToCoreHostifyDeps, binaryToCorehostify); - foreach (var binaryToRemove in new string[] { "csc", "vbc" }) - { - var assetPath = Path.Combine(binaryToCorehostifyRelDir, $"{binaryToRemove}.exe").Replace(Path.DirectorySeparatorChar, '/'); - RemoveAssetFromDepsPackages(binaryToCoreHostifyDeps, "runtimeTargets", assetPath); - RemoveAssetFromDepsPackages( - Path.Combine(sdkOutputDirectory, "dotnet.deps.json"), "runtimeTargets", assetPath); - } - } - catch (Exception ex) - { - return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}"); - } - } - - // cleanup compilers project output we don't need - PublishMutationUtilties.CleanPublishOutput( - sdkOutputDirectory, - "compilers", - deleteRuntimeConfigJson: true, - deleteDepsJson: true); - - // Crossgen SDK directory - var sharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion; - var sharedFrameworkNameVersionPath = SharedFrameworkPublisher.GetSharedFrameworkPublishPath( - rootOutputDirectory, - sharedFrameworkNugetVersion); - - // Copy Host to SDK Directory - File.Copy( - Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostBaseName), - Path.Combine(sdkOutputDirectory, $"corehost{Constants.ExeSuffix}"), - overwrite: true); - File.Copy( - Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostFxrBaseName), - Path.Combine(sdkOutputDirectory, HostArtifactNames.DotnetHostFxrBaseName), - overwrite: true); - File.Copy( - Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.HostPolicyBaseName), - Path.Combine(sdkOutputDirectory, HostArtifactNames.HostPolicyBaseName), - overwrite: true); - - CrossgenUtil.CrossgenDirectory( - sharedFrameworkNameVersionPath, - sdkOutputDirectory); - - // Generate .version file - var version = buildVersion.NuGetVersion; - var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; - File.WriteAllText(Path.Combine(sdkOutputDirectory, ".version"), content); - - if(generateNugetPackagesArchive) - { - GenerateNuGetPackagesArchive(c, dotnet, sdkOutputDirectory); - } - - CopyMSBuildTargetsToSDKRoot(sdkOutputDirectory); - - return c.Success(); - } - - private static void CopyMSBuildTargetsToSDKRoot(string sdkOutputDirectory) - { - var msbuildTargetsDirectory = Path.Combine(sdkOutputDirectory, "runtimes", "any", "native"); - - var filesToCopy = new List(); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.targets", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.Targets", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.props", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.overridetasks", SearchOption.AllDirectories)); - filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.tasks", SearchOption.AllDirectories)); - - foreach (var fileFullPath in filesToCopy) - { - var fileRelativePath = fileFullPath.Substring(msbuildTargetsDirectory.Length + 1); - var destinationFilePath = Path.Combine(sdkOutputDirectory, fileRelativePath); - - File.Copy(fileFullPath, destinationFilePath, true); - } - } - - private static void GenerateNuGetPackagesArchive( - BuildTargetContext c, - DotNetCli dotnet, - string sdkOutputDirectory) - { - var nuGetPackagesArchiveProject = Path.Combine(Dirs.Intermediate, "NuGetPackagesArchiveProject"); - var nuGetPackagesArchiveFolder = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchiveFolder"); - - RestoreNuGetPackagesArchive(dotnet, nuGetPackagesArchiveProject, nuGetPackagesArchiveFolder); - - CompressNuGetPackagesArchive(c, dotnet, nuGetPackagesArchiveFolder, sdkOutputDirectory); - } - - private static void RestoreNuGetPackagesArchive( - DotNetCli dotnet, - string nuGetPackagesArchiveProject, - string nuGetPackagesArchiveFolder) - { - Rmdir(nuGetPackagesArchiveProject); - Mkdirp(nuGetPackagesArchiveProject); - - Rmdir(nuGetPackagesArchiveFolder); - Mkdirp(nuGetPackagesArchiveFolder); - - dotnet.New() - .WorkingDirectory(nuGetPackagesArchiveProject) - .Execute() - .EnsureSuccessful(); - - dotnet.Restore("--packages", nuGetPackagesArchiveFolder) - .WorkingDirectory(nuGetPackagesArchiveProject) - .Execute() - .EnsureSuccessful(); - } - - private static void CompressNuGetPackagesArchive( - BuildTargetContext c, - DotNetCli dotnet, - string nuGetPackagesArchiveFolder, - string sdkOutputDirectory) - { - var configuration = c.BuildContext.Get("Configuration"); - var archiverExe = Path.Combine(Dirs.Output, "tools", $"Archiver{Constants.ExeSuffix}"); - var intermediateArchive = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchive.lzma"); - var finalArchive = Path.Combine(sdkOutputDirectory, "nuGetPackagesArchive.lzma"); - - Rm(intermediateArchive); - Rm($"{intermediateArchive}.zip"); - - c.Info("Publishing Archiver"); - dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) - .WorkingDirectory(Path.Combine(Dirs.RepoRoot, "tools", "Archiver")) - .Execute() - .EnsureSuccessful(); - - Cmd(archiverExe, - "-a", intermediateArchive, - nuGetPackagesArchiveFolder) - .Execute(); - - File.Copy(intermediateArchive, finalArchive); - } - - private static void RemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath) - { - JToken deps; - using (var file = File.OpenText(depsFile)) - using (JsonTextReader reader = new JsonTextReader(file)) - { - deps = JObject.ReadFrom(reader); - } - - foreach (JProperty target in deps["targets"]) - { - foreach (JProperty pv in target.Value.Children()) - { - var section = pv.Value[sectionName]; - if (section != null) - { - foreach (JProperty relPath in section) - { - if (assetPath.Equals(relPath.Name)) - { - relPath.Remove(); - break; - } - } - } - } - } - using (var file = File.CreateText(depsFile)) - using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) - { - deps.WriteTo(writer); - } - } - - private static void CopySharedFramework(string sharedFrameworkPublish, string rootOutputDirectory) - { - CopyRecursive(sharedFrameworkPublish, rootOutputDirectory); - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.Build.Utilities; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.DotNet.InternalAbstractions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; +using static Microsoft.DotNet.Cli.Build.FS; + +namespace Microsoft.DotNet.Cli.Build +{ + public class CompileTargets : Task + { + public static readonly bool IsWinx86 = CurrentPlatform.IsWindows && CurrentArchitecture.Isx86; + + public static readonly string[] BinariesForCoreHost = new[] + { + "csc" + }; + + public static readonly string[] ProjectsToPublish = new[] + { + "dotnet" + }; + + public static readonly string[] FilesToClean = new[] + { + "vbc.exe" + }; + + public static string HostPackagePlatformRid => HostPackageSupportedRids[ + (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) + ? $"win7-{RuntimeEnvironment.RuntimeArchitecture}" + : RuntimeEnvironment.GetRuntimeIdentifier()]; + + public static readonly Dictionary HostPackageSupportedRids = new Dictionary() + { + // Key: Current platform RID. Value: The actual publishable (non-dummy) package name produced by the build system for this RID. + { "win7-x64", "win7-x64" }, + { "win7-x86", "win7-x86" }, + { "osx.10.10-x64", "osx.10.10-x64" }, + { "osx.10.11-x64", "osx.10.10-x64" }, + { "ubuntu.14.04-x64", "ubuntu.14.04-x64" }, + { "ubuntu.16.04-x64", "ubuntu.16.04-x64" }, + { "centos.7-x64", "rhel.7-x64" }, + { "rhel.7-x64", "rhel.7-x64" }, + { "rhel.7.2-x64", "rhel.7-x64" }, + { "debian.8-x64", "debian.8-x64" }, + { "fedora.23-x64", "fedora.23-x64" }, + { "opensuse.13.2-x64", "opensuse.13.2-x64" } + }; + + public const string SharedFrameworkName = "Microsoft.NETCore.App"; + + public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); + + public override bool Execute() + { + BuildContext context = new BuildSetup("MSBuild").UseAllTargetsFromAssembly().CreateBuildContext(); + BuildTargetContext c = new BuildTargetContext(context, null, null); + + return Compile(c).Success; + } + + [Target] + public static BuildTargetResult Compile(BuildTargetContext c) + { + PrepareTargets.Init(c); + CompileStage1(c); + CompileStage2(c); + + return c.Success(); + } + + public static BuildTargetResult CompileStage1(BuildTargetContext c) + { + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + + if (Directory.Exists(Dirs.Stage1)) + { + Utils.DeleteDirectory(Dirs.Stage1); + } + Directory.CreateDirectory(Dirs.Stage1); + + var result = CompileCliSdk(c, + dotnet: DotNetCli.Stage0, + rootOutputDirectory: Dirs.Stage1); + + CleanOutputDir(Path.Combine(Dirs.Stage1, "sdk")); + FS.CopyRecursive(Dirs.Stage1, Dirs.Stage1Symbols); + + RemovePdbsFromDir(Path.Combine(Dirs.Stage1, "sdk")); + + return result; + } + + public static BuildTargetResult CompileStage2(BuildTargetContext c) + { + var configuration = c.BuildContext.Get("Configuration"); + + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + + if (Directory.Exists(Dirs.Stage2)) + { + Utils.DeleteDirectory(Dirs.Stage2); + } + Directory.CreateDirectory(Dirs.Stage2); + + var result = CompileCliSdk(c, + dotnet: DotNetCli.Stage1, + rootOutputDirectory: Dirs.Stage2, + generateNugetPackagesArchive: true); + + if (!result.Success) + { + return result; + } + + if (CurrentPlatform.IsWindows) + { + // build projects for nuget packages + var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging"); + Mkdirp(packagingOutputDir); + foreach (var project in PackageTargets.ProjectsToPack) + { + // Just build them, we'll pack later + var packBuildResult = DotNetCli.Stage1.Build( + "--build-base-path", + packagingOutputDir, + "--configuration", + configuration, + Path.Combine(c.BuildContext.BuildDirectory, "src", project)) + .Execute(); + + packBuildResult.EnsureSuccessful(); + } + } + + CleanOutputDir(Path.Combine(Dirs.Stage2, "sdk")); + FS.CopyRecursive(Dirs.Stage2, Dirs.Stage2Symbols); + + RemovePdbsFromDir(Path.Combine(Dirs.Stage2, "sdk")); + + return c.Success(); + } + + private static void CleanOutputDir(string directory) + { + foreach (var file in FilesToClean) + { + FS.RmFilesInDirRecursive(directory, file); + } + } + + private static void RemovePdbsFromDir(string directory) + { + FS.RmFilesInDirRecursive(directory, "*.pdb"); + } + + private static BuildTargetResult CompileCliSdk( + BuildTargetContext c, + DotNetCli dotnet, + string rootOutputDirectory, + bool generateNugetPackagesArchive = false) + { + var configuration = c.BuildContext.Get("Configuration"); + var buildVersion = c.BuildContext.Get("BuildVersion"); + var srcDir = Path.Combine(c.BuildContext.BuildDirectory, "src"); + var sdkOutputDirectory = Path.Combine(rootOutputDirectory, "sdk", buildVersion.NuGetVersion); + + CopySharedFramework(Dirs.SharedFrameworkPublish, rootOutputDirectory); + + FS.CleanBinObj(c, srcDir); + Rmdir(sdkOutputDirectory); + Mkdirp(sdkOutputDirectory); + + foreach (var project in ProjectsToPublish) + { + dotnet.Publish( + "--native-subdirectory", + "--output", sdkOutputDirectory, + "--configuration", configuration, + "--version-suffix", buildVersion.CommitCountString, + Path.Combine(srcDir, project)) + .Execute() + .EnsureSuccessful(); + } + + FixModeFlags(sdkOutputDirectory); + + string compilersProject = Path.Combine(Dirs.RepoRoot, "src", "compilers"); + dotnet.Publish(compilersProject, + "--output", + sdkOutputDirectory, + "--framework", + "netcoreapp1.0") + .Execute() + .EnsureSuccessful(); + + var compilersDeps = Path.Combine(sdkOutputDirectory, "compilers.deps.json"); + var compilersRuntimeConfig = Path.Combine(sdkOutputDirectory, "compilers.runtimeconfig.json"); + + var binaryToCorehostifyRelDir = Path.Combine("runtimes", "any", "native"); + var binaryToCorehostifyOutDir = Path.Combine(sdkOutputDirectory, binaryToCorehostifyRelDir); + // Corehostify binaries + foreach (var binaryToCorehostify in BinariesForCoreHost) + { + try + { + // Yes, it is .exe even on Linux. This is the managed exe we're working with + File.Copy(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.dll")); + File.Move(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(sdkOutputDirectory, $"{binaryToCorehostify}.exe")); + var binaryToCoreHostifyDeps = Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json"); + + File.Copy(compilersDeps, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".deps.json")); + File.Copy(compilersRuntimeConfig, Path.Combine(sdkOutputDirectory, binaryToCorehostify + ".runtimeconfig.json")); + PublishMutationUtilties.ChangeEntryPointLibraryName(binaryToCoreHostifyDeps, binaryToCorehostify); + foreach (var binaryToRemove in new string[] { "csc", "vbc" }) + { + var assetPath = Path.Combine(binaryToCorehostifyRelDir, $"{binaryToRemove}.exe").Replace(Path.DirectorySeparatorChar, '/'); + RemoveAssetFromDepsPackages.DoRemoveAssetFromDepsPackages( + binaryToCoreHostifyDeps, + "runtimeTargets", + assetPath); + RemoveAssetFromDepsPackages.DoRemoveAssetFromDepsPackages( + Path.Combine(sdkOutputDirectory, "dotnet.deps.json"), + "runtimeTargets", + assetPath); + } + } + catch (Exception ex) + { + return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}"); + } + } + + // cleanup compilers project output we don't need + PublishMutationUtilties.CleanPublishOutput( + sdkOutputDirectory, + "compilers", + deleteRuntimeConfigJson: true, + deleteDepsJson: true); + + // Crossgen SDK directory + var sharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion; + var sharedFrameworkNameVersionPath = SharedFrameworkPublisher.GetSharedFrameworkPublishPath( + rootOutputDirectory, + sharedFrameworkNugetVersion); + + // Copy Host to SDK Directory + File.Copy( + Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostBaseName), + Path.Combine(sdkOutputDirectory, $"corehost{Constants.ExeSuffix}"), + overwrite: true); + File.Copy( + Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.DotnetHostFxrBaseName), + Path.Combine(sdkOutputDirectory, HostArtifactNames.DotnetHostFxrBaseName), + overwrite: true); + File.Copy( + Path.Combine(sharedFrameworkNameVersionPath, HostArtifactNames.HostPolicyBaseName), + Path.Combine(sdkOutputDirectory, HostArtifactNames.HostPolicyBaseName), + overwrite: true); + + CrossgenUtil.CrossgenDirectory( + sharedFrameworkNameVersionPath, + sdkOutputDirectory); + + // Generate .version file + var version = buildVersion.NuGetVersion; + var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; + File.WriteAllText(Path.Combine(sdkOutputDirectory, ".version"), content); + + if(generateNugetPackagesArchive) + { + GenerateNuGetPackagesArchive(c, dotnet, sdkOutputDirectory); + } + + CopyMSBuildTargetsToSDKRoot(sdkOutputDirectory); + + return c.Success(); + } + + private static void CopyMSBuildTargetsToSDKRoot(string sdkOutputDirectory) + { + var msbuildTargetsDirectory = Path.Combine(sdkOutputDirectory, "runtimes", "any", "native"); + + var filesToCopy = new List(); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.targets", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.Targets", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.props", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.overridetasks", SearchOption.AllDirectories)); + filesToCopy.AddRange(Directory.EnumerateFiles(msbuildTargetsDirectory, "*.tasks", SearchOption.AllDirectories)); + + foreach (var fileFullPath in filesToCopy) + { + var fileRelativePath = fileFullPath.Substring(msbuildTargetsDirectory.Length + 1); + var destinationFilePath = Path.Combine(sdkOutputDirectory, fileRelativePath); + + File.Copy(fileFullPath, destinationFilePath, true); + } + } + + private static void GenerateNuGetPackagesArchive( + BuildTargetContext c, + DotNetCli dotnet, + string sdkOutputDirectory) + { + var nuGetPackagesArchiveProject = Path.Combine(Dirs.Intermediate, "NuGetPackagesArchiveProject"); + var nuGetPackagesArchiveFolder = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchiveFolder"); + + RestoreNuGetPackagesArchive(dotnet, nuGetPackagesArchiveProject, nuGetPackagesArchiveFolder); + + CompressNuGetPackagesArchive(c, dotnet, nuGetPackagesArchiveFolder, sdkOutputDirectory); + } + + private static void RestoreNuGetPackagesArchive( + DotNetCli dotnet, + string nuGetPackagesArchiveProject, + string nuGetPackagesArchiveFolder) + { + Rmdir(nuGetPackagesArchiveProject); + Mkdirp(nuGetPackagesArchiveProject); + + Rmdir(nuGetPackagesArchiveFolder); + Mkdirp(nuGetPackagesArchiveFolder); + + dotnet.New() + .WorkingDirectory(nuGetPackagesArchiveProject) + .Execute() + .EnsureSuccessful(); + + dotnet.Restore("--packages", nuGetPackagesArchiveFolder) + .WorkingDirectory(nuGetPackagesArchiveProject) + .Execute() + .EnsureSuccessful(); + } + + private static void CompressNuGetPackagesArchive( + BuildTargetContext c, + DotNetCli dotnet, + string nuGetPackagesArchiveFolder, + string sdkOutputDirectory) + { + var configuration = c.BuildContext.Get("Configuration"); + var archiverExe = Path.Combine(Dirs.Output, "tools", $"Archiver{Constants.ExeSuffix}"); + var intermediateArchive = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchive.lzma"); + var finalArchive = Path.Combine(sdkOutputDirectory, "nuGetPackagesArchive.lzma"); + + Rm(intermediateArchive); + Rm($"{intermediateArchive}.zip"); + + c.Info("Publishing Archiver"); + dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) + .WorkingDirectory(Path.Combine(Dirs.RepoRoot, "tools", "Archiver")) + .Execute() + .EnsureSuccessful(); + + Cmd(archiverExe, + "-a", intermediateArchive, + nuGetPackagesArchiveFolder) + .Execute(); + + File.Copy(intermediateArchive, finalArchive); + } + + private static void CopySharedFramework(string sharedFrameworkPublish, string rootOutputDirectory) + { + CopyRecursive(sharedFrameworkPublish, rootOutputDirectory); + } + } +} diff --git a/build_projects/dotnet-cli-build/CrossgenDirectory.cs b/build_projects/dotnet-cli-build/CrossgenDirectory.cs index 5010295e3..f38baeb8d 100644 --- a/build_projects/dotnet-cli-build/CrossgenDirectory.cs +++ b/build_projects/dotnet-cli-build/CrossgenDirectory.cs @@ -16,15 +16,23 @@ namespace Microsoft.DotNet.Cli.Build { public class CrossgenDirectory : Task { - private static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); + [Required] + public string CoreCLRVersion { get; set; } + [Required] + public string JitVersion { get; set; } + + [Required] public string SharedFrameworkNameVersionPath { get; set; } + [Required] public string SdkOutputDirectory { get; set; } public override bool Execute() { - CrossgenUtil.CrossgenDirectory(SharedFrameworkNameVersionPath, SdkOutputDirectory); + var crossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion); + + crossgenUtil.CrossgenDirectory(SharedFrameworkNameVersionPath, SdkOutputDirectory); return true; } diff --git a/build_projects/dotnet-cli-build/FixModeFlags.cs b/build_projects/dotnet-cli-build/FixModeFlags.cs index 225a82a6e..ab2961942 100644 --- a/build_projects/dotnet-cli-build/FixModeFlags.cs +++ b/build_projects/dotnet-cli-build/FixModeFlags.cs @@ -16,6 +16,7 @@ namespace Microsoft.DotNet.Cli.Build { public class FixModeFlags : Task { + [Required] public string Dir { get; set; } public override bool Execute() diff --git a/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs b/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs index 9d37583fd..e3ea94620 100644 --- a/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs +++ b/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs @@ -18,10 +18,13 @@ namespace Microsoft.DotNet.Cli.Build { public class RemoveAssetFromDepsPackages : Task { + [Required] public string DepsFile { get; set; } + [Required] public string SectionName { get; set; } + [Required] public string AssetPath { get; set; } public override bool Execute() @@ -31,7 +34,7 @@ namespace Microsoft.DotNet.Cli.Build return true; } - private static void DoRemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath) + public static void DoRemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath) { JToken deps; using (var file = File.OpenText(depsFile)) diff --git a/build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs b/build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs deleted file mode 100644 index 59bb39e49..000000000 --- a/build_projects/dotnet-cli-build/SharedFrameworkNameVersionPath.cs +++ /dev/null @@ -1,34 +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 SharedFrameworkNameVersionPath : Task - { - public string RootOutputDirectory { get; set; } - - [Output] - public string OutputSharedFrameworkNameVersionPath { get; set; } - - public override bool Execute() - { - var sharedFrameworkNugetVersion = CliDependencyVersions.SharedFrameworkVersion; - OutputSharedFrameworkNameVersionPath = SharedFrameworkPublisher.GetSharedFrameworkPublishPath( - RootOutputDirectory, - sharedFrameworkNugetVersion); - - return true; - } - } -} diff --git a/tools/Archiver/project.json b/tools/Archiver/project.json index 899fd6995..d389e713e 100644 --- a/tools/Archiver/project.json +++ b/tools/Archiver/project.json @@ -16,5 +16,18 @@ }, "frameworks": { "netcoreapp1.0": {} + }, + "runtimes": { + "win7-x64": {}, + "win7-x86": {}, + "osx.10.10-x64": {}, + "osx.10.11-x64": {}, + "ubuntu.14.04-x64": {}, + "ubuntu.16.04-x64": {}, + "centos.7-x64": {}, + "rhel.7.2-x64": {}, + "debian.8-x64": {}, + "fedora.23-x64": {}, + "opensuse.13.2-x64": {} } } diff --git a/tools/MultiProjectValidator/project.json b/tools/MultiProjectValidator/project.json index 0edf465ca..7409d24c8 100644 --- a/tools/MultiProjectValidator/project.json +++ b/tools/MultiProjectValidator/project.json @@ -19,5 +19,18 @@ "dnxcore50" ] } + }, + "runtimes": { + "win7-x64": {}, + "win7-x86": {}, + "osx.10.10-x64": {}, + "osx.10.11-x64": {}, + "ubuntu.14.04-x64": {}, + "ubuntu.16.04-x64": {}, + "centos.7-x64": {}, + "rhel.7.2-x64": {}, + "debian.8-x64": {}, + "fedora.23-x64": {}, + "opensuse.13.2-x64": {} } } From 2846a9b2e727d96abb542728f14a81dca2233310 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 30 Jun 2016 16:13:55 -0700 Subject: [PATCH 08/11] Fixing an issue where there was a new line in the path to dotnet.exe in the sharedframework and added incrementality to BuildProjectsForNuGetPackages. --- build/Microsoft.DotNet.Cli.Compile.targets | 4 +- .../Microsoft.DotNet.Cli.Nupkg.targets | 75 ++++++++++++++++++- 2 files changed, 72 insertions(+), 7 deletions(-) diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index cfd97e5be..d831479ae 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -65,9 +65,7 @@ Microsoft.NETCore.App 1.0.0 - - $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkNuGetVersion) - + $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkNuGetVersion) diff --git a/build/package/Microsoft.DotNet.Cli.Nupkg.targets b/build/package/Microsoft.DotNet.Cli.Nupkg.targets index ddb61ba9c..f100595e9 100644 --- a/build/package/Microsoft.DotNet.Cli.Nupkg.targets +++ b/build/package/Microsoft.DotNet.Cli.Nupkg.targets @@ -11,46 +11,111 @@ - + + + + + + + + + + + + + + + + + + + + + + + @(MicrosoftDotNetCliUtilsInputs) + @(MicrosoftDotNetCliUtilsOutputs) Microsoft.DotNet.Cli.Utils $(SdkNugetVersion) + @(MicrosoftDotNetCompilerCommonInputs) + @(MicrosoftDotNetCompilerCommonOutputs) Microsoft.DotNet.Compiler.Common $(SdkNugetVersion) + @(MicrosoftDotNetFilesInputs) + @(MicrosoftDotNetFilesOutputs) Microsoft.DotNet.Files $(SdkNugetVersion) + @(MicrosoftDotNetInternalAbstractionsInputs) + @(MicrosoftDotNetInternalAbstractionsOutputs) Microsoft.DotNet.InternalAbstractions $(DependencyModelAndInternalAbstractionsNugetVersion) + @(MicrosoftDotNetProjectModelInputs) + @(MicrosoftDotNetProjectModelOutputs) Microsoft.DotNet.ProjectModel $(ProjectModelNugetVersion) + @(MicrosoftDotNetProjectModelLoaderInputs) + @(MicrosoftDotNetProjectModelLoaderOutputs) Microsoft.DotNet.ProjectModel.Loader $(SdkNugetVersion) + @(MicrosoftDotNetProjectModelWorkspacesInputs) + @(MicrosoftDotNetProjectModelWorkspacesOutputs) Microsoft.DotNet.ProjectModel.Workspaces $(SdkNugetVersion) + @(MicrosoftExtensionsDependencyModelInputs) + @(MicrosoftExtensionsDependencyModelOutputs) Microsoft.Extensions.DependencyModel $(DependencyModelAndInternalAbstractionsNugetVersion) + @(MicrosoftExtensionsTestingAbstractionsInputs) + @(MicrosoftExtensionsTestingAbstractionsOutputs) Microsoft.Extensions.Testing.Abstractions $(SdkNugetVersion) - + - @@ -70,7 +135,9 @@ + Condition=" '$(OS)' == 'Windows_NT' " + Inputs="%(ProjectsToPack.Inputs)" + Outputs="%(ProjectsToPack.Outputs)"> -NoRun --norun - + Prepare;Compile;Test;Package;Publish $(MSBuildThisFileDirectory)/build_projects/dotnet-cli-build/bin/dotnet-cli-build $(CLIBuildFileName).dll Debug $(MSBuildThisFileDirectory) - + preview + Microsoft.NETCore.App 1.0.0 1.0.1 1.0.1 + + 1.0.2 + 1.0.2 diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index d831479ae..7397926cf 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -7,12 +7,11 @@ - - + GenerateNuGetPackagesArchive" /> @@ -62,10 +61,8 @@ runtimes/any/native $(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir) $(SdkOutputDirectory)/runtimes/any/native - - Microsoft.NETCore.App - 1.0.0 - $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkNuGetVersion) + + $(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkVersion) diff --git a/build/package/Microsoft.DotNet.Cli.Nupkg.targets b/build/package/Microsoft.DotNet.Cli.Nupkg.targets index f100595e9..ddb61ba9c 100644 --- a/build/package/Microsoft.DotNet.Cli.Nupkg.targets +++ b/build/package/Microsoft.DotNet.Cli.Nupkg.targets @@ -11,111 +11,46 @@ - - - - - - - - - - - - - - - - - - - - - - - @(MicrosoftDotNetCliUtilsInputs) - @(MicrosoftDotNetCliUtilsOutputs) + Microsoft.DotNet.Cli.Utils $(SdkNugetVersion) - @(MicrosoftDotNetCompilerCommonInputs) - @(MicrosoftDotNetCompilerCommonOutputs) Microsoft.DotNet.Compiler.Common $(SdkNugetVersion) - @(MicrosoftDotNetFilesInputs) - @(MicrosoftDotNetFilesOutputs) Microsoft.DotNet.Files $(SdkNugetVersion) - @(MicrosoftDotNetInternalAbstractionsInputs) - @(MicrosoftDotNetInternalAbstractionsOutputs) Microsoft.DotNet.InternalAbstractions $(DependencyModelAndInternalAbstractionsNugetVersion) - @(MicrosoftDotNetProjectModelInputs) - @(MicrosoftDotNetProjectModelOutputs) Microsoft.DotNet.ProjectModel $(ProjectModelNugetVersion) - @(MicrosoftDotNetProjectModelLoaderInputs) - @(MicrosoftDotNetProjectModelLoaderOutputs) Microsoft.DotNet.ProjectModel.Loader $(SdkNugetVersion) - @(MicrosoftDotNetProjectModelWorkspacesInputs) - @(MicrosoftDotNetProjectModelWorkspacesOutputs) Microsoft.DotNet.ProjectModel.Workspaces $(SdkNugetVersion) - @(MicrosoftExtensionsDependencyModelInputs) - @(MicrosoftExtensionsDependencyModelOutputs) Microsoft.Extensions.DependencyModel $(DependencyModelAndInternalAbstractionsNugetVersion) - @(MicrosoftExtensionsTestingAbstractionsInputs) - @(MicrosoftExtensionsTestingAbstractionsOutputs) Microsoft.Extensions.Testing.Abstractions $(SdkNugetVersion) - + + @@ -135,9 +70,7 @@ + Condition=" '$(OS)' == 'Windows_NT' "> Date: Fri, 1 Jul 2016 11:02:26 -0700 Subject: [PATCH 10/11] Addressing more code review comments --- build.proj | 7 ++++--- build/Microsoft.DotNet.Cli.Compile.targets | 5 +++-- build/Microsoft.DotNet.Cli.Prepare.targets | 3 --- build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets | 7 ++++--- build/package/Microsoft.DotNet.Cli.Layout.targets | 6 +----- .../dotnet-cli-build/ChangeEntryPointLibraryName.cs | 3 +-- build_projects/dotnet-cli-build/CleanPublishOutput.cs | 3 +-- build_projects/dotnet-cli-build/CrossgenDirectory.cs | 3 +-- build_projects/dotnet-cli-build/FixModeFlags.cs | 3 +-- .../dotnet-cli-build/RemoveAssetFromDepsPackages.cs | 7 +++---- 10 files changed, 19 insertions(+), 28 deletions(-) diff --git a/build.proj b/build.proj index 44bc94833..3935e56a4 100644 --- a/build.proj +++ b/build.proj @@ -1,6 +1,7 @@ + diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index 7397926cf..46d2ca3ee 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -1,4 +1,5 @@ - + + @@ -70,7 +71,7 @@ - + diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index bb8441ae6..46aae457b 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -67,9 +67,6 @@ $(VersionMajor).$(VersionMinor).$(VersionPatch)-rc4-$(CommitCount) $(VersionMajor).$(VersionMinor).1-beta-$(CommitCount) - 1.0.2 - 1.0.2 - .zip .tar.gz diff --git a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets index 531cb000b..670ad4478 100644 --- a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets +++ b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets @@ -1,7 +1,8 @@ - + + @@ -28,7 +29,7 @@ + DependsOnTargets="Prepare;SetupStage"> $(IntermediateDirectory)/NuGetPackagesArchiveProject $(IntermediateDirectory)/NuGetPackagesArchiveFolder diff --git a/build/package/Microsoft.DotNet.Cli.Layout.targets b/build/package/Microsoft.DotNet.Cli.Layout.targets index 4c6036a4d..37809a7fd 100644 --- a/build/package/Microsoft.DotNet.Cli.Layout.targets +++ b/build/package/Microsoft.DotNet.Cli.Layout.targets @@ -56,11 +56,7 @@ @(SdkDebugLayoutInput) -<<<<<<< 52e9475be8e9dd9d6715a1f0787da3faa1137f8a - @(SdkDebugRelativeOutputFiles -> '$(SdkDebugLayoutOutputDirectory)/%(Identity)') -======= - @(SdkDebugLayoutInput -> '$(SdkDebugLayoutOutputDirectory)/$([MSBuild]::MakeRelative($(Stage2SymbolsDirectory), '%(Identity)'))') ->>>>>>> Addressing code review comments and making incremental build work. + @(SdkDebugRelativeOutputFiles -> '$(SdkDebugLayoutOutputDirectory)/%(Identity)') $(ArtifactNameWithVersionSdkDebug) $(ArtifactNameSdkDebug) diff --git a/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs b/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs index d309f8856..4eea67021 100644 --- a/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs +++ b/build_projects/dotnet-cli-build/ChangeEntryPointLibraryName.cs @@ -4,11 +4,10 @@ using System.IO; using System.IO.Compression; using System.Runtime.InteropServices; using System.Net.Http; +using Microsoft.Build.Framework; 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; diff --git a/build_projects/dotnet-cli-build/CleanPublishOutput.cs b/build_projects/dotnet-cli-build/CleanPublishOutput.cs index 02528b749..8ed3ba21c 100644 --- a/build_projects/dotnet-cli-build/CleanPublishOutput.cs +++ b/build_projects/dotnet-cli-build/CleanPublishOutput.cs @@ -4,11 +4,10 @@ using System.IO; using System.IO.Compression; using System.Runtime.InteropServices; using System.Net.Http; +using Microsoft.Build.Framework; 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; diff --git a/build_projects/dotnet-cli-build/CrossgenDirectory.cs b/build_projects/dotnet-cli-build/CrossgenDirectory.cs index ac5fb5067..2b03c012f 100644 --- a/build_projects/dotnet-cli-build/CrossgenDirectory.cs +++ b/build_projects/dotnet-cli-build/CrossgenDirectory.cs @@ -4,11 +4,10 @@ using System.IO; using System.IO.Compression; using System.Runtime.InteropServices; using System.Net.Http; +using Microsoft.Build.Framework; 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; diff --git a/build_projects/dotnet-cli-build/FixModeFlags.cs b/build_projects/dotnet-cli-build/FixModeFlags.cs index ab2961942..7caf97333 100644 --- a/build_projects/dotnet-cli-build/FixModeFlags.cs +++ b/build_projects/dotnet-cli-build/FixModeFlags.cs @@ -4,11 +4,10 @@ using System.IO; using System.IO.Compression; using System.Runtime.InteropServices; using System.Net.Http; +using Microsoft.Build.Framework; 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; diff --git a/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs b/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs index e3ea94620..f2395df23 100644 --- a/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs +++ b/build_projects/dotnet-cli-build/RemoveAssetFromDepsPackages.cs @@ -4,13 +4,12 @@ using System.IO; using System.IO.Compression; using System.Runtime.InteropServices; using System.Net.Http; +using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Microsoft.DotNet.Cli.Build.Framework; using Microsoft.DotNet.InternalAbstractions; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; From f66ec9a789d992cde040930d7433ee47c81de9f2 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Fri, 1 Jul 2016 20:46:54 -0700 Subject: [PATCH 11/11] Adding trailing slash back to OutputDirectory that I accidently removed when merging and improving the inputs for GenerateNuGetPackagesArchiveInputs to take into account the c# template and the dotnet-archive and Microsoft.Dotnet.Archive codes. --- build/Microsoft.DotNet.Cli.Prepare.targets | 2 +- .../compile/Microsoft.DotNet.Cli.LzmaArchive.targets | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 46aae457b..b5d76503d 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -36,7 +36,7 @@ $(BaseOutputDirectory)/stage2 $(BaseOutputDirectory)/stage2symbols $(Stage2Directory)/dotnet.exe - $(Stage2Directory) + $(Stage2Directory)/ $(BaseOutputDirectory)/stage2compilation $(BaseOutputDirectory)/intermediate $(BaseOutputDirectory)/packages diff --git a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets index 670ad4478..47873c488 100644 --- a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets +++ b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets @@ -2,7 +2,7 @@ @@ -37,5 +37,15 @@ $(IntermediateDirectory)/nuGetPackagesArchive.lzma $(Stage2Directory)/sdk/$(SdkVersion)/nuGetPackagesArchive.lzma + + + + + + \ No newline at end of file