mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
update
This commit is contained in:
@@ -278,5 +278,45 @@ Get-ChildItem -Path $rootPath -Recurse "packages.config" | ForEach-Object {
|
||||
}
|
||||
}
|
||||
|
||||
# Update .vcxproj files with hardcoded package paths
|
||||
Get-ChildItem -Path $rootPath -Recurse "*.vcxproj" | ForEach-Object {
|
||||
$file = Read-FileWithEncoding -Path $_.FullName
|
||||
$content = $file.Content
|
||||
$isModified = $false
|
||||
|
||||
foreach ($pkgId in $packageVersions.Keys) {
|
||||
$ver = $packageVersions[$pkgId]
|
||||
# Escape dots in package ID for regex
|
||||
$pkgIdRegex = $pkgId -replace '\.', '\.'
|
||||
|
||||
# Look for properties like <WasdkNuget>...packages\Microsoft.WindowsAppSDK.1.2.3...</WasdkNuget>
|
||||
# Regex to match: >...packages\PackageId.OldVersion<
|
||||
# We want to replace OldVersion with NewVersion
|
||||
|
||||
# Pattern: matches "packages\PackageId.Version" inside a tag value
|
||||
# We use a lookbehind for "packages\" and PackageId, then match the version
|
||||
$pattern = "(?<=packages\\$pkgIdRegex\.)([\d\.]+[-a-zA-Z0-9]*)(?=<)"
|
||||
|
||||
if ($content -match $pattern) {
|
||||
$currentVersionInFile = $Matches[0]
|
||||
if ($currentVersionInFile -ne $ver) {
|
||||
# Replace all occurrences of this specific package version path
|
||||
# We construct a specific regex for replacement to be safe
|
||||
$specificPattern = "packages\\$pkgIdRegex\.$([regex]::Escape($currentVersionInFile))"
|
||||
$replacement = "packages\$pkgId.$ver"
|
||||
|
||||
$content = $content -replace $specificPattern, $replacement
|
||||
$isModified = $true
|
||||
Write-Host "Updating $pkgId in $($_.Name): $currentVersionInFile -> $ver"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($isModified) {
|
||||
Write-FileWithEncoding -Path $_.FullName -Content $content -Encoding $file.encoding
|
||||
Write-Host "Modified " $_.FullName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user