public static BuildTargetResult GenerateBundles(BuildTargetContext c) { return(c.Success()); }
public static void PublishSharedFramework(BuildTargetContext c, string outputDir, DotNetCli dotnetCli) { string SharedFrameworkSourceRoot = Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "framework"); string SharedFrameworkNugetVersion = c.BuildContext.Get <string>("SharedFrameworkNugetVersion"); // We publish to a sub folder of the PublishRoot so tools like heat and zip can generate folder structures easier. string SharedFrameworkNameAndVersionRoot = Path.Combine(outputDir, "shared", SharedFrameworkName, SharedFrameworkNugetVersion); c.BuildContext["SharedFrameworkPath"] = SharedFrameworkNameAndVersionRoot; if (Directory.Exists(SharedFrameworkNameAndVersionRoot)) { Utils.DeleteDirectory(SharedFrameworkNameAndVersionRoot); } string publishFramework = "dnxcore50"; // Temporary, use "netcoreapp" when we update nuget. string publishRuntime; if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows) { publishRuntime = $"win7-{PlatformServices.Default.Runtime.RuntimeArchitecture}"; } else { publishRuntime = PlatformServices.Default.Runtime.GetRuntimeIdentifier(); } dotnetCli.Publish( "--output", SharedFrameworkNameAndVersionRoot, "-r", publishRuntime, "-f", publishFramework, SharedFrameworkSourceRoot).Execute().EnsureSuccessful(); // Clean up artifacts that dotnet-publish generates which we don't need DeleteMainPublishOutput(SharedFrameworkNameAndVersionRoot, "framework"); File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.runtimeconfig.json")); // Rename the .deps file var destinationDeps = Path.Combine(SharedFrameworkNameAndVersionRoot, $"{SharedFrameworkName}.deps.json"); File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.deps.json"), destinationDeps); // Generate RID fallback graph string runtimeGraphGeneratorRuntime = null; switch (PlatformServices.Default.Runtime.OperatingSystemPlatform) { case Platform.Windows: runtimeGraphGeneratorRuntime = "win"; break; case Platform.Linux: runtimeGraphGeneratorRuntime = "linux"; break; case Platform.Darwin: runtimeGraphGeneratorRuntime = "osx"; break; } if (!string.IsNullOrEmpty(runtimeGraphGeneratorRuntime)) { var runtimeGraphGeneratorName = "RuntimeGraphGenerator"; var runtimeGraphGeneratorProject = Path.Combine(Dirs.RepoRoot, "tools", runtimeGraphGeneratorName); var runtimeGraphGeneratorOutput = Path.Combine(Dirs.Output, "tools", runtimeGraphGeneratorName); dotnetCli.Publish( "--output", runtimeGraphGeneratorOutput, runtimeGraphGeneratorProject).Execute().EnsureSuccessful(); var runtimeGraphGeneratorExe = Path.Combine(runtimeGraphGeneratorOutput, $"{runtimeGraphGeneratorName}{Constants.ExeSuffix}"); Cmd(runtimeGraphGeneratorExe, "--project", SharedFrameworkSourceRoot, "--deps", destinationDeps, runtimeGraphGeneratorRuntime) .Execute() .EnsureSuccessful(); } else { c.Error($"Could not determine rid graph generation runtime for platform {PlatformServices.Default.Runtime.OperatingSystemPlatform}"); } // corehost will be renamed to dotnet at some point and then we will not need to rename it here. File.Copy( Path.Combine(Dirs.Corehost, CoreHostBaseName), Path.Combine(SharedFrameworkNameAndVersionRoot, $"dotnet{Constants.ExeSuffix}"), true); File.Copy( Path.Combine(Dirs.Corehost, CoreHostBaseName), Path.Combine(SharedFrameworkNameAndVersionRoot, CoreHostBaseName), true); File.Copy( Path.Combine(Dirs.Corehost, HostPolicyBaseName), Path.Combine(SharedFrameworkNameAndVersionRoot, HostPolicyBaseName), true); if (File.Exists(Path.Combine(SharedFrameworkNameAndVersionRoot, "mscorlib.ni.dll"))) { // Publish already places the crossgen'd version of mscorlib into the output, so we can // remove the IL version File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "mscorlib.dll")); } CrossgenSharedFx(c, SharedFrameworkNameAndVersionRoot); // Generate .version file for sharedfx var version = SharedFrameworkNugetVersion; var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; File.WriteAllText(Path.Combine(SharedFrameworkNameAndVersionRoot, ".version"), content); }
public static BuildTargetResult UpdateBuild(BuildTargetContext c) { return(c.Success()); }
public static BuildTargetResult SetupTestProjects(BuildTargetContext c) => c.Success();
public static BuildTargetResult Prepare(BuildTargetContext c) => c.Success();
public static BuildTargetResult CheckCoreclrPlatformDependencies(BuildTargetContext c) => c.Success();
public static BuildTargetResult Test(BuildTargetContext c) => c.Success();
public static BuildTargetResult PublishArchivesToAzure(BuildTargetContext c) => c.Success();
public static BuildTargetResult PublishDebFilesToDebianRepo(BuildTargetContext c) { return(c.Success()); }
public static BuildTargetResult PublishArtifacts(BuildTargetContext c) => c.Success();
public static BuildTargetResult PublishInstallerFilesToAzure(BuildTargetContext c) => c.Success();
public static BuildTargetResult Publish(BuildTargetContext c) { if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_BUILD_SKIP_PACKAGING"), "1", StringComparison.Ordinal)) { c.Info("Skipping packaging because DOTNET_BUILD_SKIP_PACKAGING is set"); return(c.Success()); } // NOTE(anurse): Currently, this just invokes the remaining build scripts as-is. We should port those to C# as well, but // I want to get the merged in. // Set up the environment variables previously defined by common.sh/ps1 // This is overkill, but I want to cover all the variables used in all OSes (including where some have the same names) var buildVersion = c.BuildContext.Get <BuildVersion>("BuildVersion"); var configuration = c.BuildContext.Get <string>("Configuration"); var env = new Dictionary <string, string>() { { "RID", PlatformServices.Default.Runtime.GetRuntimeIdentifier() }, { "OSNAME", PlatformServices.Default.Runtime.OperatingSystem }, { "TFM", "dnxcore50" }, { "OutputDir", Dirs.Output }, { "Stage1Dir", Dirs.Stage1 }, { "Stage1CompilationDir", Dirs.Stage1Compilation }, { "Stage2Dir", Dirs.Stage2 }, { "STAGE2_DIR", Dirs.Stage2 }, { "Stage2CompilationDir", Dirs.Stage2Compilation }, { "HostDir", Dirs.Corehost }, { "PackageDir", Path.Combine(Dirs.Packages, "dnvm") }, // Legacy name { "TestBinRoot", Dirs.TestOutput }, { "TestPackageDir", Dirs.TestPackages }, { "MajorVersion", buildVersion.Major.ToString() }, { "MinorVersion", buildVersion.Minor.ToString() }, { "PatchVersion", buildVersion.Patch.ToString() }, { "CommitCountVersion", buildVersion.CommitCountString }, { "COMMIT_COUNT_VERSION", buildVersion.CommitCountString }, { "DOTNET_CLI_VERSION", buildVersion.SimpleVersion }, { "DOTNET_MSI_VERSION", buildVersion.GenerateMsiVersion() }, { "VersionSuffix", buildVersion.VersionSuffix }, { "CONFIGURATION", configuration } }; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { env["OSNAME"] = "osx"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Cmd("powershell", "-NoProfile", "-NoLogo", Path.Combine(c.BuildContext.BuildDirectory, "scripts", "package", "package.ps1")) .Environment(env) .Execute() .EnsureSuccessful(); } else { // Can directly execute scripts on Unix :). Thank you shebangs! Cmd(Path.Combine(c.BuildContext.BuildDirectory, "scripts", "package", "package.sh")) .Environment(env) .Execute() .EnsureSuccessful(); } return(c.Success()); }
public static BuildTargetResult ReattachEngineToBundle(BuildTargetContext c) { ReattachEngineToBundleHelper(SdkBundle, SdkEngine); return(c.Success()); }
public static BuildTargetResult ExtractEngineFromBundle(BuildTargetContext c) { ExtractEngineFromBundleHelper(SdkBundle, SdkEngine); return(c.Success()); }
public static BuildTargetResult GenerateInstaller(BuildTargetContext c) { return(c.Success()); }
public static BuildTargetResult PublishCombinedFrameworkSDKHostInstallerFileToAzure(BuildTargetContext c) { var version = CliNuGetVersion; var installerFile = c.BuildContext.Get <string>("CombinedFrameworkSDKHostInstallerFile"); AzurePublisherTool.PublishInstallerFile(installerFile, Channel, version); return(c.Success()); }
public static BuildTargetResult CheckPrereqs(BuildTargetContext c) => c.Success();
public static BuildTargetResult PublishCombinedHostFrameworkSdkArchiveToAzure(BuildTargetContext c) { var version = CliNuGetVersion; var archiveFile = c.BuildContext.Get <string>("CombinedFrameworkSDKHostCompressedFile"); AzurePublisherTool.PublishArchive(archiveFile, Channel, version); return(c.Success()); }
public static BuildTargetResult CheckInstallerBuildPlatformDependencies(BuildTargetContext c) => c.Success();
[Environment("PUBLISH_TO_AZURE_BLOB", "1", "true")] // This is set by CI systems public static BuildTargetResult Publish(BuildTargetContext c) { return(c.Success()); }
public static BuildTargetResult SetupTestPackages(BuildTargetContext c) => c.Success();
public static BuildTargetResult FinalizeBuild(BuildTargetContext c) { if (CheckIfAllBuildsHavePublished()) { string targetContainer = $"{Channel}/Binaries/Latest/"; string targetVersionFile = $"{targetContainer}{CliNuGetVersion}"; string semaphoreBlob = $"{Channel}/Binaries/publishSemaphore"; AzurePublisherTool.CreateBlobIfNotExists(semaphoreBlob); string leaseId = AzurePublisherTool.AcquireLeaseOnBlob(semaphoreBlob); // Prevent race conditions by dropping a version hint of what version this is. If we see this file // and it is the same as our version then we know that a race happened where two+ builds finished // at the same time and someone already took care of publishing and we have no work to do. if (AzurePublisherTool.IsLatestSpecifiedVersion(targetVersionFile)) { AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId); return(c.Success()); } else { // This is an old drop of latest so remove all old files to ensure a clean state AzurePublisherTool.ListBlobs($"{targetContainer}") .Select(s => s.Replace("/dotnet/", "")) .ToList() .ForEach(f => AzurePublisherTool.TryDeleteBlob(f)); // Drop the version file signaling such for any race-condition builds (see above comment). AzurePublisherTool.DropLatestSpecifiedVersion(targetVersionFile); } try { // Copy the latest CLI bits CopyBlobs($"{Channel}/Binaries/{CliNuGetVersion}/", targetContainer); // Copy the shared framework CopyBlobs($"{Channel}/Binaries/{SharedFrameworkNugetVersion}/", targetContainer); // Copy the latest installer files CopyBlobs($"{Channel}/Installers/{CliNuGetVersion}/", $"{Channel}/Installers/Latest/"); // Copy the shared framework installers CopyBlobs($"{Channel}/Installers/{SharedFrameworkNugetVersion}/", $"{Channel}/Installers/Latest/"); // Copy the shared host installers CopyBlobs($"{Channel}/Installers/{SharedHostNugetVersion}/", $"{Channel}/Installers/Latest/"); // Generate the CLI and SDK Version text files List <string> versionFiles = new List <string>() { "win.x86.version", "win.x64.version", "ubuntu.x64.version", "rhel.x64.version", "osx.x64.version", "debian.x64.version", "centos.x64.version" }; string cliVersion = Utils.GetCliVersionFileContent(c); string sfxVersion = Utils.GetSharedFrameworkVersionFileContent(c); foreach (string version in versionFiles) { AzurePublisherTool.PublishStringToBlob($"{Channel}/dnvm/latest.{version}", cliVersion); AzurePublisherTool.PublishStringToBlob($"{Channel}/dnvm/latest.sharedfx.{version}", sfxVersion); } } finally { AzurePublisherTool.ReleaseLeaseOnBlob(semaphoreBlob, leaseId); } } return(c.Success()); }
public static BuildTargetResult CheckPackageCache(BuildTargetContext c) { var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal); if (ciBuild) { // On CI, HOME is redirected under the repo, which gets deleted after every build. // So make NUGET_PACKAGES outside of the repo. var nugetPackages = Path.GetFullPath(Path.Combine(c.BuildContext.BuildDirectory, "..", ".nuget", "packages")); Environment.SetEnvironmentVariable("NUGET_PACKAGES", nugetPackages); Dirs.NuGetPackages = nugetPackages; } // Set the package cache location in NUGET_PACKAGES just to be safe if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_PACKAGES"))) { Environment.SetEnvironmentVariable("NUGET_PACKAGES", Dirs.NuGetPackages); } CleanNuGetTempCache(); // Determine cache expiration time var cacheExpiration = 7 * 24; // cache expiration in hours var cacheExpirationStr = Environment.GetEnvironmentVariable("NUGET_PACKAGES_CACHE_TIME_LIMIT"); if (!string.IsNullOrEmpty(cacheExpirationStr)) { cacheExpiration = int.Parse(cacheExpirationStr); } if (ciBuild) { var cacheTimeFile = Path.Combine(Dirs.NuGetPackages, "packageCacheTime.txt"); DateTime?cacheTime = null; try { // Read the cache file if (File.Exists(cacheTimeFile)) { var content = File.ReadAllText(cacheTimeFile); if (!string.IsNullOrEmpty(content)) { cacheTime = DateTime.ParseExact("O", content, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); } } } catch (Exception ex) { c.Warn($"Error reading NuGet cache time file, leaving the cache alone"); c.Warn($"Error Detail: {ex.ToString()}"); } if (cacheTime == null || (cacheTime.Value.AddHours(cacheExpiration) < DateTime.UtcNow)) { // Cache has expired or the status is unknown, clear it and write the file c.Info("Clearing NuGet cache"); Rmdir(Dirs.NuGetPackages); Mkdirp(Dirs.NuGetPackages); File.WriteAllText(cacheTimeFile, DateTime.UtcNow.ToString("O")); } } return(c.Success()); }
public static BuildTargetResult SetNuGetPackagesDir(BuildTargetContext c) { Environment.SetEnvironmentVariable("NUGET_PACKAGES", Dirs.NuGetPackages); return(c.Success()); }
public static BuildTargetResult PackageCoreHost(BuildTargetContext c) { if (!string.Equals(Environment.GetEnvironmentVariable("BUILD_COREHOST_PACKAGES"), "1")) { return(c.Success()); } var buildVersion = c.BuildContext.Get <BuildVersion>("BuildVersion"); var versionTag = buildVersion.ReleaseSuffix; var buildMajor = buildVersion.CommitCountString; var arch = IsWinx86 ? "x86" : "x64"; var version = buildVersion.NuGetVersion; var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; File.WriteAllText(Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost", "packaging", "version.txt"), content); string corehostSrcDir = Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Command.Create(Path.Combine(corehostSrcDir, "packaging", "pack.cmd")) // Workaround to arg escaping adding backslashes for arguments to .cmd scripts. .Environment("__WorkaroundCliCoreHostBuildArch", arch) .Environment("__WorkaroundCliCoreHostBinDir", Dirs.Corehost) .Environment("__WorkaroundCliCoreHostPolicyVer", HostPolicyVer) .Environment("__WorkaroundCliCoreHostFxrVer", HostFxrVer) .Environment("__WorkaroundCliCoreHostVer", HostVer) .Environment("__WorkaroundCliCoreHostBuildMajor", buildMajor) .Environment("__WorkaroundCliCoreHostVersionTag", versionTag) .ForwardStdOut() .ForwardStdErr() .Execute() .EnsureSuccessful(); } else { Exec(Path.Combine(corehostSrcDir, "packaging", "pack.sh"), "--arch", "x64", "--hostbindir", Dirs.Corehost, "--policyver", HostPolicyVer, "--fxrver", HostFxrVer, "--hostver", HostVer, "--build", buildMajor, "--vertag", versionTag); } int runtimeCount = 0; foreach (var file in Directory.GetFiles(Path.Combine(corehostSrcDir, "packaging", "bin", "packages"), "*.nupkg")) { var fileName = Path.GetFileName(file); File.Copy(file, Path.Combine(Dirs.Corehost, fileName)); runtimeCount += (fileName.StartsWith("runtime.") ? 1 : 0); } if (runtimeCount < 3) { throw new BuildFailureException("Not all corehost nupkgs were successfully created"); } return(c.Success()); }
private static BuildTargetResult CompileCliSdk(BuildTargetContext c, DotNetCli dotnet, string rootOutputDirectory) { var configuration = c.BuildContext.Get <string>("Configuration"); var buildVersion = c.BuildContext.Get <BuildVersion>("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", "netstandard1.5") .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.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{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); } } 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 = DependencyVersions.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); return(c.Success()); }
private static BuildTargetResult CompileCliSdk(BuildTargetContext c, DotNetCli dotnet, string outputDir) { var configuration = c.BuildContext.Get <string>("Configuration"); var buildVersion = c.BuildContext.Get <BuildVersion>("BuildVersion"); outputDir = Path.Combine(outputDir, "sdk", buildVersion.NuGetVersion); Rmdir(outputDir); Mkdirp(outputDir); foreach (var project in ProjectsToPublish) { // TODO: Use the flag once we get a full build round tripped // --version-suffix buildVesion.VersionSuffix dotnet.Publish( "--native-subdirectory", "--output", outputDir, "--configuration", configuration, Path.Combine(c.BuildContext.BuildDirectory, "src", project)) .Environment("DOTNET_BUILD_VERSION", buildVersion.VersionSuffix) .Execute() .EnsureSuccessful(); } FixModeFlags(outputDir); string compilersProject = Path.Combine(Dirs.RepoRoot, "src", "compilers"); dotnet.Publish(compilersProject, "--output", outputDir, "--framework", "netstandard1.5") .Execute() .EnsureSuccessful(); var compilersDeps = Path.Combine(outputDir, "compilers.deps.json"); var compilersRuntimeConfig = Path.Combine(outputDir, "compilers.runtimeconfig.json"); // Copy corehost File.Copy(Path.Combine(Dirs.Corehost, $"corehost{Constants.ExeSuffix}"), Path.Combine(outputDir, $"corehost{Constants.ExeSuffix}"), overwrite: true); File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(outputDir, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true); File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostfxr{Constants.DynamicLibSuffix}"), Path.Combine(outputDir, $"{Constants.DynamicLibPrefix}hostfxr{Constants.DynamicLibSuffix}"), overwrite: true); var binaryToCorehostifyOutDir = Path.Combine(outputDir, "runtimes", "any", "native"); // 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(outputDir, $"{binaryToCorehostify}.dll")); File.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe")); File.Copy(compilersDeps, Path.Combine(outputDir, binaryToCorehostify + ".deps.json")); File.Copy(compilersRuntimeConfig, Path.Combine(outputDir, binaryToCorehostify + ".runtimeconfig.json")); } catch (Exception ex) { return(c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}")); } } // cleanup compilers project output we don't need DeleteMainPublishOutput(outputDir, "compilers"); File.Delete(compilersDeps); File.Delete(compilersRuntimeConfig); // Copy AppDeps var result = CopyAppDeps(c, outputDir); if (!result.Success) { return(result); } // Generate .version file var version = buildVersion.NuGetVersion; var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; File.WriteAllText(Path.Combine(outputDir, ".version"), content); return(c.Success()); }
public static BuildTargetResult CompileCoreHost(BuildTargetContext c) { var hostVersion = c.BuildContext.Get <HostVersion>("HostVersion"); var configuration = c.BuildContext.Get <string>("Configuration"); string rid = c.BuildContext.Get <string>("TargetRID"); string platform = c.BuildContext.Get <string>("Platform"); // Generate build files var cmakeOut = Path.Combine(Dirs.CorehostLatest, "cmake"); Rmdir(cmakeOut); Mkdirp(cmakeOut); // Run the build string corehostSrcDir = Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost"); string commitHash = c.BuildContext.Get <string>("CommitHash"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Create .rc files on Windows. var resourceDir = GenerateVersionResource(c); if (configuration.Equals("Release")) { // Cmake calls it "RelWithDebInfo" in the generated MSBuild configuration = "RelWithDebInfo"; } // Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir? // See the comment in "src/corehost/build.sh" for details. It doesn't work for some reason. List <string> cmakeArgList = new List <string>(); string cmakeBaseRid, visualStudio, archMacro, arch; string ridMacro = $"-DCLI_CMAKE_RUNTIME_ID:STRING={rid}"; string cmakeHostVer = $"-DCLI_CMAKE_HOST_VER:STRING={hostVersion.LatestHostVersion.ToString()}"; string cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={hostVersion.LatestHostPolicyVersion.ToString()}"; string cmakeHostFxrVer = $"-DCLI_CMAKE_HOST_FXR_VER:STRING={hostVersion.LatestHostFxrVersion.ToString()}"; string cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}"; string cmakeResourceDir = $"-DCLI_CMAKE_RESOURCE_DIR:STRING={resourceDir}"; string cmakeExtraArgs = null; switch (platform.ToLower()) { case "x86": cmakeBaseRid = "-DCLI_CMAKE_PKG_RID:STRING=win7-x86"; visualStudio = "Visual Studio 14 2015"; archMacro = "-DCLI_CMAKE_PLATFORM_ARCH_I386=1"; arch = "x86"; break; case "arm": cmakeBaseRid = "-DCLI_CMAKE_PKG_RID:STRING=win8-arm"; visualStudio = "Visual Studio 14 2015 ARM"; archMacro = "-DCLI_CMAKE_PLATFORM_ARCH_ARM=1"; cmakeExtraArgs = "-DCMAKE_SYSTEM_VERSION=10.0"; arch = "arm"; break; case "arm64": cmakeBaseRid = "-DCLI_CMAKE_PKG_RID:STRING=win10-arm64"; visualStudio = "Visual Studio 14 2015 Win64"; archMacro = "-DCLI_CMAKE_PLATFORM_ARCH_ARM64=1"; arch = "arm64"; if (Environment.GetEnvironmentVariable("__ToolsetDir") == null) { throw new Exception("Toolset Dir must be set when the Platform is ARM64"); } break; case "x64": cmakeBaseRid = "-DCLI_CMAKE_PKG_RID:STRING=win7-x64"; visualStudio = "Visual Studio 14 2015 Win64"; archMacro = "-DCLI_CMAKE_PLATFORM_ARCH_AMD64=1"; arch = "x64"; break; default: throw new PlatformNotSupportedException("Target Architecture: " + platform + " is not currently supported."); } cmakeArgList.Add(corehostSrcDir); cmakeArgList.Add(archMacro); cmakeArgList.Add(ridMacro); cmakeArgList.Add(cmakeHostVer); cmakeArgList.Add(cmakeHostFxrVer); cmakeArgList.Add(cmakeHostPolicyVer); cmakeArgList.Add(cmakeBaseRid); cmakeArgList.Add(cmakeCommitHash); cmakeArgList.Add(cmakeResourceDir); cmakeArgList.Add("-G"); cmakeArgList.Add(visualStudio); if (!String.IsNullOrEmpty(cmakeExtraArgs)) { cmakeArgList.Add(cmakeExtraArgs); } ExecIn(cmakeOut, "cmake", cmakeArgList); var pf32 = RuntimeInformation.OSArchitecture == Architecture.X64 ? Environment.GetEnvironmentVariable("ProgramFiles(x86)") : Environment.GetEnvironmentVariable("ProgramFiles"); string msbuildPath = Path.Combine(pf32, "MSBuild", "14.0", "Bin", "MSBuild.exe"); string cmakeOutPath = Path.Combine(cmakeOut, "ALL_BUILD.vcxproj"); string configParameter = $"/p:Configuration={configuration}"; if (arch == "arm64") { Exec(msbuildPath, cmakeOutPath, configParameter, "/p:useEnv=true"); } else { Exec(msbuildPath, cmakeOutPath, configParameter); } // Copy the output out File.Copy(Path.Combine(cmakeOut, "cli", "exe", configuration, "dotnet.exe"), Path.Combine(Dirs.CorehostLatest, "dotnet.exe"), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "exe", configuration, "dotnet.pdb"), Path.Combine(Dirs.CorehostLatest, "dotnet.pdb"), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.dll"), Path.Combine(Dirs.CorehostLatest, "hostpolicy.dll"), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.pdb"), Path.Combine(Dirs.CorehostLatest, "hostpolicy.pdb"), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "fxr", configuration, "hostfxr.dll"), Path.Combine(Dirs.CorehostLatest, "hostfxr.dll"), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "fxr", configuration, "hostfxr.pdb"), Path.Combine(Dirs.CorehostLatest, "hostfxr.pdb"), overwrite: true); } else { string arch; switch (platform.ToLower()) { case "x64": arch = "x64"; break; case "arm": arch = "arm"; break; default: throw new PlatformNotSupportedException("Target Architecture: " + platform + " is not currently supported."); } // Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir? // See the comment in "src/corehost/build.sh" for details. It doesn't work for some reason. List <string> buildScriptArgList = new List <string>(); string buildScriptFile = Path.Combine(corehostSrcDir, "build.sh"); buildScriptArgList.Add("--arch"); buildScriptArgList.Add(arch); buildScriptArgList.Add("--hostver"); buildScriptArgList.Add(hostVersion.LatestHostVersion.ToString()); buildScriptArgList.Add("--fxrver"); buildScriptArgList.Add(hostVersion.LatestHostFxrVersion.ToString()); buildScriptArgList.Add("--policyver"); buildScriptArgList.Add(hostVersion.LatestHostPolicyVersion.ToString()); buildScriptArgList.Add("--rid"); buildScriptArgList.Add(rid); buildScriptArgList.Add("--commithash"); buildScriptArgList.Add(commitHash); ExecIn(cmakeOut, buildScriptFile, buildScriptArgList); // Copy the output out File.Copy(Path.Combine(cmakeOut, "cli", "exe", "dotnet"), Path.Combine(Dirs.CorehostLatest, "dotnet"), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "dll", HostArtifactNames.HostPolicyBaseName), Path.Combine(Dirs.CorehostLatest, HostArtifactNames.HostPolicyBaseName), overwrite: true); File.Copy(Path.Combine(cmakeOut, "cli", "fxr", HostArtifactNames.DotnetHostFxrBaseName), Path.Combine(Dirs.CorehostLatest, HostArtifactNames.DotnetHostFxrBaseName), overwrite: true); } return(c.Success()); }
public static BuildTargetResult Compile(BuildTargetContext c) { return(c.Success()); }
private static BuildTargetResult Crossgen(BuildTargetContext c, string outputDir) { // Check if we need to skip crossgen if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_BUILD_SKIP_CROSSGEN"), "1")) { c.Warn("Skipping crossgen because DOTNET_BUILD_SKIP_CROSSGEN is set"); return(c.Success()); } // Find crossgen string packageId; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { packageId = "runtime.win7-x64.Microsoft.NETCore.Runtime.CoreCLR"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { var osname = PlatformServices.Default.Runtime.OperatingSystem; if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase)) { packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR"; } else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase)) { // CentOS runtime is in the runtime.rhel.7-x64... package. packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR"; } else { return(c.Failed($"Unknown Linux Distro: {osname}")); } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR"; } else { return(c.Failed("Unsupported OS Platform")); } var crossGenExePath = Path.Combine( Dirs.NuGetPackages, packageId, CoreCLRVersion, "tools", $"crossgen{Constants.ExeSuffix}"); // We have to copy crossgen next to mscorlib var crossgen = Path.Combine(outputDir, $"crossgen{Constants.ExeSuffix}"); File.Copy(crossGenExePath, crossgen, overwrite: true); Chmod(crossgen, "a+x"); // And if we have mscorlib.ni.dll, we need to rename it to mscorlib.dll if (File.Exists(Path.Combine(outputDir, "mscorlib.ni.dll"))) { File.Copy(Path.Combine(outputDir, "mscorlib.ni.dll"), Path.Combine(outputDir, "mscorlib.dll"), overwrite: true); } foreach (var assemblyToCrossgen in AssembliesToCrossGen) { c.Info($"Crossgenning {assemblyToCrossgen}"); ExecInSilent(outputDir, crossgen, "-nologo", "-platform_assemblies_paths", outputDir, assemblyToCrossgen); } c.Info("Crossgen complete"); // Check if csc/vbc.ni.exe exists, and overwrite the dll with it just in case if (File.Exists(Path.Combine(outputDir, "csc.ni.exe")) && !File.Exists(Path.Combine(outputDir, "csc.ni.dll"))) { File.Move(Path.Combine(outputDir, "csc.ni.exe"), Path.Combine(outputDir, "csc.ni.dll")); } if (File.Exists(Path.Combine(outputDir, "vbc.ni.exe")) && !File.Exists(Path.Combine(outputDir, "vbc.ni.dll"))) { File.Move(Path.Combine(outputDir, "vbc.ni.exe"), Path.Combine(outputDir, "vbc.ni.dll")); } return(c.Success()); }