Skip to content

Commit 296bc9d

Browse files
authored
Check nupkg dependencies exist in CI (#7309)
1 parent bde9562 commit 296bc9d

4 files changed

Lines changed: 61 additions & 53 deletions

File tree

eng/pipelines/pr.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ stages:
272272
- ${{ if eq(parameters.RunStaticAnalysis, true) }}:
273273
- job:
274274
displayName: Run Static Analysis
275-
timeoutInMinutes: 15
275+
timeoutInMinutes: 30
276276
pool:
277277
vmImage: windows-latest
278278
steps:
@@ -284,3 +284,62 @@ stages:
284284
displayName: Log Environment Variables
285285
- script: dotnet format whitespace --verify-no-changes NuGet.sln
286286
displayName: Run dotnet format whitespace
287+
condition: succeededOrFailed()
288+
- task: PowerShell@2
289+
displayName: Ensure all projects are in NuGet.sln
290+
condition: succeededOrFailed()
291+
inputs:
292+
targetType: inline
293+
script: |
294+
try {
295+
$slnProjects = & dotnet sln NuGet.sln list | Select-Object -Skip 2 | ForEach-Object { "$PWD\$_" } | sort
296+
"Solution contains $($slnProjects.Length) projects"
297+
$fsProjects = gci -Recurse -Filter *.csproj | ForEach-Object { $_.FullName } | Where-Object { $_ -notlike "*\EndToEnd\*" -and $_ -notlike "*\bin\*" -and $_ -notlike "*\compiler\resources\*" -and $_ -notlike "*\Assets\*" -and $_ -notlike "*\eng\*" } | sort
298+
"Repo contains $($fsProjects.Length) projects"
299+
$diff = @(Compare-Object -ReferenceObject $fsProjects -DifferenceObject $slnProjects)
300+
$diff
301+
if ($diff.length -gt 0)
302+
{
303+
throw "Repo has project file(s) not in NuGet.sln"
304+
}
305+
}
306+
catch
307+
{
308+
Write-Host "##vso[task.LogIssue type=error;]$Error[0]"
309+
exit 1
310+
}
311+
312+
- task: MSBuild@1
313+
displayName: Restore and Build
314+
condition: "and(succeededOrFailed(), ne(variables['SkipNupkgDependenciesCheck'], 'true'))"
315+
inputs:
316+
solution: NuGet.sln
317+
msbuildArchitecture: x64
318+
msbuildArguments: "/property:BuildRTM=true /property:MicroBuild_SigningEnabled=false"
319+
320+
- task: MSBuild@1
321+
displayName: Pack Nupkgs
322+
condition: "and(succeeded(), ne(variables['SkipNupkgDependenciesCheck'], 'true'))"
323+
inputs:
324+
solution: build\build.proj
325+
msbuildArchitecture: x64
326+
msbuildArguments: "/restore:false /target:Pack /property:BuildRTM=true /property:ExcludeTestProjects=true /property:MicroBuild_SigningEnabled=false"
327+
328+
- task: PowerShell@2
329+
displayName: Check package dependencies
330+
condition: "and(succeeded(), ne(variables['SkipNupkgDependenciesCheck'], 'true'))"
331+
inputs:
332+
targetType: inline
333+
script: |
334+
$nupkgs = Get-ChildItem artifacts/nupkgs/*.nupkg -Exclude *.symbols.nupkg,NuGet.CommandLine.XPlat.*
335+
if ($nupkgs.Count -eq 0) { throw "Could not find nupkgs" }
336+
"nupkgs:"
337+
$nupkgs.FullName
338+
""
339+
"Building validation tool"
340+
dotnet build tools-local/ensure-nupkg-dependencies-on-source/
341+
if ($LASTEXITCODE -ne 0) { throw "Build was not successful" }
342+
""
343+
"Running validation tool"
344+
dotnet run --project tools-local/ensure-nupkg-dependencies-on-source/ --no-build -- $nupkgs -s https://api.nuget.org/v3/index.json
345+
if ($LASTEXITCODE -ne 0) { throw "Validation tool failed" }

eng/pipelines/templates/Validate_Build_Output.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

eng/pipelines/templates/pipeline.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,3 @@ stages:
262262
parameters:
263263
BuildRTM: true
264264
SigningType: ${{ parameters.SigningType }}
265-
266-
- job: Validate_Publishing_Artifacts
267-
condition: "and(succeeded(), ne(variables['RunBuildForPublishing'], 'false'))"
268-
displayName: 'Validate Publishing build artifacts'
269-
dependsOn: Build_RTM
270-
timeoutInMinutes: 15
271-
pool:
272-
name: AzurePipelines-EO
273-
image: 1ESPT-Windows2022
274-
os: windows
275-
steps:
276-
- template: /eng/pipelines/templates/Validate_Build_Output.yml@self
277-
parameters:
278-
isOfficialBuild: ${{ parameters.isOfficialBuild }}

tools-local/ensure-nupkg-dependencies-on-source/ensure-nupkg-dependencies-on-source.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>$(NETCoreTargetFramework)</TargetFramework>
5+
<TargetFramework>$(LatestNETCoreTargetFramework)</TargetFramework>
66
<RootNamespace>ensure_nupkg_dependencies_on_source</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Description>Checks that the dependencies of one or more nupkgs are available on specified NuGet source(s)</Description>

0 commit comments

Comments
 (0)