From 7d6bca548b428cc0ab7023133886cc173a5618a2 Mon Sep 17 00:00:00 2001 From: Joel Verhagen Date: Wed, 24 Oct 2018 12:58:28 -0700 Subject: [PATCH] Enable msbuild /t:pack on library packages Progress on https://github.com/NuGet/Engineering/issues/1673 --- build.ps1 | 16 +-- .../NuGet.Jobs.Common.csproj | 9 ++ .../Validation.Common.Job.csproj | 14 ++- .../Validation.Common.Job.nuspec | 31 ------ .../Validation.ScanAndSign.Core.csproj | 9 ++ .../Validation.Symbols.Core.csproj | 9 ++ .../CsprojNuspecConsistencyFacts.cs | 105 ------------------ .../Validation.Common.Job.Tests.csproj | 1 - 8 files changed, 45 insertions(+), 149 deletions(-) delete mode 100644 src/Validation.Common.Job/Validation.Common.Job.nuspec delete mode 100644 tests/Validation.Common.Job.Tests/CsprojNuspecConsistencyFacts.cs diff --git a/build.ps1 b/build.ps1 index af7bb4a29..4a99fb376 100644 --- a/build.ps1 +++ b/build.ps1 @@ -147,13 +147,17 @@ Invoke-BuildStep 'Creating artifacts' { # We need a few projects to be published for sharing the common bits with other repos. # We need symbols published for those, too. All other packages are deployment ones and # don't need to be shared, hence no need for symbols for them - $ProjectsWithSymbols = + $CsprojProjects = "src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj", "src/Validation.Common.Job/Validation.Common.Job.csproj", "src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj", "src/Validation.Symbols.Core/Validation.Symbols.Core.csproj" - $Projects = ` + $CsprojProjects | ForEach-Object { + New-ProjectPackage (Join-Path $PSScriptRoot $_) -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -Symbols + } + + $NuspecProjects = ` "src/Stats.CollectAzureCdnLogs/Stats.CollectAzureCdnLogs.csproj", ` "src/Stats.AggregateCdnDownloadsInGallery/Stats.AggregateCdnDownloadsInGallery.csproj", ` "src/Stats.ImportAzureCdnStatistics/Stats.ImportAzureCdnStatistics.csproj", ` @@ -181,12 +185,10 @@ Invoke-BuildStep 'Creating artifacts' { "src/Monitoring.RebootSearchInstance/Monitoring.RebootSearchInstance.csproj", ` "src/StatusAggregator/StatusAggregator.csproj", ` "src/Validation.Symbols.Core/Validation.Symbols.Core.csproj", ` - "src/Validation.Symbols/Validation.Symbols.csproj" ` - + $ProjectsWithSymbols + "src/Validation.Symbols/Validation.Symbols.csproj" - Foreach ($Project in $Projects) { - $Symbols = $ProjectsWithSymbols -contains $Project; - New-Package (Join-Path $PSScriptRoot "$Project") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -MSBuildVersion "$msBuildVersion" -Symbols:$Symbols + Foreach ($Project in $NuspecProjects) { + New-Package (Join-Path $PSScriptRoot "$Project") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -MSBuildVersion "$msBuildVersion" } } ` -ev +BuildErrors diff --git a/src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj b/src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj index 647f69162..427a108ca 100644 --- a/src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj +++ b/src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj @@ -15,6 +15,10 @@ TRACE + + .NET Foundation + true + true full @@ -90,6 +94,11 @@ 1.1.2 + + 4.8.0 + runtime; build; native; contentfiles; analyzers + all + 2.27.0 diff --git a/src/Validation.Common.Job/Validation.Common.Job.csproj b/src/Validation.Common.Job/Validation.Common.Job.csproj index 3ae2596e1..845c7184b 100644 --- a/src/Validation.Common.Job/Validation.Common.Job.csproj +++ b/src/Validation.Common.Job/Validation.Common.Job.csproj @@ -14,6 +14,10 @@ true + + .NET Foundation + true + true full @@ -90,6 +94,11 @@ 1.1.2 + + 4.8.0 + runtime; build; native; contentfiles; analyzers + all + 4.8.0-preview4.5289 @@ -127,11 +136,6 @@ NuGet.Jobs.Common - - - Designer - - ..\..\build diff --git a/src/Validation.Common.Job/Validation.Common.Job.nuspec b/src/Validation.Common.Job/Validation.Common.Job.nuspec deleted file mode 100644 index 0c007762b..000000000 --- a/src/Validation.Common.Job/Validation.Common.Job.nuspec +++ /dev/null @@ -1,31 +0,0 @@ - - - - NuGet.Services.Validation.Common.Job - $version$ - NuGet.Services.Validation.Common.Job - .NET Foundation - .NET Foundation - NuGet.Services.Validation.Common.Job - Copyright .NET Foundation - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj b/src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj index 6c215c062..6f22f9ec2 100644 --- a/src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj +++ b/src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj @@ -14,6 +14,10 @@ true + + .NET Foundation + true + true full @@ -54,6 +58,11 @@ 1.1.2 + + 4.8.0 + runtime; build; native; contentfiles; analyzers + all + 2.27.0 diff --git a/src/Validation.Symbols.Core/Validation.Symbols.Core.csproj b/src/Validation.Symbols.Core/Validation.Symbols.Core.csproj index 458185a9a..5dc6080d5 100644 --- a/src/Validation.Symbols.Core/Validation.Symbols.Core.csproj +++ b/src/Validation.Symbols.Core/Validation.Symbols.Core.csproj @@ -14,6 +14,10 @@ true + + .NET Foundation + true + true full @@ -58,6 +62,11 @@ + + 4.8.0 + runtime; build; native; contentfiles; analyzers + all + 2.29.0 diff --git a/tests/Validation.Common.Job.Tests/CsprojNuspecConsistencyFacts.cs b/tests/Validation.Common.Job.Tests/CsprojNuspecConsistencyFacts.cs deleted file mode 100644 index 91f80d980..000000000 --- a/tests/Validation.Common.Job.Tests/CsprojNuspecConsistencyFacts.cs +++ /dev/null @@ -1,105 +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.IO; -using System.Linq; -using System.Xml.Linq; -using Xunit; - -namespace Validation.Common.Job.Tests -{ - public class CsprojNuspecConsistencyFacts - { - [Fact] - public void CsprojReferencesMatchNuspec() - { - var sln = TryFindFile(Directory.GetCurrentDirectory(), "NuGet.Jobs.sln"); - var csproj = new FileInfo(Path.Combine(sln.Directory.FullName, @"src\Validation.Common.Job\Validation.Common.Job.csproj")); - var nuspec = new FileInfo(Path.Combine(sln.Directory.FullName, @"src\Validation.Common.Job\Validation.Common.Job.nuspec")); - - var csprojDoc = XDocument.Load(csproj.FullName); - var nuspecDoc = XDocument.Load(nuspec.FullName); - - var csprojPackageReferences = csprojDoc.Root.Descendants().Where(e => e.Name.LocalName == "PackageReference").ToList(); - var nuspecDependencies = nuspecDoc.Root.Descendants().Where(e => e.Name.LocalName == "dependency").ToList(); - - var nuspecDependencyList = nuspecDependencies.Select(GetNuspecDependencyInfo).ToList(); - - foreach (var csprojRef in csprojPackageReferences.Select(GetCsprojDependencyInfo)) - { - Assert.Contains(csprojRef, nuspecDependencyList); - } - } - - private FileInfo TryFindFile(string startDirectory, string filename) - { - var path = new DirectoryInfo(startDirectory); - - FileInfo[] files = null; - - while (path != null && (files = path.GetFiles()).Count(f => f.Name == filename) <= 0) - { - path = path.Parent; - } - - return files?.FirstOrDefault(f => f.Name == filename); - } - - private DependencyInfo GetCsprojDependencyInfo(XElement xelement) - { - string id = xelement.Attribute("Include").Value; - var versionAttribute = xelement.Attributes().FirstOrDefault(xa => xa.Name.LocalName == "Version"); - var versionChild = xelement.Elements().FirstOrDefault(xa => xa.Name.LocalName == "Version"); - string version = null; - - if (versionChild != null) - { - version = versionChild.Value; - } - else if (versionAttribute != null) - { - version = versionAttribute.Value; - } - - Assert.NotNull(id); - Assert.NotNull(version); - - return new DependencyInfo(id, version); - } - - private DependencyInfo GetNuspecDependencyInfo(XElement xelement) - { - var idAttribute = xelement.Attributes().FirstOrDefault(xa => xa.Name.LocalName == "id"); - var versionAttribute = xelement.Attributes().FirstOrDefault(xa => xa.Name.LocalName == "version"); - - Assert.NotNull(idAttribute); - Assert.NotNull(versionAttribute); - - return new DependencyInfo(idAttribute.Value, versionAttribute.Value); - } - - private class DependencyInfo : IEquatable - { - public string PackageId { get; } - public string PackageVersion { get; } - - public DependencyInfo(string packageId, string packageVersion) - { - PackageId = packageId; - PackageVersion = packageVersion; - } - - public bool Equals(DependencyInfo other) - { - return PackageId.Equals(other.PackageId, StringComparison.OrdinalIgnoreCase) - && PackageVersion.Equals(other.PackageVersion, StringComparison.OrdinalIgnoreCase); - } - - public override string ToString() - { - return $"{PackageId} {PackageVersion}"; - } - } - } -} diff --git a/tests/Validation.Common.Job.Tests/Validation.Common.Job.Tests.csproj b/tests/Validation.Common.Job.Tests/Validation.Common.Job.Tests.csproj index 6cfbf0ee8..0f868bbec 100644 --- a/tests/Validation.Common.Job.Tests/Validation.Common.Job.Tests.csproj +++ b/tests/Validation.Common.Job.Tests/Validation.Common.Job.Tests.csproj @@ -42,7 +42,6 @@ -