Improve NuGet Dependency Version Validation via dotnet restore (#40646)

### NuGet Package Management Improvements:
* This pull request includes updates to improve NuGet package management
and dependency versions.

### Example problem of the new ps1 change, and fixed in this PR
Updated the version of `NLog` from `5.0.4` to `5.2.8`, with the error
message:
error NU1605:
Warning As Error: Detected package downgrade: NLog from 5.2.8 to 5.0.4.
Reference the package directly from the pr
      oject to select a different version.
Microsoft.PowerToys.Run.Plugin.History -> Wox.Plugin ->
NLog.Extensions.Logging 5.3.8 -> NLog (>= 5.2.8)
Microsoft.PowerToys.Run.Plugin.History -> Wox.Plugin -> NLog (>= 5.0.4)
This commit is contained in:
Gordon Lam 2025-08-21 03:07:14 -07:00 committed by GitHub
parent e0a0bbffe5
commit 2db1dcd10c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 1 deletions

View File

@ -1118,6 +1118,7 @@ NOTSRCCOPY
NOTSRCERASE NOTSRCERASE
notwindows notwindows
NOTXORPEN NOTXORPEN
nowarn
NOZORDER NOZORDER
NPH NPH
npmjs npmjs

View File

@ -21,4 +21,13 @@ if (-not $?)
exit 1 exit 1
} }
# Ignore NU1503 on vcxproj files
dotnet restore $solution /nowarn:NU1503
if ($lastExitCode -ne 0)
{
$result = $lastExitCode
Write-Error "Error running dotnet restore, with the exit code $lastExitCode. Please verify logs on the nuget package versions."
exit $result
}
exit 0 exit 0

View File

@ -65,7 +65,8 @@
<!-- Moq to stay below v4.20 due to behavior change. need to be sure fixed --> <!-- Moq to stay below v4.20 due to behavior change. need to be sure fixed -->
<PackageVersion Include="Moq" Version="4.18.4" /> <PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="MSTest" Version="3.8.3" /> <PackageVersion Include="MSTest" Version="3.8.3" />
<PackageVersion Include="NLog" Version="5.0.4" /> <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NLog" Version="5.2.8" />
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.8" /> <PackageVersion Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageVersion Include="NLog.Schema" Version="5.2.8" /> <PackageVersion Include="NLog.Schema" Version="5.2.8" />
<PackageVersion Include="OpenAI" Version="2.0.0" /> <PackageVersion Include="OpenAI" Version="2.0.0" />

View File

@ -1522,6 +1522,7 @@ SOFTWARE.
- ModernWpfUI - ModernWpfUI
- Moq - Moq
- MSTest - MSTest
- NLog
- NLog.Extensions.Logging - NLog.Extensions.Logging
- NLog.Schema - NLog.Schema
- OpenAI - OpenAI

View File

@ -30,6 +30,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="NLog" />
<PackageReference Include="NLog.Extensions.Logging" /> <PackageReference Include="NLog.Extensions.Logging" />
<!-- HACK: Microsoft.Extensions.Hosting is referenced, even if it is not used, to force dll versions to be the same as in other projects. Really only needed since OneNote uses the LazyCache and NLog dependencies, which references older assemblies. --> <!-- HACK: Microsoft.Extensions.Hosting is referenced, even if it is not used, to force dll versions to be the same as in other projects. Really only needed since OneNote uses the LazyCache and NLog dependencies, which references older assemblies. -->
<PackageReference Include="Microsoft.Extensions.Hosting" /> <PackageReference Include="Microsoft.Extensions.Hosting" />