-
-
Notifications
You must be signed in to change notification settings - Fork 1
Hardening SDK testing #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
004626c
Hardening SDK testing
josesimoes ad4ba00
Fix packing SDK in PR pack
josesimoes 0d09b9f
Fix from code review
josesimoes 0d4ed0a
Fix nbgv version config
josesimoes 7e94c60
Remove nbgv install
josesimoes af3fbc6
Another fix in nbgv version config
josesimoes 7d499cb
FIx getting nuget version
josesimoes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| [CmdletBinding()] | ||
| param( | ||
| [string]$Project = '', | ||
| [ValidateSet('Debug', 'Release')] | ||
| [string]$Configuration = 'Debug' | ||
| ) | ||
|
|
||
| Set-StrictMode -Version Latest | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| function Find-MSBuild { | ||
| $command = Get-Command msbuild.exe -ErrorAction SilentlyContinue | ||
| if ($null -ne $command) { | ||
| return $command.Source | ||
| } | ||
|
|
||
| $programFilesX86 = [Environment]::GetFolderPath('ProgramFilesX86') | ||
| $vswhere = Join-Path $programFilesX86 'Microsoft Visual Studio\Installer\vswhere.exe' | ||
| if (-not (Test-Path -LiteralPath $vswhere)) { | ||
| throw "Unable to locate msbuild.exe. Install Visual Studio Build Tools, or run from a Developer PowerShell where msbuild.exe is on PATH." | ||
| } | ||
|
|
||
| $msbuildPath = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -find 'MSBuild\**\Bin\MSBuild.exe' | Select-Object -First 1 | ||
| if ([string]::IsNullOrWhiteSpace($msbuildPath)) { | ||
| throw "Unable to locate msbuild.exe with vswhere. Install Visual Studio Build Tools, or run from a Developer PowerShell where msbuild.exe is on PATH." | ||
| } | ||
|
|
||
| return $msbuildPath | ||
| } | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace($Project)) { | ||
| $scriptPath = $PSCommandPath | ||
| if ([string]::IsNullOrWhiteSpace($scriptPath)) { | ||
| $scriptPath = $MyInvocation.MyCommand.Path | ||
| } | ||
| if ([string]::IsNullOrWhiteSpace($scriptPath)) { | ||
| throw 'Unable to resolve script path. Pass -Project explicitly.' | ||
| } | ||
|
|
||
| $scriptDirectory = Split-Path -Parent $scriptPath | ||
| $Project = Join-Path $scriptDirectory 'SmokeTest.csproj' | ||
| } | ||
|
|
||
| if (-not (Test-Path -LiteralPath $Project)) { | ||
| throw "Project not found: $Project" | ||
| } | ||
|
|
||
| function Build-And-CaptureNanoResources { | ||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [ValidateSet('dotnet', 'msbuild')] | ||
| [string]$Toolchain, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$ProjectPath, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$BuildConfiguration, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$CaptureDirectory, | ||
| [string]$MSBuildPath | ||
| ) | ||
|
|
||
| $projectDirectory = Split-Path -Parent $ProjectPath | ||
| $resourceDirectory = Join-Path $projectDirectory "obj\$BuildConfiguration\netnano1.0" | ||
|
|
||
| if (Test-Path -LiteralPath $resourceDirectory) { | ||
| Get-ChildItem -LiteralPath $resourceDirectory -Filter '*.nanoresources' -File | Remove-Item -Force | ||
| } | ||
|
|
||
| if ($Toolchain -eq 'dotnet') { | ||
| & dotnet build $ProjectPath -c $BuildConfiguration /nologo /v:minimal | ||
| $exitCode = $LASTEXITCODE | ||
| } | ||
| else { | ||
| & $MSBuildPath $ProjectPath /t:Build /p:Configuration=$BuildConfiguration /nologo /verbosity:minimal | ||
| $exitCode = $LASTEXITCODE | ||
| } | ||
|
|
||
| if (-not (Test-Path -LiteralPath $resourceDirectory)) { | ||
| throw "Expected intermediate output directory was not produced: $resourceDirectory" | ||
| } | ||
|
|
||
| $resourceFiles = @(Get-ChildItem -LiteralPath $resourceDirectory -Filter '*.nanoresources' -File) | ||
| if ($exitCode -ne 0) { | ||
| throw "$Toolchain build failed with exit code $exitCode." | ||
| } | ||
|
|
||
| if ($resourceFiles.Count -eq 0) { | ||
| throw "No .nanoresources files were produced under: $resourceDirectory" | ||
| } | ||
|
|
||
| foreach ($file in $resourceFiles) { | ||
| Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $CaptureDirectory $file.Name) -Force | ||
| } | ||
| } | ||
|
|
||
| $resolvedProject = (Resolve-Path -LiteralPath $Project).Path | ||
| $msbuild = Find-MSBuild | ||
| $tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("nf-smoketest-parity-" + [Guid]::NewGuid().ToString('N')) | ||
| $null = New-Item -ItemType Directory -Path $tempRoot -Force | ||
|
|
||
| try { | ||
| $coreCapture = Join-Path $tempRoot 'net8.0' | ||
| $frameworkCapture = Join-Path $tempRoot 'net472' | ||
| $null = New-Item -ItemType Directory -Path $coreCapture -Force | ||
| $null = New-Item -ItemType Directory -Path $frameworkCapture -Force | ||
|
|
||
| Build-And-CaptureNanoResources -Toolchain dotnet -ProjectPath $resolvedProject -BuildConfiguration $Configuration -CaptureDirectory $coreCapture | ||
| Build-And-CaptureNanoResources -Toolchain msbuild -ProjectPath $resolvedProject -BuildConfiguration $Configuration -CaptureDirectory $frameworkCapture -MSBuildPath $msbuild | ||
|
|
||
| $coreFiles = Get-ChildItem -LiteralPath $coreCapture -Filter '*.nanoresources' -File | Sort-Object -Property Name | ||
| $frameworkFiles = Get-ChildItem -LiteralPath $frameworkCapture -Filter '*.nanoresources' -File | Sort-Object -Property Name | ||
|
|
||
| $coreNames = @($coreFiles.Name) | ||
| $frameworkNames = @($frameworkFiles.Name) | ||
| if (@(Compare-Object -ReferenceObject $coreNames -DifferenceObject $frameworkNames).Count -ne 0) { | ||
| throw "Parity check failed: generated .nanoresources file sets differ.`nnet8.0 : $($coreNames -join ', ')`nnet472 : $($frameworkNames -join ', ')" | ||
| } | ||
|
|
||
| $mismatches = @() | ||
| foreach ($name in $coreNames) { | ||
| $corePath = Join-Path $coreCapture $name | ||
| $frameworkPath = Join-Path $frameworkCapture $name | ||
|
|
||
| $coreHash = Get-FileHash -LiteralPath $corePath -Algorithm SHA256 | ||
| $frameworkHash = Get-FileHash -LiteralPath $frameworkPath -Algorithm SHA256 | ||
|
|
||
| Write-Host "$name" | ||
| Write-Host " net8.0: $($coreHash.Hash)" | ||
| Write-Host " net472: $($frameworkHash.Hash)" | ||
|
|
||
| if ($coreHash.Hash -ne $frameworkHash.Hash) { | ||
| $mismatches += $name | ||
| } | ||
| } | ||
|
|
||
| if ($mismatches.Count -gt 0) { | ||
| throw "Parity check failed: hash mismatch in .nanoresources files: $($mismatches -join ', ')" | ||
| } | ||
|
|
||
| Write-Host 'Parity check passed: all .nanoresources files are byte-identical for net8.0 and net472.' | ||
| } | ||
| finally { | ||
| if (Test-Path -LiteralPath $tempRoot) { | ||
| Remove-Item -LiteralPath $tempRoot -Recurse -Force | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.