Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit e01c553

Browse files
authored
New artifacts (#384)
* Build now should produce two more packages: NuGet.Jobs.Common and Validation.Common.Job * No non-auto-generated assembly versions for new packages * Removed ExtractAndValidate references (project was renamed) * Dropped branch from package id * Manual dependencies in Validation.Common.Job.nuspec * Hacky test to check that nuspec dependencies match csproj package reference list. * Removed auto added node
1 parent 80a5a5b commit e01c553

7 files changed

Lines changed: 145 additions & 4 deletions

File tree

build.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' { `
108108
"$PSScriptRoot\src\NuGet.Services.Validation.Orchestrator\Properties\AssemblyInfo.g.cs",
109109
"$PSScriptRoot\src\Stats.CollectAzureChinaCDNLogs\Properties\AssemblyInfo.g.cs",
110110
"$PSScriptRoot\src\Validation.PackageSigning.ProcessSignature\Properties\AssemblyInfo.g.cs",
111-
"$PSScriptRoot\src\Validation.PackageSigning.ValidateCertificate\Properties\AssemblyInfo.g.cs"
111+
"$PSScriptRoot\src\Validation.PackageSigning.ValidateCertificate\Properties\AssemblyInfo.g.cs",
112+
"$PSScriptRoot\src\NuGet.Jobs.Common\Properties\AssemblyInfo.g.cs",
113+
"$PSScriptRoot\src\Validation.Common.Job\Properties\AssemblyInfo.g.cs"
112114

113115
$versionMetadata | ForEach-Object {
114116
Set-VersionInfo -Path $_ -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
@@ -156,7 +158,9 @@ Invoke-BuildStep 'Creating artifacts' {
156158
"src/NuGet.Services.Validation.Orchestrator/NuGet.Services.Validation.Orchestrator.csproj", `
157159
"src/Stats.CollectAzureChinaCDNLogs/Stats.CollectAzureChinaCDNLogs.csproj", `
158160
"src/Validation.PackageSigning.ProcessSignature/Validation.PackageSigning.ProcessSignature.csproj", `
159-
"src/Validation.PackageSigning.ValidateCertificate/Validation.PackageSigning.ValidateCertificate.csproj"
161+
"src/Validation.PackageSigning.ValidateCertificate/Validation.PackageSigning.ValidateCertificate.csproj", `
162+
"src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj", `
163+
"src/Validation.Common.Job/Validation.Common.Job.csproj"
160164

161165
Foreach ($Project in $Projects) {
162166
New-Package (Join-Path $PSScriptRoot "$Project") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -MSBuildVersion "$msBuildVersion"

src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
<Compile Include="JobBase.cs" />
202202
<Compile Include="JobRunner.cs" />
203203
<Compile Include="Properties\AssemblyInfo.cs" />
204+
<Compile Include="Properties\AssemblyInfo.*.cs" />
204205
<Compile Include="StorageHelpers.cs" />
205206
<Compile Include="Strings.Designer.cs" />
206207
</ItemGroup>

src/NuGet.Jobs.Common/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@
1111
[assembly: AssemblyCopyright("Copyright © .NET Foundation 2015")]
1212
[assembly: ComVisible(false)]
1313
[assembly: Guid("6dc01e18-81b0-49b4-9976-4a3548c6a959")]
14-
[assembly: AssemblyVersion("1.0.0.0")]
15-
[assembly: AssemblyFileVersion("1.0.0.0")]

src/Validation.Common.Job/Validation.Common.Job.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<Compile Include="LoggerDiagnosticsSource.cs" />
4646
<Compile Include="PackageDownloader.cs" />
4747
<Compile Include="Properties\AssemblyInfo.cs" />
48+
<Compile Include="Properties\AssemblyInfo.*.cs" />
4849
<Compile Include="Storage\AddStatusResult.cs" />
4950
<Compile Include="Storage\IValidatorStateService.cs" />
5051
<Compile Include="Storage\SaveStatusResult.cs" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>NuGet.Services.Validation.Common.Job</id>
5+
<version>$version$</version>
6+
<title>NuGet.Services.Validation.Common.Job</title>
7+
<authors>.NET Foundation</authors>
8+
<owners>.NET Foundation</owners>
9+
<description>NuGet.Services.Validation.Common.Job</description>
10+
<copyright>Copyright .NET Foundation</copyright>
11+
<dependencies>
12+
<dependency id="NuGet.Jobs.Common" version="$version$" />
13+
<dependency id="Autofac" version="4.6.2" />
14+
<dependency id="Autofac.Extensions.DependencyInjection" version="4.2.0" />
15+
<dependency id="Microsoft.ApplicationInsights" version="2.2.0" />
16+
<dependency id="Microsoft.Extensions.DependencyInjection" version="1.1.1" />
17+
<dependency id="Microsoft.Extensions.Options.ConfigurationExtensions" version="1.1.2" />
18+
<dependency id="NuGet.Packaging" version="4.7.0-preview1.5029" />
19+
<dependency id="NuGet.Services.Configuration" version="2.19.1" />
20+
<dependency id="NuGet.Services.Logging" version="2.19.1" />
21+
<dependency id="NuGet.Services.Storage" version="2.19.1" />
22+
<dependency id="NuGet.Services.Validation" version="2.19.1" />
23+
<dependency id="NuGetGallery.Core" version="4.4.4-dev-26021" />
24+
<dependency id="Serilog" version="2.5.0" />
25+
<dependency id="System.Net.Http" version="4.3.3" />
26+
</dependencies>
27+
</metadata>
28+
</package>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Xml.Linq;
11+
using Xunit;
12+
13+
namespace Validation.Common.Job.Tests
14+
{
15+
public class CsprojNuspecConsistencyFacts
16+
{
17+
[Fact]
18+
public void CsprojReferencesMatchNuspec()
19+
{
20+
var sln = TryFindFile(Directory.GetCurrentDirectory(), "NuGet.Jobs.sln");
21+
var csproj = new FileInfo(Path.Combine(sln.Directory.FullName, @"src\Validation.Common.Job\Validation.Common.Job.csproj"));
22+
var nuspec = new FileInfo(Path.Combine(sln.Directory.FullName, @"src\Validation.Common.Job\Validation.Common.Job.nuspec"));
23+
24+
var csprojDoc = XDocument.Load(csproj.FullName);
25+
var nuspecDoc = XDocument.Load(nuspec.FullName);
26+
27+
var csprojPackageReferences = csprojDoc.Root.Descendants().Where(e => e.Name.LocalName == "PackageReference").ToList();
28+
var nuspecDependencies = nuspecDoc.Root.Descendants().Where(e => e.Name.LocalName == "dependency").ToList();
29+
30+
var nuspecDependencyList = nuspecDependencies.Select(GetNuspecDependencyInfo).ToList();
31+
32+
foreach (var csprojRef in csprojPackageReferences.Select(GetCsprojDependencyInfo))
33+
{
34+
Assert.Contains(csprojRef, nuspecDependencyList);
35+
}
36+
}
37+
38+
private FileInfo TryFindFile(string startDirectory, string filename)
39+
{
40+
var path = new DirectoryInfo(startDirectory);
41+
42+
FileInfo[] files = null;
43+
44+
while (path != null && (files = path.GetFiles()).Count(f => f.Name == filename) <= 0)
45+
{
46+
path = path.Parent;
47+
}
48+
49+
return files?.FirstOrDefault(f => f.Name == filename);
50+
}
51+
52+
private DependencyInfo GetCsprojDependencyInfo(XElement xelement)
53+
{
54+
string id = xelement.Attribute("Include").Value;
55+
var versionAttribute = xelement.Attributes().FirstOrDefault(xa => xa.Name.LocalName == "Version");
56+
var versionChild = xelement.Elements().FirstOrDefault(xa => xa.Name.LocalName == "Version");
57+
string version = null;
58+
59+
if (versionChild != null)
60+
{
61+
version = versionChild.Value;
62+
}
63+
else if (versionAttribute != null)
64+
{
65+
version = versionAttribute.Value;
66+
}
67+
68+
Assert.NotNull(id);
69+
Assert.NotNull(version);
70+
71+
return new DependencyInfo(id, version);
72+
}
73+
74+
private DependencyInfo GetNuspecDependencyInfo(XElement xelement)
75+
{
76+
var idAttribute = xelement.Attributes().FirstOrDefault(xa => xa.Name.LocalName == "id");
77+
var versionAttribute = xelement.Attributes().FirstOrDefault(xa => xa.Name.LocalName == "version");
78+
79+
Assert.NotNull(idAttribute);
80+
Assert.NotNull(versionAttribute);
81+
82+
return new DependencyInfo(idAttribute.Value, versionAttribute.Value);
83+
}
84+
85+
private class DependencyInfo : IEquatable<DependencyInfo>
86+
{
87+
public string PackageId { get; }
88+
public string PackageVersion { get; }
89+
90+
public DependencyInfo(string packageId, string packageVersion)
91+
{
92+
PackageId = packageId;
93+
PackageVersion = packageVersion;
94+
}
95+
96+
public bool Equals(DependencyInfo other)
97+
{
98+
return PackageId.Equals(other.PackageId, StringComparison.OrdinalIgnoreCase)
99+
&& PackageVersion.Equals(other.PackageVersion, StringComparison.OrdinalIgnoreCase);
100+
}
101+
102+
public override string ToString()
103+
{
104+
return $"{PackageId} {PackageVersion}";
105+
}
106+
}
107+
}
108+
}

tests/Validation.Common.Job.Tests/Validation.Common.Job.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</ItemGroup>
4141
<ItemGroup>
4242
<Compile Include="CommonTelemetryServiceFacts.cs" />
43+
<Compile Include="CsprojNuspecConsistencyFacts.cs" />
4344
<Compile Include="LoggerDiagnosticSourceFacts.cs" />
4445
<Compile Include="Properties\AssemblyInfo.cs" />
4546
</ItemGroup>

0 commit comments

Comments
 (0)