Skip to content

Commit fb37e93

Browse files
Copilottomasherceg
andauthored
Delete nuget.g.props/targets before restore to force full TFM regeneration
Co-authored-by: tomasherceg <5599524+tomasherceg@users.noreply.github.com>
1 parent 85a37b8 commit fb37e93

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

.github/unittest/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ runs:
8787
# TFMs. The LintCommandLine tests invoke the CLI which runs MSBuild internally, regenerating
8888
# the NuGet Core targets for net8.0 only. Without this restore, subsequent steps that build
8989
# net472 projects (e.g. Analyzers.Tests) fail with CS0518 (missing reference assemblies).
90+
#
91+
# We must delete the *.nuget.g.props / *.nuget.g.targets files first: NuGet skips rewriting
92+
# them when project.assets.json has not changed, so a plain restore would silently leave the
93+
# corrupted single-TFM files in place.
94+
- run: Get-ChildItem src -Recurse -Include "*.nuget.g.props","*.nuget.g.targets" | Remove-Item -Force
95+
shell: pwsh
96+
if: ${{ inputs.target-framework == 'net8.0' && runner.os == 'Windows' }}
97+
- run: find src -name "*.nuget.g.props" -o -name "*.nuget.g.targets" | xargs rm -f
98+
shell: bash
99+
if: ${{ inputs.target-framework == 'net8.0' && runner.os != 'Windows' }}
90100
- run: msbuild ${{ inputs.sln }} -t:Restore
91101
shell: pwsh
92102
if: ${{ inputs.target-framework == 'net8.0' && runner.os == 'Windows' }}

0 commit comments

Comments
 (0)