Skip to content

Commit 26b809d

Browse files
authored
Check PublishData.json feeds (#72333)
* Update BuildBoss docs * Check PublishData.json
1 parent f520a73 commit 26b809d

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

src/Tools/BuildBoss/CompilerNuGetCheckerUtil.cs

+41-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Reflection.PortableExecutable;
1616
using System.Security.Cryptography;
1717
using System.Text.RegularExpressions;
18+
using Newtonsoft.Json.Linq;
1819

1920
namespace BuildBoss
2021
{
@@ -72,6 +73,7 @@ public bool Check(TextWriter textWriter)
7273
try
7374
{
7475
var allGood = true;
76+
allGood &= CheckPublishData(textWriter);
7577
allGood &= CheckPackages(textWriter);
7678
allGood &= CheckExternalApis(textWriter);
7779
return allGood;
@@ -83,6 +85,44 @@ public bool Check(TextWriter textWriter)
8385
}
8486
}
8587

88+
/// <summary>
89+
/// Verify PublishData.json contains feeds for all packages that will be published.
90+
/// </summary>
91+
private bool CheckPublishData(TextWriter textWriter)
92+
{
93+
var allGood = true;
94+
95+
// Load PublishData.json
96+
var publishDataPath = Path.Combine(RepositoryDirectory, "eng", "config", "PublishData.json");
97+
var publishDataRoot = JObject.Parse(File.ReadAllText(publishDataPath));
98+
var publishDataPackages = publishDataRoot["packages"]["default"] as JObject;
99+
100+
// Check all shipping packages have an entry in PublishData.json
101+
var regex = new Regex(@"^(.*?)\.\d.*\.nupkg$");
102+
var packagesDirectory = Path.Combine(ArtifactsDirectory, "packages", Configuration, "Shipping");
103+
foreach (var packageFullPath in Directory.EnumerateFiles(packagesDirectory, "*.nupkg"))
104+
{
105+
var packageFileName = Path.GetFileName(packageFullPath);
106+
var match = regex.Match(packageFileName);
107+
if (!match.Success)
108+
{
109+
allGood = false;
110+
textWriter.WriteLine($"Unexpected package file name '{packageFileName}'");
111+
}
112+
else
113+
{
114+
var packageId = match.Groups[1].Value;
115+
if (!publishDataPackages.ContainsKey(packageId))
116+
{
117+
allGood = false;
118+
textWriter.WriteLine($"Package doesn't have corresponding PublishData.json entry: {packageId} ({packageFileName})");
119+
}
120+
}
121+
}
122+
123+
return allGood;
124+
}
125+
86126
/// <summary>
87127
/// Verify the contents of the compiler packages match the expected input
88128
/// </summary>
@@ -360,7 +400,7 @@ void verifyFolder(string folderRelativeName)
360400
}
361401

362402
// As a simplification we only validate the assembly names that begin with Microsoft.CodeAnalysis. This is a good
363-
// hueristic for finding assemblies that we build. Can be expanded in the future if we find more assemblies that
403+
// heuristic for finding assemblies that we build. Can be expanded in the future if we find more assemblies that
364404
// are worth validating here.
365405
var neededDllNames = neededDllNameSet
366406
.Where(x => x.StartsWith("Microsoft.CodeAnalysis"))

src/Tools/BuildBoss/ProjectCheckerUtil.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private bool CheckDeploymentSettings(TextWriter textWriter)
174174

175175
/// <summary>
176176
/// It's important that every reference be included in the solution. MSBuild does not necessarily
177-
/// apply all configuration entries to projects which are compiled via referenes but not included
177+
/// apply all configuration entries to projects which are compiled via references but not included
178178
/// in the solution.
179179
/// </summary>
180180
private bool CheckProjectReferencesComplete(TextWriter textWriter, IEnumerable<ProjectKey> declaredReferences)

src/Tools/BuildBoss/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is a tool to validate the state of our solutions, project files and other b
66
> BuildBoss.exe <solution / project / targets path / build log paths>
77
```
88

9-
This tool is run on every CI job against our important solution files: [Roslyn.sln](https://github.com/dotnet/roslyn/blob/main/Roslyn.sln), and [CrossPlatform.sln](https://github.com/dotnet/roslyn/blob/main/CrossPlatform.sln).
9+
This tool is run on every CI job against our important solution files: [Roslyn.sln](https://github.com/dotnet/roslyn/blob/main/Roslyn.sln).
1010

1111
Violations reported are important to fix as they represent correctness issues in our build. Many of the properties verified represent problems that otherwise won't be verified at check in time.
1212

@@ -39,13 +39,13 @@ There are a number of properties which are simply unnecessary for build. They a
3939

4040
### Transitive references
4141

42-
Projects which represent full deployments must have a complete set of project references declared in the project file. Or in other words the declared set of project references much match the tranistive closure of project references. Any gap between the two sets won't be deployed on build which in turn will break F5, testing, etc ...
42+
Projects which represent full deployments must have a complete set of project references declared in the project file. Or in other words the declared set of project references much match the transitive closure of project references. Any gap between the two sets won't be deployed on build which in turn will break F5, testing, etc ...
4343

4444
### Classifying projects
4545

4646
Our build process depends on being able to correctly classify our projects: exe, VSIX, dll, etc ... This can typically be inferred from properties like OutputType. But in other occasions it requires a more declarative entry via the `<RoslynProjectType>` property. The tool will catch places where projects are incorrectly classified.
4747

48-
This could be done using MSBuild targets but the logic is hard to follow and complicates the build. It's easier and more readable to have a declaritive entry in the file.
48+
This could be done using MSBuild targets but the logic is hard to follow and complicates the build. It's easier and more readable to have a declarative entry in the file.
4949

5050
## Solution Content Verified
5151

@@ -57,7 +57,7 @@ This is best demonstrated by example. Consider the following setup:
5757
- Project App.csproj produces App.exe and references Util.csproj
5858
- Solution App.sln includes App.csproj only
5959

60-
Now consider when App.sln is build with the following command line:
60+
Now consider when App.sln is built with the following command line:
6161

6262
``` cmd
6363
msbuild /p:Configuration=Release App.sln

0 commit comments

Comments
 (0)