public static BuildTargetResult GenerateVersions(BuildTargetContext c) { var commitCount = GitUtils.GetCommitCount(); var commitHash = GitUtils.GetCommitHash(); var branchInfo = new BranchInfo(Dirs.RepoRoot); var hostVersion = new HostVersion() { ReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"], CommitCount = commitCount }; var buildVersion = new BuildVersion() { Major = int.Parse(branchInfo.Entries["MAJOR_VERSION"]), Minor = int.Parse(branchInfo.Entries["MINOR_VERSION"]), Patch = int.Parse(branchInfo.Entries["PATCH_VERSION"]), ReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"], CommitCount = commitCount }; c.BuildContext["BuildVersion"] = buildVersion; c.BuildContext["HostVersion"] = hostVersion; c.BuildContext["CommitHash"] = commitHash; c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.NetCoreAppVersion; c.Info($"Building Version: {hostVersion.LatestHostVersion.WithoutSuffix} (NuGet Packages: {hostVersion.LatestHostVersion})"); c.Info($"From Commit: {commitHash}"); return(c.Success()); }
public static BuildTargetResult GenerateVersions(BuildTargetContext c) { var gitResult = Cmd("git", "rev-list", "--count", "HEAD") .CaptureStdOut() .Execute(); gitResult.EnsureSuccessful(); var commitCount = int.Parse(gitResult.StdOut); gitResult = Cmd("git", "rev-parse", "HEAD") .CaptureStdOut() .Execute(); gitResult.EnsureSuccessful(); var commitHash = gitResult.StdOut.Trim(); var branchInfo = ReadBranchInfo(c, Path.Combine(c.BuildContext.BuildDirectory, "branchinfo.txt")); var buildVersion = new BuildVersion() { Major = int.Parse(branchInfo["MAJOR_VERSION"]), Minor = int.Parse(branchInfo["MINOR_VERSION"]), Patch = int.Parse(branchInfo["PATCH_VERSION"]), ReleaseSuffix = branchInfo["RELEASE_SUFFIX"], CommitCount = commitCount }; c.BuildContext["BuildVersion"] = buildVersion; c.BuildContext["CommitHash"] = commitHash; c.BuildContext["SharedFrameworkNugetVersion"] = GetVersionFromProjectJson(Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "framework", "project.json")); c.Info($"Building Version: {buildVersion.SimpleVersion} (NuGet Packages: {buildVersion.NuGetVersion})"); c.Info($"From Commit: {commitHash}"); return(c.Success()); }
public static BuildTargetResult Init(BuildTargetContext c) { var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION"); string platformEnv = Environment.GetEnvironmentVariable("TARGETPLATFORM") ?? RuntimeEnvironment.RuntimeArchitecture.ToString(); string targetRID = Environment.GetEnvironmentVariable("TARGETRID"); if (targetRID == null) { targetRID = RuntimeEnvironment.GetRuntimeIdentifier(); if (targetRID.StartsWith("win") && (targetRID.EndsWith("x86") || targetRID.EndsWith("x64"))) { targetRID = $"win7-{RuntimeEnvironment.RuntimeArchitecture}"; } } string targetFramework = Environment.GetEnvironmentVariable("TARGETFRAMEWORK") ?? "netcoreapp1.0"; if (string.IsNullOrEmpty(configEnv)) { configEnv = "Debug"; } c.BuildContext["Configuration"] = configEnv; c.BuildContext["Channel"] = Environment.GetEnvironmentVariable("CHANNEL"); c.BuildContext["Platform"] = platformEnv; c.BuildContext["TargetRID"] = targetRID; c.BuildContext["TargetFramework"] = targetFramework; c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}"); c.Info("Build Environment:"); c.Info($" Operating System: {RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion}"); c.Info($" Platform: " + platformEnv); return(c.Success()); }
public static BuildTargetResult GenerateVersions(BuildTargetContext c) { var commitCount = GitUtils.GetCommitCount(); var commitHash = GitUtils.GetCommitHash(); var branchInfo = ReadBranchInfo(c, Path.Combine(c.BuildContext.BuildDirectory, "branchinfo.txt")); var buildVersion = new BuildVersion() { Major = int.Parse(branchInfo["MAJOR_VERSION"]), Minor = int.Parse(branchInfo["MINOR_VERSION"]), Patch = int.Parse(branchInfo["PATCH_VERSION"]), ReleaseSuffix = branchInfo["RELEASE_SUFFIX"], CommitCount = commitCount }; c.BuildContext["BuildVersion"] = buildVersion; c.BuildContext["BranchName"] = branchInfo["BRANCH_NAME"]; c.BuildContext["CommitHash"] = commitHash; c.Info($"Building Version: {buildVersion.SimpleVersion} (NuGet Packages: {buildVersion.NuGetVersion})"); c.Info($"From Commit: {commitHash}"); return(c.Success()); }
public static BuildTargetResult GenerateVersions(BuildTargetContext c) { var gitResult = Cmd("git", "rev-list", "--count", "HEAD") .CaptureStdOut() .Execute(); gitResult.EnsureSuccessful(); var commitCount = int.Parse(gitResult.StdOut); gitResult = Cmd("git", "rev-parse", "HEAD") .CaptureStdOut() .Execute(); gitResult.EnsureSuccessful(); var commitHash = gitResult.StdOut.Trim(); var hostVersion = new HostVersion() { CommitCount = commitCount }; c.BuildContext["HostVersion"] = hostVersion; c.BuildContext["CommitHash"] = commitHash; c.Info($"Building Version: {hostVersion.LatestHostVersionNoSuffix} (NuGet Packages: {hostVersion.LatestHostVersion})"); c.Info($"From Commit: {commitHash}"); return(c.Success()); }
public static BuildTargetResult GenerateVersions(BuildTargetContext c) { var commitCount = GitUtils.GetCommitCount(); var commitHash = GitUtils.GetCommitHash(); var branchInfo = new BranchInfo(Dirs.RepoRoot); // Read details from branchinfo.txt for our build configuration int iMajor = int.Parse(branchInfo.Entries["MAJOR_VERSION"]); int iMinor = int.Parse(branchInfo.Entries["MINOR_VERSION"]); int iPatch = int.Parse(branchInfo.Entries["PATCH_VERSION"]); string sReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"]; bool fStabilizePackageVersion = bool.Parse(branchInfo.Entries["STABILIZE_PACKAGE_VERSION"]); bool fValidateHostPackages = bool.Parse(branchInfo.Entries["VALIDATE_HOST_PACKAGES"]); bool fLockHostVersion = bool.Parse(branchInfo.Entries["LOCK_HOST_VERSION"]); var hostVersion = new HostVersion() { Major = iMajor, Minor = iMinor, Patch = iPatch, ReleaseSuffix = sReleaseSuffix, EnsureStableVersion = fStabilizePackageVersion, IsLocked = fLockHostVersion, CommitCount = commitCount }; var buildVersion = new BuildVersion() { Major = iMajor, Minor = iMinor, Patch = iPatch, ReleaseSuffix = sReleaseSuffix, CommitCount = commitCount }; c.BuildContext["ValidateHostPackages"] = fValidateHostPackages; c.BuildContext["BuildVersion"] = buildVersion; c.BuildContext["HostVersion"] = hostVersion; c.BuildContext["CommitHash"] = commitHash; c.BuildContext["BranchName"] = branchInfo.Entries["BRANCH_NAME"]; // Define the version string to be used based upon whether we are stabilizing the versions or not. if (!fStabilizePackageVersion) { c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.NetCoreAppVersion; } else { c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.ProductionVersion; } c.Info($"Building Version: {hostVersion.LatestHostVersion.WithoutSuffix} (NuGet Packages: {hostVersion.LatestHostVersion})"); c.Info($"From Commit: {commitHash}"); return(c.Success()); }
public static BuildTargetResult Init(BuildTargetContext c) { var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION"); string platformEnv = Environment.GetEnvironmentVariable("TARGETPLATFORM") ?? RuntimeEnvironment.RuntimeArchitecture.ToString(); string targetRID = Environment.GetEnvironmentVariable("TARGETRID"); if (targetRID == null) { targetRID = RuntimeEnvironment.GetRuntimeIdentifier(); if (targetRID.StartsWith("win") && (targetRID.EndsWith("x86") || targetRID.EndsWith("x64"))) { targetRID = $"win7-{RuntimeEnvironment.RuntimeArchitecture}"; } } string targetFramework = Environment.GetEnvironmentVariable("TARGETFRAMEWORK") ?? "netcoreapp1.1"; if (string.IsNullOrEmpty(configEnv)) { configEnv = "Debug"; } string crossEnv = Environment.GetEnvironmentVariable("CROSS") ?? "0"; if (string.Equals(crossEnv, "1")) { string rootfsDir = Environment.GetEnvironmentVariable("ROOTFS_DIR"); if (string.IsNullOrEmpty(rootfsDir)) { rootfsDir = Path.Combine(Dirs.RepoRoot, "cross", "rootfs", platformEnv); Environment.SetEnvironmentVariable("ROOTFS_DIR", rootfsDir); } } c.BuildContext["Configuration"] = configEnv; c.BuildContext["Channel"] = Environment.GetEnvironmentVariable("CHANNEL"); c.BuildContext["Platform"] = platformEnv; c.BuildContext["TargetRID"] = targetRID; c.BuildContext["TargetFramework"] = targetFramework; c.BuildContext["Cross"] = crossEnv; c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}"); c.Info("Build Environment:"); c.Info($" Operating System: {RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion}"); c.Info($" Platform: " + platformEnv); c.Info($" Cross Build: " + int.Parse(crossEnv)); return(c.Success()); }
private static void CompressNuGetPackagesArchive( BuildTargetContext c, DotNetCli dotnet, string nuGetPackagesArchiveFolder, string sdkOutputDirectory) { var configuration = c.BuildContext.Get <string>("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); }
public static BuildTargetResult CreatePR(BuildTargetContext c) { string remoteBranchName = c.GetRemoteBranchName(); string commitMessage = c.GetCommitMessage(); NewPullRequest prInfo = new NewPullRequest( $"[{s_config.GitHubUpstreamBranch}] {commitMessage}", s_config.GitHubOriginOwner + ":" + remoteBranchName, s_config.GitHubUpstreamBranch); string[] prNotifications = s_config.GitHubPullRequestNotifications; if (prNotifications.Length > 0) { prInfo.Body = $"/cc @{string.Join(" @", prNotifications)}"; } GitHubClient gitHub = new GitHubClient(new ProductHeaderValue("dotnetDependencyUpdater")); gitHub.Credentials = new Credentials(s_config.Password); PullRequest createdPR = gitHub.PullRequest.Create(s_config.GitHubUpstreamOwner, s_config.GitHubProject, prInfo).Result; c.Info($"Created Pull Request: {createdPR.HtmlUrl}"); return(c.Success()); }
public static BuildTargetResult RunE2ETest(BuildTargetContext c) { // Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools // So we need to skip this target if the tools aren't present. // https://github.com/dotnet/core-setup/issues/167 if (DebuildNotPresent()) { c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}"); return(c.Success()); } Directory.SetCurrentDirectory(Path.Combine(Dirs.RepoRoot, "test", "EndToEnd")); Cmd("dotnet", "build") .Execute() .EnsureSuccessful(); var testResultsPath = Path.Combine(Dirs.Output, "obj", "debian", "test", "debian-endtoend-testResults.xml"); Cmd("dotnet", "test", "-xml", testResultsPath) .Execute() .EnsureSuccessful(); return(c.Success()); }
public static BuildTargetResult RemovePackages(BuildTargetContext c) { // Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools // So we need to skip this target if the tools aren't present. // https://github.com/dotnet/core-setup/issues/167 if (DebuildNotPresent()) { c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}"); return(c.Success()); } var sharedFrameworkNugetVersion = c.BuildContext.Get <string>("SharedFrameworkNugetVersion"); var hostFxrVersion = c.BuildContext.Get <HostVersion>("HostVersion").LockedHostFxrVersion.ToString(); IEnumerable <string> orderedPackageNames = new List <string>() { Monikers.GetDebianSharedFrameworkPackageName(sharedFrameworkNugetVersion), Monikers.GetDebianHostFxrPackageName(hostFxrVersion), Monikers.GetDebianSharedHostPackageName(c) }; foreach (var packageName in orderedPackageNames) { RemovePackage(packageName); } return(c.Success()); }
private static void AcquireWix(BuildTargetContext c) { if (File.Exists(Path.Combine(WixRoot, "candle.exe"))) { return; } Directory.CreateDirectory(WixRoot); c.Info("Downloading WixTools.."); DownloadFile($"https://dotnetcli.blob.core.windows.net/build/wix/wix.{WixVersion}.zip", Path.Combine(WixRoot, "WixTools.zip")); c.Info("Extracting WixTools.."); ZipFile.ExtractToDirectory(Path.Combine(WixRoot, "WixTools.zip"), WixRoot); }
private static Dictionary <string, string> LoadVsVars(BuildTargetContext c) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return(new Dictionary <string, string>()); } c.Verbose("Start Collecting Visual Studio Environment Variables"); var vsvarsPath = Path.GetFullPath(Path.Combine(Environment.GetEnvironmentVariable("VS140COMNTOOLS"), "..", "..", "VC")); // Write a temp batch file because that seems to be the easiest way to do this (argument parsing is hard) var temp = Path.Combine(Path.GetTempPath(), $"{Path.GetRandomFileName()}.cmd"); File.WriteAllText(temp, $@"@echo off cd {vsvarsPath} call vcvarsall.bat x64 set"); CommandResult result; try { result = Cmd(Environment.GetEnvironmentVariable("COMSPEC"), "/c", temp) .WorkingDirectory(vsvarsPath) .CaptureStdOut() .Execute(); } finally { if (File.Exists(temp)) { File.Delete(temp); } } result.EnsureSuccessful(); var vars = new Dictionary <string, string>(); foreach (var line in result.StdOut.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { var splat = line.Split(new[] { '=' }, 2); if (splat.Length == 2) { c.Verbose($"Adding variable '{line}'"); vars[splat[0]] = splat[1]; } else { c.Info($"Skipping VS Env Variable. Unknown format: '{line}'"); } } c.Verbose("Finish Collecting Visual Studio Environment Variables"); return(vars); }
private static List <string> RunDotnetTestOnTestProjects(BuildTargetContext c, DotNetCli dotnet, string configuration) { var failingTests = new List <string>(); // Fetch the target RID to determine if we support running tests or not. string rid = c.BuildContext.Get <string>("TargetRID"); bool fIsCrossArch = false; if (!String.IsNullOrEmpty(rid)) { if ((String.Compare(rid, "win8-arm", true) == 0) || (String.Compare(rid, "win10-arm64", true) == 0)) { // We dont support running native tests for cross-architecture builds yet. fIsCrossArch = true; } } foreach (var project in TestProjects) { // Explicitly checking for the host tests since they are the only ones running native code. if (String.Compare("HostActivationTests", project) == 0) { if (fIsCrossArch) { c.Info($"Skipping tests in: {project} since cross-arch test runs are not yet supported for {rid}."); continue; } } c.Info($"Running tests in: {project}"); var result = dotnet.Test("--configuration", configuration, "-xml", $"{project}-testResults.xml", "-notrait", "category=failing") .WorkingDirectory(Path.Combine(Dirs.RepoRoot, "test", project)) .EnvironmentVariable("PATH", $"{dotnet.BinPath}{Path.PathSeparator}{Environment.GetEnvironmentVariable("PATH")}") .EnvironmentVariable("TEST_ARTIFACTS", Dirs.TestArtifacts) .Execute(); if (result.ExitCode != 0) { failingTests.Add(project); } } return(failingTests); }
public static BuildTargetResult GenerateVersions(BuildTargetContext c) { var commitCount = GitUtils.GetCommitCount(); var commitHash = GitUtils.GetCommitHash(); var hostVersion = new HostVersion() { CommitCount = commitCount }; c.BuildContext["HostVersion"] = hostVersion; c.BuildContext["CommitHash"] = commitHash; c.Info($"Building Version: {hostVersion.LatestHostVersionNoSuffix} (NuGet Packages: {hostVersion.LatestHostVersion})"); c.Info($"From Commit: {commitHash}"); return(c.Success()); }
private static void AcquireWix(BuildTargetContext c) { if (File.Exists(Path.Combine(WixRoot, "candle.exe"))) { return; } Directory.CreateDirectory(WixRoot); c.Info("Downloading WixTools.."); // Download Wix version 3.10.2 - https://wix.codeplex.com/releases/view/619491 Cmd("powershell", "-NoProfile", "-NoLogo", $"Invoke-WebRequest -Uri https://wix.codeplex.com/downloads/get/1540241 -Method Get -OutFile {WixRoot}\\WixTools.zip") .Execute() .EnsureSuccessful(); c.Info("Extracting WixTools.."); ZipFile.ExtractToDirectory($"{WixRoot}\\WixTools.zip", WixRoot); }
public static BuildTargetResult Init(BuildTargetContext c) { var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION"); if (string.IsNullOrEmpty(configEnv)) { configEnv = "Debug"; } c.BuildContext["Configuration"] = configEnv; c.BuildContext["Channel"] = Environment.GetEnvironmentVariable("CHANNEL"); c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}"); c.Info("Build Environment:"); c.Info($" Operating System: {RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion}"); c.Info($" Platform: {RuntimeEnvironment.OperatingSystemPlatform}"); return(c.Success()); }
public static BuildTargetResult CheckPackageCache(BuildTargetContext c) { var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal); // Always set the package cache location local to the build 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 InstallSharedFramework(BuildTargetContext c) { // Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools // So we need to skip this target if the tools aren't present. // https://github.com/dotnet/core-setup/issues/167 if (DebuildNotPresent()) { c.Info("Debuild not present, skipping target: {nameof(InstallSharedFramework)}"); return(c.Success()); } InstallPackage(c.BuildContext.Get <string>("SharedFrameworkInstallerFile")); return(c.Success()); }
public static BuildTargetResult GenerateSdkDeb(BuildTargetContext c) { // Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools // So we need to skip this target if the tools aren't present. // https://github.com/dotnet/core-setup/issues/167 if (DebuildNotPresent()) { c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}"); return(c.Success()); } var channel = c.BuildContext.Get <string>("Channel").ToLower(); var packageName = CliMonikers.GetSdkDebianPackageName(c); var version = c.BuildContext.Get <BuildVersion>("BuildVersion").NuGetVersion; var debFile = c.BuildContext.Get <string>("SdkInstallerFile"); var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages"); var sdkPublishRoot = c.BuildContext.Get <string>("CLISDKRoot"); var sharedFxDebianPackageName = Monikers.GetDebianSharedFrameworkPackageName(CliDependencyVersions.SharedFrameworkVersion); var debianConfigFile = Path.Combine(Dirs.DebPackagingConfig, "dotnet-debian_config.json"); var postinstallFile = Path.Combine(Dirs.DebPackagingConfig, "postinst"); var debianConfigVariables = new Dictionary <string, string>() { { "SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME", sharedFxDebianPackageName }, { "SHARED_FRAMEWORK_NUGET_NAME", Monikers.SharedFrameworkName }, { "SHARED_FRAMEWORK_NUGET_VERSION", CliDependencyVersions.SharedFrameworkVersion }, { "SHARED_FRAMEWORK_BRAND_NAME", Monikers.SharedFxBrandName }, { "SDK_NUGET_VERSION", version }, { "CLI_SDK_BRAND_NAME", Monikers.CLISdkBrandName } }; var debCreator = new DebPackageCreator( DotNetCli.Stage2, Dirs.Intermediate); debCreator.CreateDeb( debianConfigFile, packageName, version, sdkPublishRoot, debianConfigVariables, debFile, manpagesDirectory: manPagesDir, versionManpages: true, debianFiles: new string[] { postinstallFile }); return(c.Success()); }
public static BuildTargetResult BuildTests(BuildTargetContext c) { var dotnet = DotNetCli.Stage2; var configuration = c.BuildContext.Get <string>("Configuration"); foreach (var testProject in TestProjects) { c.Info($"Building tests: {testProject}"); dotnet.Build("--configuration", configuration) .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test", testProject)) .Execute() .EnsureSuccessful(); } return(c.Success()); }
private static string GetNewVersion(this BuildTargetContext c, string packageId) { string newVersion = c.GetDependencyInfos() .SelectMany(d => d.NewVersions) .FirstOrDefault(p => p.Id == packageId) ?.Version .ToNormalizedString(); if (string.IsNullOrEmpty(newVersion)) { c.Info($"Could not find package version information for '{packageId}'"); return(null); } return(newVersion); }
public static BuildTargetResult GenerateSharedFrameworkDeb(BuildTargetContext c) { // Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools // So we need to skip this target if the tools aren't present. // https://github.com/dotnet/core-setup/issues/167 if (DebuildNotPresent()) { c.Info("Debuild not present, skipping target: {nameof(GenerateSharedFrameworkDeb)}"); return(c.Success()); } var sharedFrameworkNugetVersion = c.BuildContext.Get <string>("SharedFrameworkNugetVersion"); var packageName = Monikers.GetDebianSharedFrameworkPackageName(sharedFrameworkNugetVersion); var sharedHostVersion = c.BuildContext.Get <HostVersion>("HostVersion").LockedHostVersion.ToString(); var hostFxrVersion = c.BuildContext.Get <HostVersion>("HostVersion").LockedHostFxrVersion.ToString(); var hostfxrDebianPackageName = Monikers.GetDebianHostFxrPackageName(hostFxrVersion); var version = c.BuildContext.Get <string>("SharedFrameworkNugetVersion"); var inputRoot = c.BuildContext.Get <string>("SharedFrameworkPublishRoot"); var debFile = c.BuildContext.Get <string>("SharedFrameworkInstallerFile"); var debianConfigFile = Path.Combine(Dirs.DebPackagingConfig, "dotnet-sharedframework-debian_config.json"); var debianConfigVariables = new Dictionary <string, string>() { { "SHARED_HOST_DEBIAN_VERSION", sharedHostVersion }, { "HOSTFXR_DEBIAN_PACKAGE_NAME", hostfxrDebianPackageName }, { "HOSTFXR_DEBIAN_VERSION", hostFxrVersion }, { "SHARED_FRAMEWORK_DEBIAN_PACKAGE_NAME", packageName }, { "SHARED_FRAMEWORK_NUGET_NAME", Monikers.SharedFrameworkName }, { "SHARED_FRAMEWORK_NUGET_VERSION", c.BuildContext.Get <string>("SharedFrameworkNugetVersion") }, { "SHARED_FRAMEWORK_BRAND_NAME", Monikers.GetSharedFxBrandName(c) } }; var debCreator = new DebPackageCreator( DotNetCli.Stage0, Dirs.Intermediate, dotnetDebToolPackageSource: Dirs.Packages); debCreator.CreateDeb( debianConfigFile, packageName, version, inputRoot, debianConfigVariables, debFile); return(c.Success()); }
public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c) { List <DependencyInfo> dependencyInfos = c.GetDependencyInfos(); const string noUpdateFileName = ".noautoupdate"; IEnumerable <string> projectJsonFiles = Enumerable.Union( Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories), Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.template", SearchOption.AllDirectories)) .Where(p => !File.Exists(Path.Combine(Path.GetDirectoryName(p), noUpdateFileName)) && !Path.GetDirectoryName(p).EndsWith("CSharp_Web", StringComparison.Ordinal)); JObject projectRoot; foreach (string projectJsonFile in projectJsonFiles) { try { projectRoot = ReadProject(projectJsonFile); } catch (Exception e) { c.Warn($"Non-fatal exception occurred reading '{projectJsonFile}'. Skipping file. Exception: {e}. "); continue; } if (projectRoot == null) { c.Warn($"A non valid JSON file was encountered '{projectJsonFile}'. Skipping file."); continue; } bool changedAnyPackage = FindAllDependencyProperties(projectRoot) .Select(dependencyProperty => ReplaceDependencyVersion(dependencyProperty, dependencyInfos)) .ToArray() .Any(shouldWrite => shouldWrite); if (changedAnyPackage) { c.Info($"Writing changes to {projectJsonFile}"); WriteProject(projectRoot, projectJsonFile); } } return(c.Success()); }
public static BuildTargetResult LocateStage0(BuildTargetContext c) { // We should have been run in the repo root, so locate the stage 0 relative to current directory var stage0 = DotNetCli.Stage0.BinPath; if (!Directory.Exists(stage0)) { return(c.Failed($"Stage 0 directory does not exist: {stage0}")); } // Identify the version var version = File.ReadAllLines(Path.Combine(stage0, "..", ".version")); c.Info($"Using Stage 0 Version: {version[1]}"); return(c.Success()); }
public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c) { List <DependencyInfo> dependencyInfos = c.GetDependencyInfos(); var projectJsonFiles = new List <string> { Path.Combine(Dirs.PkgProjects, "Microsoft.NETCore.App", "project.json.template"), Path.Combine(Dirs.PkgProjects, "Microsoft.NETCore.UniversalWindowsPlatform", "project.json.template"), Path.Combine(Dirs.PkgDeps, "project.json") }; //projectJsonFiles.AddRange(Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories)); JObject projectRoot; foreach (string projectJsonFile in projectJsonFiles) { try { projectRoot = ReadProject(projectJsonFile); } catch (Exception e) { c.Warn($"Non-fatal exception occurred reading '{projectJsonFile}'. Skipping file. Exception: {e}. "); continue; } if (projectRoot == null) { c.Warn($"A non valid JSON file was encountered '{projectJsonFile}'. Skipping file."); continue; } bool changedAnyPackage = FindAllDependencyProperties(projectRoot) .Select(dependencyProperty => ReplaceDependencyVersion(dependencyProperty, dependencyInfos)) .ToArray() .Any(shouldWrite => shouldWrite); if (changedAnyPackage) { c.Info($"Writing changes to {projectJsonFile}"); WriteProject(projectRoot, projectJsonFile); } } return(c.Success()); }
public static BuildTargetResult GenerateSdkDeb(BuildTargetContext c) { // Ubuntu 16.04 Jenkins Machines don't have docker or debian package build tools // So we need to skip this target if the tools aren't present. // https://github.com/dotnet/core-setup/issues/167 if (DebuildNotPresent()) { c.Info("Debuild not present, skipping target: {nameof(RemovePackages)}"); return(c.Success()); } var channel = c.BuildContext.Get <string>("Channel").ToLower(); var packageName = CliMonikers.GetSdkDebianPackageName(c); var version = c.BuildContext.Get <BuildVersion>("BuildVersion").NuGetVersion; var debFile = c.BuildContext.Get <string>("SdkInstallerFile"); var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages"); var previousVersionURL = $"https://dotnetcli.blob.core.windows.net/dotnet/{channel}/Installers/Latest/dotnet-ubuntu-x64.latest.deb"; var sdkPublishRoot = c.BuildContext.Get <string>("CLISDKRoot"); var sharedFxDebianPackageName = Monikers.GetDebianSharedFrameworkPackageName(CliDependencyVersions.SharedFrameworkVersion); var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sdk"); if (Directory.Exists(objRoot)) { Directory.Delete(objRoot, true); } Directory.CreateDirectory(objRoot); Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"), "-v", version, "-i", sdkPublishRoot, "-o", debFile, "-p", packageName, "-b", Monikers.CLISdkBrandName, "-m", manPagesDir, "--framework-debian-package-name", sharedFxDebianPackageName, "--framework-nuget-name", Monikers.SharedFrameworkName, "--framework-nuget-version", CliDependencyVersions.SharedFrameworkVersion, "--previous-version-url", previousVersionURL, "--obj-root", objRoot) .Execute() .EnsureSuccessful(); return(c.Success()); }
public static BuildTargetResult ValidateDependencies(BuildTargetContext c) { var configuration = c.BuildContext.Get <string>("Configuration"); var dotnet = DotNetCli.Stage2; c.Info("Publishing MultiProjectValidator"); dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools", "MultiProjectValidator")) .Execute() .EnsureSuccessful(); var validator = Path.Combine(Dirs.Output, "tools", $"pjvalidate{Constants.ExeSuffix}"); Cmd(validator, Path.Combine(c.BuildContext.BuildDirectory, "src")) .Execute(); return(c.Success()); }
public static BuildTargetResult RunXUnitTests(BuildTargetContext c) { // Need to load up the VS Vars var dotnet = DotNetCli.Stage2; var vsvars = LoadVsVars(c); var configuration = c.BuildContext.Get <string>("Configuration"); // Copy the test projects var testProjectsDir = Path.Combine(Dirs.TestOutput, "TestProjects"); Rmdir(testProjectsDir); Mkdirp(testProjectsDir); CopyRecursive(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"), testProjectsDir); // Run the tests and set the VS vars in the environment when running them var failingTests = new List <string>(); foreach (var project in TestProjects) { c.Info($"Running tests in: {project}"); var result = dotnet.Test("--configuration", configuration, "-xml", $"{project}-testResults.xml", "-notrait", "category=failing") .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test", project)) .Environment(vsvars) .EnvironmentVariable("PATH", $"{DotNetCli.Stage2.BinPath}{Path.PathSeparator}{Environment.GetEnvironmentVariable("PATH")}") .EnvironmentVariable("TEST_ARTIFACTS", Dirs.TestArtifacts) .Execute(); if (result.ExitCode != 0) { failingTests.Add(project); } } if (failingTests.Any()) { foreach (var project in failingTests) { c.Error($"{project} failed"); } return(c.Failed("Tests failed!")); } return(c.Success()); }
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c) { var dotnet = DotNetCli.Stage2; Rmdir(Dirs.TestPackages); Mkdirp(Dirs.TestPackages); foreach (var relativePath in TestPackageProjects) { var fullPath = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages", relativePath.Replace('/', Path.DirectorySeparatorChar)); c.Info($"Packing: {fullPath}"); dotnet.Pack("--output", Dirs.TestPackages) .WorkingDirectory(fullPath) .Execute() .EnsureSuccessful(); } return(c.Success()); }