Skip to content

Commit 9cf1ace

Browse files
authored
[release/6.0] Check solution filters (#37114)
- backport of #36449 and #36756 Dougbu/check.solution.filters (#36449) * Check solution filters - confirm all mentioned projects are in AspNetCore.sln - clean up CodeCheck.ps1 - avoid aliases - rework long lines - avoid deprecated `dotnet run -p` - improve output a bit - correct whitespace - there can be only one - we have just one solution file - solution file should mention projects _once_ * Add missing projects to AspNetCore.sln - Middleware.slnf contained projects that no longer exist eg. NodeServices - VS also sorted the file and VS 2019 added ARM64 configurations - a few other solution filters still referenced removed and moved projects - correct capitalization in some solution filters Note: Unable to load some WiX projects in VS 2019 or _any_ in VS 2022 (WiX extension unavailable for 2022) * Remove trailing comma in a solution filter Put concatenated `string`s in parentheses (#36756) - follow-up to 779db7f - errors occur but point to the `+` sign instead of displaying real problem
1 parent 9341ccb commit 9cf1ace

File tree

13 files changed

+2711
-250
lines changed

13 files changed

+2711
-250
lines changed

AspNetCore.sln

Lines changed: 2506 additions & 48 deletions
Large diffs are not rendered by default.

eng/scripts/CodeCheck.ps1

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ try {
5050
if ($ci) {
5151
# Install dotnet.exe
5252
if ($RuntimeSourceFeed -or $RuntimeSourceFeedKey) {
53-
& $repoRoot/restore.cmd -ci -nobl -noBuildNodeJS -RuntimeSourceFeed $RuntimeSourceFeed -RuntimeSourceFeedKey $RuntimeSourceFeedKey
54-
}
55-
else{
53+
& $repoRoot/restore.cmd -ci -nobl -noBuildNodeJS -RuntimeSourceFeed $RuntimeSourceFeed `
54+
-RuntimeSourceFeedKey $RuntimeSourceFeedKey
55+
} else {
5656
& $repoRoot/restore.cmd -ci -nobl -noBuildNodeJS
5757
}
5858
}
@@ -67,16 +67,17 @@ try {
6767

6868
# Ignore duplicates in submodules. These should be isolated from the rest of the build.
6969
# Ignore duplicates in the .ref folder. This is expected.
70-
Get-ChildItem -Recurse "$repoRoot/src/*.*proj" `
71-
| ? { $_.FullName -notmatch 'submodules' -and $_.FullName -notmatch 'node_modules' } `
72-
| ? { (Split-Path -Leaf (Split-Path -Parent $_)) -ne 'ref' } `
73-
| % {
74-
$fileName = [io.path]::GetFileNameWithoutExtension($_)
75-
if (-not ($projectFileNames.Add($fileName))) {
76-
LogError -code 'BUILD003' -filepath $_ `
77-
"Multiple project files named '$fileName' exist. Project files should have a unique name to avoid conflicts in build output."
78-
}
70+
Get-ChildItem -Recurse "$repoRoot/src/*.*proj" |
71+
Where-Object { $_.FullName -notmatch 'submodules' -and $_.FullName -notmatch 'node_modules' } |
72+
Where-Object { (Split-Path -Leaf (Split-Path -Parent $_)) -ne 'ref' } |
73+
ForEach-Object {
74+
$fileName = [io.path]::GetFileNameWithoutExtension($_)
75+
if (-not ($projectFileNames.Add($fileName))) {
76+
LogError -code 'BUILD003' -filepath $_ `
77+
("Multiple project files named '$fileName' exist. Project files should have a unique name " +
78+
"to avoid conflicts in build output.")
7979
}
80+
}
8081

8182
#
8283
# Versions.props and Version.Details.xml
@@ -102,9 +103,9 @@ try {
102103
$actualVersion = $globalJson.'msbuild-sdks'.($dep.Name)
103104

104105
if ($expectedVersion -ne $actualVersion) {
105-
LogError `
106-
"MSBuild SDK version '$($dep.Name)' in global.json does not match the value in Version.Details.xml. Expected '$expectedVersion', actual '$actualVersion'" `
107-
-filepath "$repoRoot\global.json"
106+
LogError -filepath "$repoRoot\global.json" `
107+
("MSBuild SDK version '$($dep.Name)' in global.json does not match the value in " +
108+
"Version.Details.xml. Expected '$expectedVersion', actual '$actualVersion'")
108109
}
109110
}
110111
else {
@@ -122,58 +123,68 @@ try {
122123
}
123124

124125
if ($expectedVersion -ne $actualVersion) {
125-
LogError `
126-
"Version variable '$varName' does not match the value in Version.Details.xml. Expected '$expectedVersion', actual '$actualVersion'" `
127-
-filepath "$repoRoot\eng\Versions.props"
126+
LogError -filepath "$repoRoot\eng\Versions.props" `
127+
("Version variable '$varName' does not match the value in Version.Details.xml. " +
128+
"Expected '$expectedVersion', actual '$actualVersion'")
128129
}
129130
}
130131
}
131132

132133
foreach ($unexpectedVar in $versionVars) {
133-
LogError `
134-
"Version variable '$unexpectedVar' does not have a matching entry in Version.Details.xml. See https://github.com/dotnet/aspnetcore/blob/main/docs/ReferenceResolution.md for instructions on how to add a new dependency." `
135-
-filepath "$repoRoot\eng\Versions.props"
134+
LogError -Filepath "$repoRoot\eng\Versions.props" `
135+
("Version variable '$unexpectedVar' does not have a matching entry in Version.Details.xml. " +
136+
"See https://github.com/dotnet/aspnetcore/blob/main/docs/ReferenceResolution.md for instructions " +
137+
"on how to add a new dependency.")
136138
}
137139

138-
Write-Host "Checking that solutions are up to date"
139-
140-
Get-ChildItem "$repoRoot/*.sln" -Recurse `
141-
| ? {
142-
# These .sln files are used by the templating engine.
143-
($_.Name -ne "BlazorServerWeb_CSharp.sln") -and
144-
($_.Name -ne "ComponentsWebAssembly-CSharp.sln")
145-
} `
146-
| % {
147-
Write-Host " Checking $(Split-Path -Leaf $_)"
148-
$slnDir = Split-Path -Parent $_
149-
$sln = $_
150-
& dotnet sln $_ list `
151-
| ? { $_ -like '*proj' } `
152-
| % {
153-
$proj = Join-Path $slnDir $_
154-
if (-not (Test-Path $proj)) {
155-
LogError "Missing project. Solution references a project which does not exist: $proj. [$sln] "
156-
}
140+
# ComponentsWebAssembly-CSharp.sln is used by the templating engine; MessagePack.sln is irrelevant (in submodule).
141+
$solution = Get-ChildItem "$repoRoot/AspNetCore.sln"
142+
$solutionFile = Split-Path -Leaf $solution
143+
144+
Write-Host "Checking that $solutionFile is up to date"
145+
146+
# $solutionProjects will store relative paths i.e. the exact solution and solution filter content.
147+
$solutionProjects = New-Object 'System.Collections.Generic.HashSet[string]'
148+
149+
# Where-Object needed to ignore heading `dotnet sln` outputs
150+
& dotnet sln $solution list | Where-Object { $_ -like '*proj' } | ForEach-Object {
151+
$proj = Join-Path $repoRoot $_
152+
if (-not ($solutionProjects.Add($_))) {
153+
LogError "Duplicate project. $solutionFile references a project more than once: $proj."
154+
}
155+
if (-not (Test-Path $proj)) {
156+
LogError "Missing project. $solutionFile references a project which does not exist: $proj."
157+
}
158+
}
159+
160+
Write-Host "Checking solution filters"
161+
Get-ChildItem -Recurse "$repoRoot\*.slnf" | ForEach-Object {
162+
$solutionFilter = $_
163+
$json = Get-Content -Raw -Path $solutionFilter |ConvertFrom-Json
164+
$json.solution.projects | ForEach-Object {
165+
if (!$solutionProjects.Contains($_)) {
166+
LogError "$solutionFilter references a project not in $solutionFile`: $_"
157167
}
158168
}
169+
}
159170

160171
#
161172
# Generated code check
162173
#
163174

164175
Write-Host "Re-running code generation"
165176

166-
Write-Host "Re-generating project lists"
177+
Write-Host " Re-generating project lists"
167178
Invoke-Block {
168179
& $PSScriptRoot\GenerateProjectList.ps1 -ci:$ci
169180
}
170181

171-
Write-Host "Re-generating package baselines"
182+
Write-Host " Re-generating package baselines"
172183
Invoke-Block {
173-
& dotnet run -p "$repoRoot/eng/tools/BaselineGenerator/"
184+
& dotnet run --project "$repoRoot/eng/tools/BaselineGenerator/"
174185
}
175186

176-
Write-Host "Run git diff to check for pending changes"
187+
Write-Host "Running git diff to check for pending changes"
177188

178189
# Redirect stderr to stdout because PowerShell does not consistently handle output to stderr
179190
$changedFiles = & cmd /c 'git --no-pager diff --ignore-space-change --name-only 2>nul'
@@ -186,7 +197,9 @@ try {
186197
foreach ($file in $changedFiles) {
187198
if ($changedFilesExclusions -contains $file) {continue}
188199
$filePath = Resolve-Path "${repoRoot}/${file}"
189-
LogError "Generated code is not up to date in $file. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md)" -filepath $filePath
200+
LogError -filepath $filePath `
201+
("Generated code is not up to date in $file. You might need to regenerate the reference " +
202+
"assemblies or project list (see docs/ReferenceResolution.md)")
190203
& git --no-pager diff --ignore-space-change $filePath
191204
}
192205
}
@@ -222,7 +235,8 @@ try {
222235
Write-Host "Found changes in $($changedAPIBaselines.count) API baseline files"
223236

224237
if ($changedAPIBaselines.count -gt 0) {
225-
LogError "Detected modification to baseline API files. PublicAPI.Shipped.txt files should only be updated after a major release. See /docs/APIBaselines.md for more information."
238+
LogError ("Detected modification to baseline API files. PublicAPI.Shipped.txt files should only " +
239+
"be updated after a major release. See /docs/APIBaselines.md for more information.")
226240
LogError "Modified API baseline files:"
227241
foreach ($file in $changedAPIBaselines) {
228242
LogError $file

src/Installers/Windows/AspNetCoreModule-Setup/IIS-Setup/IIS-Common/reftrace/reftrace.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\build\submodule.props" />
4-
<Import Project="..\build\settings.props" />
3+
<Import Project="..\..\..\build\submodule.props" />
4+
<Import Project="..\..\..\build\settings.props" />
55
<ItemGroup Label="ProjectConfigurations">
66
<ProjectConfiguration Include="Debug|Win32">
77
<Configuration>Debug</Configuration>

src/Installers/Windows/Installers.slnf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
"src\\Installers\\Windows\\AspNetCoreModule-Setup\\CustomAction\\aspnetcoreCA.vcxproj",
66
"src\\Installers\\Windows\\AspNetCoreModule-Setup\\IIS-Setup\\iisca\\lib\\iisca.vcxproj",
77
"src\\Installers\\Windows\\AspNetCoreModule-Setup\\IIS-Setup\\IIS-Common\\lib\\IISSetup.CommonLib.vcxproj",
8-
"src\\Installers\\Windows\\AspNetCoreModule-Setup\\ANCMIISExpressV2\\AncmIISExpressV2.wixproj",
98
"src\\Installers\\Windows\\SharedFrameworkLib\\SharedFrameworkLib.wixproj",
109
"src\\Installers\\Windows\\SharedFrameworkBundle\\SharedFrameworkBundle.wixproj",
11-
"src\\Installers\\Windows\\AspNetCoreModule-Setup\\ANCMV2\\AncmV2.wixproj",
1210
"src\\Installers\\Windows\\WindowsHostingBundle\\WindowsHostingBundle.wixproj",
1311
"src\\Installers\\Windows\\SharedFramework\\SharedFramework.wixproj"
1412
]

src/Localization/Localization.slnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"src\\Localization\\Abstractions\\src\\Microsoft.Extensions.Localization.Abstractions.csproj",
66
"src\\Localization\\Localization\\src\\Microsoft.Extensions.Localization.csproj",
77
"src\\Localization\\Localization\\test\\Microsoft.Extensions.Localization.RootNamespace.Tests\\Microsoft.Extensions.Localization.RootNamespace.Tests.csproj",
8-
"src\\Localization\\Localization\\test\\Microsoft.Extensions.Localization.Tests\\Microsoft.Extensions.Localization.Tests.csproj",
8+
"src\\Localization\\Localization\\test\\Microsoft.Extensions.Localization.Tests\\Microsoft.Extensions.Localization.Tests.csproj"
99
]
1010
}
1111
}

src/Middleware/ConcurrencyLimiter/ConcurrencyLimiter.slnf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
"src\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj",
1515
"src\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj",
1616
"src\\Servers\\Kestrel\\Transport.Sockets\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj",
17-
"src\\http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
18-
"src\\http\\http\\src\\Microsoft.AspNetCore.Http.csproj",
17+
"src\\Http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
18+
"src\\Http\\Http\\src\\Microsoft.AspNetCore.Http.csproj",
1919
"src\\Middleware\\ConcurrencyLimiter\\perf\\Microbenchmarks\\Microsoft.AspNetCore.ConcurrencyLimiter.Microbenchmarks.csproj",
2020
"src\\Middleware\\ConcurrencyLimiter\\sample\\ConcurrencyLimiterSample.csproj",
2121
"src\\Middleware\\ConcurrencyLimiter\\src\\Microsoft.AspNetCore.ConcurrencyLimiter.csproj",
2222
"src\\Middleware\\ConcurrencyLimiter\\test\\Microsoft.AspNetCore.ConcurrencyLimiter.Tests.csproj",
2323
"src\\Middleware\\HttpsPolicy\\src\\Microsoft.AspNetCore.HttpsPolicy.csproj"
2424
]
2525
}
26-
}
26+
}

src/Middleware/Diagnostics/Diagnostics.slnf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"src\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj",
2222
"src\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj",
2323
"src\\Servers\\Kestrel\\Transport.Sockets\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj",
24-
"src\\http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
25-
"src\\http\\Routing\\src\\Microsoft.AspNetCore.Routing.csproj",
26-
"src\\http\\http\\src\\Microsoft.AspNetCore.Http.csproj",
24+
"src\\Http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
25+
"src\\Http\\Routing\\src\\Microsoft.AspNetCore.Routing.csproj",
26+
"src\\Http\\Http\\src\\Microsoft.AspNetCore.Http.csproj",
2727
"src\\Middleware\\Diagnostics.Abstractions\\src\\Microsoft.AspNetCore.Diagnostics.Abstractions.csproj",
2828
"src\\Middleware\\Diagnostics.EntityFrameworkCore\\src\\Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.csproj",
2929
"src\\Middleware\\Diagnostics.EntityFrameworkCore\\test\\FunctionalTests\\Diagnostics.EFCore.FunctionalTests.csproj",

0 commit comments

Comments
 (0)