Skip to content

Commit 25a743b

Browse files
committed
Prevent restore loop in VS
The `GetReferenceAssemblyPaths` target adds a `PackageReference` to `Microsoft.NETFramework.ReferenceAssemblies` when needed. In VS, this new package causes VS to nominate a NuGet restore then perform another design-time build. That second design-time build was previously determining that the `PackageReference` was no longer needed, then removing it. The task's `FullFrameworkReferenceAssemblyPaths` output parameter contains the full path of the reference assembly folder in such a case, which fails the empty-string test. This change tests whether the output parameter is a reference to the package, and if so allows the `PackageReference` to remain.
1 parent 7d7d543 commit 25a743b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,11 @@ Copyright (c) .NET Foundation. All rights reserved.
426426
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
427427
</GetReferenceAssemblyPaths>
428428

429-
430429
<ItemGroup>
431430
<_ExistingReferenceAssembliesPackageReference Include="@(PackageReference)" Condition="'%(PackageReference.Identity)' == 'Microsoft.NETFramework.ReferenceAssemblies'"/>
432431

433432
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesLatestPackageVersion)" IsImplicitlyDefined="true" PrivateAssets="All"
434-
Condition="'$(_FullFrameworkReferenceAssemblyPaths)' == '' and '@(_ExistingReferenceAssembliesPackageReference)' == ''"/>
433+
Condition="('$(_FullFrameworkReferenceAssemblyPaths)' == '' or $(_FullFrameworkReferenceAssemblyPaths.Contains('microsoft.netframework.referenceassemblies'))) and '@(_ExistingReferenceAssembliesPackageReference)' == ''"/>
435434
</ItemGroup>
436435
</Target>
437436

0 commit comments

Comments
 (0)