Skip to content

NU1701 Warning Not Suppressed by NoWarn="NU1701" on PackageReference (dotnet restore / build) #14756

Closed
NuGet/NuGet.Client
#7155

Description

@mk-ghb

NuGet Product Used

dotnet.exe

Product Version

.NET SDK: Version: 10.0.103 Commit: c2435c3e0f Workload version: 10.0.100-manifests.c992be6d MSBuild version: 18.0.11+c2435c3e0

Worked before?

No response

Impact

It bothers me. A fix would be nice

Repro Steps & Context

Describe the bug

The NU1701 warning is emitted during dotnet restore and dotnet build even when the corresponding PackageReference specifies NoWarn="NU1701".

To Reproduce

  1. Create or open an SDK-style .NET WPF project.
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
	
</Project>

2.Add a PackageReference that produces NU1701 with suppression.

<ItemGroup>
	<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" NoWarn="NU1701" />
</ItemGroup>
  1. Run dotnet restore.

Expected behavior

Restored D:\source\repos\WpfApp1\WpfApp1.csproj.
NuGet package restore finished.

Actual behavior

Restore succeeded with 1 warning(s) in 0.4s
D:\source\repos\WpfApp1\WpfApp1.csproj : warning NU1701: Package 'MicrosoftOfficeCore 15.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0-windows7.0'. This package may not be fully compatible with your project.

Further technical details

details of dotnet --info

.NET SDK: Version: 10.0.103 Commit: c2435c3e0f Workload version: 10.0.100-manifests.c992be6d MSBuild version: 18.0.11+c2435c3e0

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.103\

  • IDE VS 2026 18.3.0

dotnet/sdk#52977

Verbose Logs

Activity

  1. kartheekp-ms commented on Feb 12, 2026

    @kartheekp-ms
    Contributor

    I am unable to reproduce the issue following the steps mentioned in the issue description both in dotnet restore and VS 2026.

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net10.0-windows</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <UseWPF>true</UseWPF>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" NoWarn="NU1701" />
      </ItemGroup>
    </Project>

    Added global.json to pin the .NET SDK version mentioned in the issue description.

    {
      "sdk": {
        "version": "10.0.103"
      }
    }

    dotnet restore raises NU1701 warning when the package reference doesn't have NoWarn attribute.

    PS Q:\source\WpfApp1> dotnet restore
    Restore succeeded with 1 warning(s) in 1.0s
        Q:\source\WpfApp1\WpfApp1\WpfApp1.csproj : warning NU1701: Package 'MicrosoftOfficeCore 15.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net10.0-windows7.0'. This package may not be fully compatible with your project.
    
    Build succeeded with 1 warning(s) in 1.1s
    

    dotnet restore doesn't raise NU1701 warning when the package reference has NoWarn attribute.

    PS Q:\source\WpfApp1> dotnet restore
    Restore complete (1.0s)
    
    Build succeeded in 1.1s
    

    @mk-ghb please let me know if I am missing anything in the repro steps.

  2. added
    WaitingForCustomer
    and removed on Feb 12, 2026
  3. mk-ghb commented on Feb 12, 2026

    @mk-ghb
    Author

    I've added global.json as suggested and discovered an interesting inconsistency. After cleaning the bin and obj directories, the warning behavior varies depending on which restore tool is used first:

    • If VS 18.3.0 or msbuild -restore is run first: The NU1701 warning appears, and persists even when subsequently running dotnet restore

    • If dotnet restore is run first: No warning is present

  4. added
    WaitingForClientTeam
    and removed
    WaitingForCustomer
    on Feb 12, 2026
  5. cmconti commented on Feb 12, 2026

    @cmconti

    I'm seeing the same thing with using msbuild to restore.

    It was working with VS 18.2.1 and started failing after updating to 18.3.0

    Note: I can not reproduce (yet) with a sample project, but it happens every time with my larger multi-solution, multi-project code base...

    I can provide a verbose msbuild log if needed (or other logging), but I cannot post it publicly here...

  6. kartheekp-ms commented on Feb 13, 2026

    @kartheekp-ms
    Contributor

    I am able to reproduce this issue in VS 18.3/18.4 where as dotnet restore does not raise this warning.

    Image
  7. removed
    WaitingForClientTeam
    on Feb 13, 2026
  8. added
    WaitingForCustomer
    on Feb 13, 2026
  9. 9 remaining items

  10. nkolev92 commented on Feb 19, 2026

    @nkolev92
    Member

    Hey folks, thank for reporting this and sorry for the issue you're experiencing.

    I have a fix in flight in NuGet/NuGet.Client#7153.

    In the meantime, as a workaround you could specify the fully qualified name of the framework in the TargetFramework string.

    So:

        <TargetFramework>net10.0-windows</TargetFramework>

    fails,

    but the following should work

        <TargetFramework>net10.0-windows7.0</TargetFramework>
  11. nkolev92 commented on Feb 27, 2026

    @nkolev92
    Member

    Hey all,

    Thanks for your patience.
    Quick recap:

    The fix will be released in:

    Visual Studio & MSBuild 18.4
    .NET SDK 10.0.300

    Both of those should be happening 2nd week of March.

    Workarounds:

    Option 1: #14756 (comment)
    Option 2: Use project level suppressions.

  12. modified the milestones: 7.5, 7.3 on Mar 6, 2026
  13. ToreDemant commented on Mar 11, 2026

    @ToreDemant

    I believe that we have hit this issue when updating from VS 18.3.0 to 18.4.0 which also updates sdk from 10.0.103 to 10.0.200. We see the issue when using dot net build.

  14. nkolev92 commented on Mar 11, 2026

    @nkolev92
    Member

    @ToreDemant

    dotnet/dotnet#5021

    The fix is merged, but seems like it's not part of the 10.0.200 build.

    I'm trying to figure out when 10.0.201 ships.
    Sorry about that.

  15. modified the milestones: 7.5, 7.3, 7.4 on Mar 11, 2026
  16. nkolev92 commented on Mar 12, 2026

    @nkolev92
    Member

    Hey @ToreDemant

    This fix will be in 10.0.202 and it is scheduled for April.
    Apologies for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Functionality:RestorePriority:1Product:dotnet.exeRegressionFromPreviousRTMStyle:PackageReferenceType:Bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions