diff --git a/.gitignore b/.gitignore index 5ccf3a317..193640562 100644 --- a/.gitignore +++ b/.gitignore @@ -34,10 +34,6 @@ cmake/ # stage0 install directory .dotnet_stage0 -# `dotnet new` project.json.template files are generated by a pre-build step. -# ignore these files -/src/dotnet/commands/dotnet-new/**/project.json.template - ### VisualStudio.gitignore from https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore ### ## Ignore Visual Studio temporary files, build results, and diff --git a/build_projects/dotnet-cli-build/PrepareTargets.cs b/build_projects/dotnet-cli-build/PrepareTargets.cs index b2bc2bc9f..3029d85f7 100644 --- a/build_projects/dotnet-cli-build/PrepareTargets.cs +++ b/build_projects/dotnet-cli-build/PrepareTargets.cs @@ -36,7 +36,6 @@ namespace Microsoft.DotNet.Cli.Build // All major targets will depend on this in order to ensure variables are set up right if they are run independently [Target( nameof(GenerateVersions), - nameof(UpdateTemplateVersions), nameof(CheckPrereqs), nameof(LocateStage0), nameof(ExpectedBuildArtifacts), @@ -87,27 +86,6 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - /// - /// Updates the Microsoft.NETCore.App version number in the `dotnet new` project.json.template files. - /// - [Target] - public static BuildTargetResult UpdateTemplateVersions(BuildTargetContext c) - { - IEnumerable templateFiles = Directory.GetFiles( - Path.Combine(Dirs.RepoRoot, "src", "dotnet", "commands", "dotnet-new"), - "project.json.pretemplate", - SearchOption.AllDirectories); - - foreach (string templateFile in templateFiles) - { - JObject projectRoot = JsonUtils.ReadProject(templateFile); - projectRoot["dependencies"]["Microsoft.NETCore.App"]["version"] = DependencyVersions.SharedFrameworkVersion; - JsonUtils.WriteProject(projectRoot, Path.ChangeExtension(templateFile, "template")); - } - - return c.Success(); - } - [Target] public static BuildTargetResult LocateStage0(BuildTargetContext c) { diff --git a/build_projects/update-dependencies/Config.cs b/build_projects/update-dependencies/Config.cs index 029769833..8d5008ee1 100644 --- a/build_projects/update-dependencies/Config.cs +++ b/build_projects/update-dependencies/Config.cs @@ -19,6 +19,7 @@ namespace Microsoft.DotNet.Scripts /// The following Environment Variables can optionally be specified: /// /// COREFX_VERSION_URL - The Url to get the current CoreFx package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt") + /// CORESETUP_VERSION_URL - The Url to get the current dotnet/core-setup package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/master/Latest_Packages.txt") /// GITHUB_ORIGIN_OWNER - The owner of the GitHub fork to push the commit and create the PR from. (ex. "dotnet-bot") /// GITHUB_UPSTREAM_OWNER - The owner of the GitHub base repo to create the PR to. (ex. "dotnet") /// GITHUB_PROJECT - The repo name under the ORIGIN and UPSTREAM owners. (ex. "cli") @@ -34,6 +35,7 @@ namespace Microsoft.DotNet.Scripts private Lazy _password = new Lazy(() => GetEnvironmentVariable("GITHUB_PASSWORD")); private Lazy _coreFxVersionUrl = new Lazy(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt")); + private Lazy _coreSetupVersionUrl = new Lazy(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/master/Latest_Packages.txt")); private Lazy _gitHubOriginOwner; private Lazy _gitHubUpstreamOwner = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet")); private Lazy _gitHubProject = new Lazy(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli")); @@ -51,6 +53,7 @@ namespace Microsoft.DotNet.Scripts public string Email => _email.Value; public string Password => _password.Value; public string CoreFxVersionUrl => _coreFxVersionUrl.Value; + public string CoreSetupVersionUrl => _coreSetupVersionUrl.Value; public string GitHubOriginOwner => _gitHubOriginOwner.Value; public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value; public string GitHubProject => _gitHubProject.Value; diff --git a/build_projects/update-dependencies/UpdateFilesTargets.cs b/build_projects/update-dependencies/UpdateFilesTargets.cs index 625fd329c..6638c7255 100644 --- a/build_projects/update-dependencies/UpdateFilesTargets.cs +++ b/build_projects/update-dependencies/UpdateFilesTargets.cs @@ -32,6 +32,7 @@ namespace Microsoft.DotNet.Scripts List dependencyInfos = c.GetDependencyInfos(); dependencyInfos.Add(CreateDependencyInfo("CoreFx", Config.Instance.CoreFxVersionUrl).Result); + dependencyInfos.Add(CreateDependencyInfo("CoreSetup", Config.Instance.CoreSetupVersionUrl).Result); return c.Success(); } @@ -74,7 +75,7 @@ namespace Microsoft.DotNet.Scripts }; } - [Target(nameof(ReplaceProjectJson), nameof(ReplaceCrossGen))] + [Target(nameof(ReplaceProjectJson), nameof(ReplaceDependencyVersions))] public static BuildTargetResult ReplaceVersions(BuildTargetContext c) => c.Success(); /// @@ -89,7 +90,7 @@ namespace Microsoft.DotNet.Scripts IEnumerable projectJsonFiles = Enumerable.Union( Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories), - Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.pretemplate", 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))); JObject projectRoot; @@ -187,17 +188,21 @@ namespace Microsoft.DotNet.Scripts } /// - /// Replaces version number that is hard-coded in the CrossGen script. + /// Replaces version numbers that are hard-coded in DependencyVersions.cs. /// [Target] - public static BuildTargetResult ReplaceCrossGen(BuildTargetContext c) + public static BuildTargetResult ReplaceDependencyVersions(BuildTargetContext c) { - ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", compileTargetsContent => + ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", fileContents => { DependencyInfo coreFXInfo = c.GetCoreFXDependency(); - Regex regex = new Regex(@"CoreCLRVersion = ""(?\d.\d.\d)-(?.*)"";"); + DependencyInfo coreSetupInfo = c.GetCoreSetupDependency(); - return regex.ReplaceGroupValue(compileTargetsContent, "release", coreFXInfo.NewReleaseVersion); + fileContents = ReplaceDependencyVersion(fileContents, coreFXInfo, "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR"); + fileContents = ReplaceDependencyVersion(fileContents, coreSetupInfo, "SharedFrameworkVersion", "Microsoft.NETCore.App"); + fileContents = ReplaceDependencyVersion(fileContents, coreSetupInfo, "SharedHostVersion", "Microsoft.NETCore.DotNetHost"); + + return fileContents; }); return c.Success(); @@ -208,6 +213,29 @@ namespace Microsoft.DotNet.Scripts return c.GetDependencyInfos().Single(d => d.Name == "CoreFx"); } + private static DependencyInfo GetCoreSetupDependency(this BuildTargetContext c) + { + return c.GetDependencyInfos().Single(d => d.Name == "CoreSetup"); + } + + private static string ReplaceDependencyVersion(string fileContents, DependencyInfo dependencyInfo, string dependencyPropertyName, string packageId) + { + Regex regex = new Regex($@"{dependencyPropertyName} = ""(?.*)"";"); + + string newVersion = dependencyInfo + .NewVersions + .FirstOrDefault(p => p.Id == packageId) + ?.Version + .ToNormalizedString(); + + if (string.IsNullOrEmpty(newVersion)) + { + throw new InvalidOperationException($"Could not find package version information for '{packageId}'"); + } + + return regex.ReplaceGroupValue(fileContents, "version", newVersion); + } + private static void ReplaceFileContents(string repoRelativePath, Func replacement) { string fullPath = Path.Combine(Dirs.RepoRoot, repoRelativePath); diff --git a/src/dotnet/commands/dotnet-new/CSharp_Console/project.json.pretemplate b/src/dotnet/commands/dotnet-new/CSharp_Console/project.json.template similarity index 86% rename from src/dotnet/commands/dotnet-new/CSharp_Console/project.json.pretemplate rename to src/dotnet/commands/dotnet-new/CSharp_Console/project.json.template index 8429abb78..38a08507e 100644 --- a/src/dotnet/commands/dotnet-new/CSharp_Console/project.json.pretemplate +++ b/src/dotnet/commands/dotnet-new/CSharp_Console/project.json.template @@ -6,7 +6,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "$(NetCoreAppVersion)" + "version": "1.0.0-rc3-004306" } }, "frameworks": { diff --git a/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.pretemplate b/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template similarity index 94% rename from src/dotnet/commands/dotnet-new/FSharp_Console/project.json.pretemplate rename to src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template index 792f42989..425388896 100644 --- a/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.pretemplate +++ b/src/dotnet/commands/dotnet-new/FSharp_Console/project.json.template @@ -13,7 +13,7 @@ "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160316", "Microsoft.NETCore.App": { "type": "platform", - "version": "$(NetCoreAppVersion)" + "version": "1.0.0-rc3-004306" } }, "tools": {