diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 5bdeba6..1598638 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -29,4 +29,43 @@ jobs: - name: Publish NuGet run: dotnet nuget push src\bin\${{ matrix.version }}\*.nupkg -k ${{secrets.NUGETKEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate + + - name: Delete old packages + shell: pwsh + run: | + # 获取包名称 + $packageId = "Tuna.Revit.Extension" + # 保留最新的N个版本 + $versionsToKeep = 10 + + # 获取包的详细信息 + $baseUrl = "https://api.nuget.org/v3/registration5-semver1/$packageId/index.json" + $response = Invoke-RestMethod -Uri $baseUrl + + # 获取所有版本及其发布时间 + $versionDetails = @() + foreach ($item in $response.items) { + foreach ($entry in $item.items) { + $versionDetails += @{ + Version = $entry.catalogEntry.version + Published = [DateTime]::Parse($entry.catalogEntry.published) + } + } + } + + # 按发布时间排序并选择要删除的版本 + $versionsToDelete = $versionDetails | + Sort-Object Published -Descending | + Select-Object -Skip $versionsToKeep | + Select-Object -ExpandProperty Version + + foreach ($version in $versionsToDelete) { + Write-Host "Deleting version $version of $packageId (Published: $($versionDetails | Where-Object Version -eq $version | Select-Object -ExpandProperty Published))" + # 删除包版本 + Invoke-RestMethod -Uri "https://api.nuget.org/v3/packages/$packageId/$version" ` + -Method Delete ` + -Headers @{ + 'X-NuGet-ApiKey' = '${{secrets.NUGETKEY}}' + } + } diff --git a/src/Geometry/TransientElementExtensions.cs b/src/Geometry/TransientElementExtensions.cs index 4fc5981..16b66c0 100644 --- a/src/Geometry/TransientElementExtensions.cs +++ b/src/Geometry/TransientElementExtensions.cs @@ -93,13 +93,14 @@ public static void CleanTransientElements(this Document document) document.NewTransaction(() => { - foreach (var elementId in _transientElementIds) + for (int i = _transientElementIds.Count - 1; i >= 0; i--) { - Element element = document.GetElement(elementId); + ElementId currentId = _transientElementIds[i]; + Element element = document.GetElement(currentId); if (element != null) { - document.Delete(elementId); - _transientElementIds.Remove(elementId); + document.Delete(currentId); + _transientElementIds.Remove(currentId); } } }); diff --git a/src/Selection/SelectionChangedEventArgs.cs b/src/Selection/SelectionChangedEventArgs.cs index 24cfc6a..e23e117 100644 --- a/src/Selection/SelectionChangedEventArgs.cs +++ b/src/Selection/SelectionChangedEventArgs.cs @@ -24,15 +24,15 @@ internal SelectionChangedEventArgs(Autodesk.Revit.UI.Events.SelectionChangedEven /// /// 发生选择变更的文档 /// - public Document Document { get; } + public Document? Document { get; } /// /// 被选择的图元 /// - public IEnumerable Elements { get; } + public IEnumerable? Elements { get; } /// /// 被选择的引用 /// - public IEnumerable References { get; } + public IEnumerable? References { get; } } diff --git a/src/Tuna.Revit.Extension.csproj b/src/Tuna.Revit.Extension.csproj index ad1300c..5d21aa3 100644 --- a/src/Tuna.Revit.Extension.csproj +++ b/src/Tuna.Revit.Extension.csproj @@ -29,7 +29,7 @@ Rvt_24_Debug;Rvt_24_Release; Rvt_25_Debug;Rvt_25_Release; - 19 + 19.1 x64 preview enable