From 611b6a23ad3bdd722f1fc7aeaa407818c8553b22 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 6 Oct 2017 16:44:49 -0700 Subject: [PATCH] Update how PackageReference versions are set Changes: - Remove floating versions - Disable myget feeds during a Universe build - Use package-specific MSBuild variables. Pattern = `packageId.Pascalize() + "PackageVersion"`, with a few exceptions. - Remove myget feeds during build - Remove obsolete 'GenerateLineup' targets/tasks --- NuGet.config | 4 +- build/RepositoryBuild.targets | 10 +-- build/RuntimeStore.targets | 4 +- build/common.props | 4 +- build/dependencies.props | 34 ++++++-- build/repo.targets | 20 ----- build/tasks/AnalyzeBuildGraph.cs | 11 ++- build/tasks/GenerateLineup.cs | 87 ------------------- .../tasks/GeneratePackageVersionPropsFile.cs | 51 ++++++----- .../tasks/GenerateRestoreSourcesPropsFile.cs | 2 +- build/tasks/RepoTasks.tasks | 1 - build/tasks/Utilities/KoreBuildErrors.cs | 1 + korebuild-lock.txt | 4 +- .../Microsoft.AspNetCore.All.csproj | 8 +- 14 files changed, 80 insertions(+), 161 deletions(-) delete mode 100644 build/tasks/GenerateLineup.cs diff --git a/NuGet.config b/NuGet.config index c4bc056c4d..7604d0051e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,8 +2,6 @@ - - - \ No newline at end of file + diff --git a/build/RepositoryBuild.targets b/build/RepositoryBuild.targets index 2f92b51d9a..1ee1df93a5 100644 --- a/build/RepositoryBuild.targets +++ b/build/RepositoryBuild.targets @@ -29,14 +29,6 @@ - - + + $(RepositoryBuildArguments) /p:AspNetUniverseBuildOffline=true $(RepositoryBuildArguments) /p:DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath) $(RepositoryBuildArguments) /p:DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath) diff --git a/build/RuntimeStore.targets b/build/RuntimeStore.targets index 28118dbf02..81f949a2c3 100644 --- a/build/RuntimeStore.targets +++ b/build/RuntimeStore.targets @@ -41,7 +41,7 @@ + Properties="Configuration=$(Configuration);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);AspNetUniverseBuildOffline=true" /> @@ -190,4 +190,4 @@ - \ No newline at end of file + diff --git a/build/common.props b/build/common.props index f7b678dcf2..07f22d4eb3 100644 --- a/build/common.props +++ b/build/common.props @@ -14,7 +14,7 @@ - + - \ No newline at end of file + diff --git a/build/dependencies.props b/build/dependencies.props index f0452cf9db..c5d8370df2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -22,6 +22,7 @@ + @@ -95,10 +96,12 @@ https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json + 2.0.2-beta-15522 - + + @@ -171,7 +174,23 @@ - + + KRB2004 + NETStandardImplicitPackageVersion + netstandard2.0 + + + + KRB2004 + NETStandardLibraryPackageVersion + net461 + + + + KRB2004 + NETStandardLibraryPackageVersion + net46 + @@ -181,6 +200,7 @@ KRB2004 + NewtonsoftJsonRuntimePackageVersion @@ -213,14 +233,16 @@ KRB2004 - EFBenchmarksXunitAssertPackageVersion + XunitAssertStablePackageVersion KRB2004 - + + XunitRunnerVisualStudioPackageVersion + KRB2004 @@ -231,8 +253,4 @@ KRB2004 - - - 2.0.1-rtm-15400 - diff --git a/build/repo.targets b/build/repo.targets index 008abfd375..b2f0305756 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -207,26 +207,6 @@ - - - - - - - - - - - diff --git a/build/tasks/AnalyzeBuildGraph.cs b/build/tasks/AnalyzeBuildGraph.cs index 1119b21dcf..3a7a6a3ded 100644 --- a/build/tasks/AnalyzeBuildGraph.cs +++ b/build/tasks/AnalyzeBuildGraph.cs @@ -130,6 +130,15 @@ namespace RepoTasks var matchesExternalDependency = false; if (shippedPackageMap.TryGetValue(dependency.Key, out var shippedPackage)) { + if (string.IsNullOrEmpty(dependency.Value.Version)) + { + Log.LogKoreBuildError( + project.FullPath, + KoreBuildErrors.EmptyPackageReferenceVersion, + message: $"Package reference to {dependency.Key} has an empty version"); + continue; + } + matchesExternalDependency = shippedPackage.PackageInfo.Version.Equals(NuGetVersion.Parse(dependency.Value.Version)); } else if (dependencyMap.TryGetValue(dependency.Key, out var externalVersions)) @@ -152,7 +161,7 @@ namespace RepoTasks { continue; } - else if (package.PackageInfo.Version.Equals(refVersion)) + else if (package.PackageInfo.Version.Equals(refVersion.MinVersion)) { continue; } diff --git a/build/tasks/GenerateLineup.cs b/build/tasks/GenerateLineup.cs deleted file mode 100644 index 5053ebdfa2..0000000000 --- a/build/tasks/GenerateLineup.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.IO; -using System.Xml; -using System.Xml.Linq; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using RepoTasks.ProjectModel; -using RepoTasks.Utilities; - -namespace RepoTasks -{ - public class GenerateLineup : Task - { - [Required] - public ITaskItem[] Artifacts { get; set; } - - [Required] - public string OutputPath { get; set; } - - // Can be set to filter the lists of packages when produce a list for a specific repository - public string Repository { get; set; } - - public bool UseFloatingVersions { get; set; } - - public string BuildNumber { get; set; } - - public override bool Execute() - { - OutputPath = OutputPath.Replace('\\', '/'); - Directory.CreateDirectory(Path.GetDirectoryName(OutputPath)); - - if (UseFloatingVersions && string.IsNullOrEmpty(BuildNumber)) - { - Log.LogWarning("Cannot compute floating versions when BuildNumber is not specified"); - } - - var items = new XElement("ItemGroup"); - var root = new XElement("Project", items); - var doc = new XDocument(root); - - var packages = new List(); - - foreach (var pkg in Artifacts.Select(ArtifactInfo.Parse) - .OfType() - .Where(p => !p.IsSymbolsArtifact - && (string.IsNullOrEmpty(Repository) - || !Repository.Equals(p.RepoName, StringComparison.OrdinalIgnoreCase)))) - { - packages.Add(pkg.PackageInfo); - } - - foreach (var pkg in packages.OrderBy(i => i.Id)) - { - var version = pkg.Version.ToString(); - if (UseFloatingVersions && version.EndsWith(BuildNumber)) - { - version = version.Substring(0, version.Length - BuildNumber.Length) + "*"; - } - - var refType = "DotNetCliTool".Equals(pkg.PackageType, StringComparison.OrdinalIgnoreCase) - ? "DotNetCliToolReference" - : "PackageReference"; - - items.Add(new XElement(refType, - new XAttribute("Update", pkg.Id), - new XAttribute("Version", version))); - } - - var settings = new XmlWriterSettings - { - OmitXmlDeclaration = true, - Indent = true, - }; - using (var writer = XmlWriter.Create(OutputPath, settings)) - { - Log.LogMessage(MessageImportance.High, $"Generate {OutputPath}"); - doc.Save(writer); - } - return true; - } - } -} diff --git a/build/tasks/GeneratePackageVersionPropsFile.cs b/build/tasks/GeneratePackageVersionPropsFile.cs index 4f7f444db8..43a12b6bde 100644 --- a/build/tasks/GeneratePackageVersionPropsFile.cs +++ b/build/tasks/GeneratePackageVersionPropsFile.cs @@ -57,28 +57,7 @@ namespace RepoTasks } else { - var sb = new StringBuilder(); - var first = true; - foreach (var ch in pkg.ItemSpec) - { - if (ch == '.') - { - first = true; - continue; - } - - if (first) - { - first = false; - sb.Append(char.ToUpperInvariant(ch)); - } - else - { - sb.Append(ch); - } - } - sb.Append("PackageVersion"); - packageVarName = sb.ToString(); + packageVarName = GetVariableName(pkg.ItemSpec); } var packageTfm = pkg.GetMetadata("TargetFramework"); @@ -109,10 +88,36 @@ namespace RepoTasks }; using (var writer = XmlWriter.Create(OutputPath, settings)) { - Log.LogMessage(MessageImportance.High, $"Generate {OutputPath}"); + Log.LogMessage(MessageImportance.Normal, $"Generate {OutputPath}"); doc.Save(writer); } return !Log.HasLoggedErrors; } + + private string GetVariableName(string packageId) + { + var sb = new StringBuilder(); + var first = true; + foreach (var ch in packageId) + { + if (ch == '.') + { + first = true; + continue; + } + + if (first) + { + first = false; + sb.Append(char.ToUpperInvariant(ch)); + } + else + { + sb.Append(ch); + } + } + sb.Append("PackageVersion"); + return sb.ToString(); + } } } diff --git a/build/tasks/GenerateRestoreSourcesPropsFile.cs b/build/tasks/GenerateRestoreSourcesPropsFile.cs index 75343a16bc..253420dfae 100644 --- a/build/tasks/GenerateRestoreSourcesPropsFile.cs +++ b/build/tasks/GenerateRestoreSourcesPropsFile.cs @@ -43,7 +43,7 @@ namespace RepoTasks }; using (var writer = XmlWriter.Create(OutputPath, settings)) { - Log.LogMessage(MessageImportance.High, $"Generate {OutputPath}"); + Log.LogMessage(MessageImportance.Normal, $"Generate {OutputPath}"); doc.Save(writer); } return !Log.HasLoggedErrors; diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks index 5dda060bf5..58b2008d5d 100644 --- a/build/tasks/RepoTasks.tasks +++ b/build/tasks/RepoTasks.tasks @@ -6,7 +6,6 @@ - diff --git a/build/tasks/Utilities/KoreBuildErrors.cs b/build/tasks/Utilities/KoreBuildErrors.cs index b3693e5011..f21bde3436 100644 --- a/build/tasks/Utilities/KoreBuildErrors.cs +++ b/build/tasks/Utilities/KoreBuildErrors.cs @@ -23,6 +23,7 @@ namespace RepoTasks.Utilities public const int DotNetCliReferenceReferenceHasVersion = 4003; public const int PackageVersionNotFoundInLineup = 4004; public const int UndefinedExternalDependency = 4005; + public const int EmptyPackageReferenceVersion = 4006; // Other unknown errors public const int PolicyFailedToApply = 5000; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a09c6b1ed7..2a51b344b6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.0.2-beta-15516 -commithash:b7022c60cb24c59a29ca4bd9ad8f6dd29dc41509 +version:2.0.2-beta-15522 +commithash:f26cb086ebd8b5a187381bb9a431794f11d69025 diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 95e31dbeb0..67dda6b16a 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -5,11 +5,12 @@ $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + $(RestoreSources); - https://dotnet.myget.org/F/aspnet-2-0-2-october2017-patch/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; https://api.nuget.org/v3/index.json; @@ -18,6 +19,7 @@ aspnetcore Microsoft.AspNetCore.All false + $(CoreSetupPackageVersion)