revising remove duplicate

This commit is contained in:
Hongtao Zhang 2024-03-26 17:38:29 -05:00
parent bdad186f08
commit 8c19ed7732
2 changed files with 34 additions and 4 deletions

View file

@ -50,7 +50,9 @@ jobs:
with:
dotnet-version: 7.0.x
- name: Install vpk
run: dotnet tool update -g vpk
# Install vpk tool (dotnet tool install will not reinstall if already installed)
# We will update the cli by removing cache
run: dotnet tool install -g vpk
- name: Restore dependencies
run: dotnet restore
- name: Build

View file

@ -49,11 +49,39 @@ function Delete-Unused($path, $config)
{
$target = "$path\Output\$config"
$included = Get-ChildItem $target -Filter "*.dll"
$hashset = @{ }
foreach ($i in $included)
{
$deleteList = Get-ChildItem $target\Plugins -Include $i -Recurse | Where { $_.VersionInfo.FileVersion -eq $i.VersionInfo.FileVersion -And $_.Name -eq "$i" }
$deleteList | ForEach-Object{ Write-Host Deleting duplicated $_.Name with version $_.VersionInfo.FileVersion at location $_.Directory.FullName }
$deleteList | Remove-Item
$item = if ($i.VersionInfo.FileVersion -eq $null)
{
[ValueTuple]::Create($i.Name, "")
}
else
{
[ValueTuple]::Create($i.Name, $i.VersionInfo.FileVersion)
}
$key = $hashset.Add($item, $true)
}
$deleteList = Get-ChildItem $target\Plugins -Filter *.dll -Recurse | Where {
$item = if ($_.VersionInfo.FileVersion -eq $null)
{
[ValueTuple]::Create($_.Name, "")
}
else
{
[ValueTuple]::Create($_.Name, $_.VersionInfo.FileVersion)
}
$hashset.ContainsKey($item)
}
foreach ($i in $deleteList)
{
Write-Host "Deleting duplicated $i.Name with version $i.VersionInfo.FileVersion at location $i.Directory.FullName"
Remove-Item $i
}
Remove-Item -Path $target -Include "*.xml" -Recurse
}