Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot disable Nuget warnings with dotnet 2.0 #5769

Closed
xlegalles opened this issue Aug 17, 2017 · 8 comments
Closed

Cannot disable Nuget warnings with dotnet 2.0 #5769

xlegalles opened this issue Aug 17, 2017 · 8 comments
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Functionality:Restore

Comments

@xlegalles
Copy link

Details about Problem

dotnet --info
.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Description

This is linked to what I have commented in #5764: we have hundreds of NU1603 warnings and we want to disable them in Release in order to clean-up the build server logs. But it does not work: all dotnet commands (e.g. restore or build) ignore our settings and warnings are still displayed. We also have the same behavior in VS 2017 15.3.0

Here is a sample projet setting:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath>bin\Release\</OutputPath>
    <NoWarn>NU1701;NU1702;NU1705;NU1603;CS0162</NoWarn>
</PropertyGroup>

Note that if I add/remove the CS0162 warning, it is correctly ignored/displayed.

@mishra14 mishra14 added Functionality:Restore Resolution:Duplicate This issue appears to be a Duplicate of another issue labels Aug 17, 2017
@mishra14
Copy link
Contributor

mishra14 commented Aug 17, 2017

@xlegalles Thanks for reaching out. The problem is that you are not passing the right properties to the restore command. Please use the following commands-

dotnet msbuild /t:Restore /p:Configuration=Release
dotnet msbuild /t:Build /p:Configuration=Release

or

dotnet restore /p:configuration=release
dotnet build /p:configuration=release

Please let us know if this fixes your issue. Thanks!

@mishra14 mishra14 removed the Resolution:Duplicate This issue appears to be a Duplicate of another issue label Aug 17, 2017
@xlegalles
Copy link
Author

Well, that's what we do... plus I told you that it works for the CS0162 warning. But it has absolutely no effect for NU*. And it is not only for restore: we have tons of warnings for all commands: build, publish, etc. even clean.
So here is a quick repro from a basic web application template: I just add new dependencies with Log4Net 2.08. Also note that we have a private Nuget repo which explains why it cannot find the exact dependency it looks for. I just use VS 2017 15.03 and as you can see it does not care of my suppress warning settings.
Btw, the setting 1701;1702;1705 was there by default and I suspect it is wrong: maybe because of the .NET Core preview?

1>------ Build started: Project: WebApplication2, Configuration: Debug Any CPU ------
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: WebApplication2 depends on Microsoft.ApplicationInsights.AspNetCore (>= 2.0.0) but Microsoft.ApplicationInsights.AspNetCore 2.0.0 was not found. An approximate best match of Microsoft.ApplicationInsights.AspNetCore 2.1.1 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: WebApplication2 depends on Microsoft.AspNetCore (>= 1.1.2) but Microsoft.AspNetCore 1.1.2 was not found. An approximate best match of Microsoft.AspNetCore 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: Microsoft.ApplicationInsights.AspNetCore 2.1.1 depends on Microsoft.AspNetCore.Hosting (>= 1.0.0) but Microsoft.AspNetCore.Hosting 1.0.0 was not found. An approximate best match of Microsoft.AspNetCore.Hosting 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: WebApplication2 depends on Microsoft.AspNetCore.Mvc (>= 1.1.3) but Microsoft.AspNetCore.Mvc 1.1.3 was not found. An approximate best match of Microsoft.AspNetCore.Mvc 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: WebApplication2 depends on Microsoft.AspNetCore.StaticFiles (>= 1.1.2) but Microsoft.AspNetCore.StaticFiles 1.1.2 was not found. An approximate best match of Microsoft.AspNetCore.StaticFiles 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: Microsoft.ApplicationInsights.AspNetCore 2.1.1 depends on Microsoft.Extensions.Configuration (>= 1.0.0) but Microsoft.Extensions.Configuration 1.0.0 was not found. An approximate best match of Microsoft.Extensions.Configuration 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: Microsoft.ApplicationInsights.AspNetCore 2.1.1 depends on Microsoft.Extensions.Configuration.Json (>= 1.0.0) but Microsoft.Extensions.Configuration.Json 1.0.0 was not found. An approximate best match of Microsoft.Extensions.Configuration.Json 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: Microsoft.ApplicationInsights.AspNetCore 2.1.1 depends on Microsoft.Extensions.DiagnosticAdapter (>= 1.0.0) but Microsoft.Extensions.DiagnosticAdapter 1.0.0 was not found. An approximate best match of Microsoft.Extensions.DiagnosticAdapter 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: Microsoft.ApplicationInsights.AspNetCore 2.1.1 depends on Microsoft.Extensions.Logging.Abstractions (>= 1.0.0) but Microsoft.Extensions.Logging.Abstractions 1.0.0 was not found. An approximate best match of Microsoft.Extensions.Logging.Abstractions 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: WebApplication2 depends on Microsoft.Extensions.Logging.Debug (>= 1.1.2) but Microsoft.Extensions.Logging.Debug 1.1.2 was not found. An approximate best match of Microsoft.Extensions.Logging.Debug 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: WebApplication2 depends on Microsoft.VisualStudio.Web.BrowserLink (>= 1.1.2) but Microsoft.VisualStudio.Web.BrowserLink 1.1.2 was not found. An approximate best match of Microsoft.VisualStudio.Web.BrowserLink 2.0.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: log4net 2.0.8 depends on System.Diagnostics.StackTrace (>= 4.0.1) but System.Diagnostics.StackTrace 4.0.1 was not found. An approximate best match of System.Diagnostics.StackTrace 4.3.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: log4net 2.0.8 depends on System.IO.FileSystem.Watcher (>= 4.0.0) but System.IO.FileSystem.Watcher 4.0.0 was not found. An approximate best match of System.IO.FileSystem.Watcher 4.3.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: log4net 2.0.8 depends on System.Net.NameResolution (>= 4.0.0) but System.Net.NameResolution 4.0.0 was not found. An approximate best match of System.Net.NameResolution 4.3.0 was resolved.
1>c:\users\legalles\source\repos\WebApplication2\WebApplication2\WebApplication2.csproj : warning NU1603: log4net 2.0.8 depends on System.Net.Requests (>= 4.0.11) but System.Net.Requests 4.0.11 was not found. An approximate best match of System.Net.Requests 4.3.0 was resolved.
1>WebApplication2 -> C:\Users\legalles\source\repos\WebApplication2\WebApplication2\bin\Debug\netcoreapp2.0\WebApplication2.dll
1>Done building project "WebApplication2.csproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

capture

WebApplication2.zip

@mishra14
Copy link
Contributor

@xlegalles Thanks for the detailed response.

  1. The project that you sent me has a condition on Configuration=Debug. So in that case you cannot turn them off for release.
  2. Take a look at the following project -
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <NoWarn>1701;1702;1705;NU1603;NU1605</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="log4net" Version="2.0.8" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
    <PackageReference Include="System.Reflection.Metadata" Version="1.5.0" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
  </ItemGroup>

</Project>

F:\validation\test\test> dotnet --info
.NET Command Line Tools (2.0.0-preview2-006479)

Product Information:
 Version:            2.0.0-preview2-006479
 Commit SHA-1 hash:  5616284dd7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0-preview2-006479\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview2-25407-01
  Build    : 40c565230930ead58a50719c0ec799df77bddee9
F:\validation\test\test> rm -r .\obj\*; dotnet restore /p:configuration=release
  Restoring packages for F:\validation\test\test\test.csproj...
  Restore completed in 54.56 ms for F:\validation\test\test\test.csproj.
  Generating MSBuild file F:\validation\test\test\obj\test.csproj.nuget.g.props.
  Generating MSBuild file F:\validation\test\test\obj\test.csproj.nuget.g.targets.
  Restore completed in 1.37 sec for F:\validation\test\test\test.csproj.
F:\validation\test\test>

I had to make 2 changes i.e.

  1. change the configuration to release on the property group condition
  2. add NU1605 to the nowarn list as I was getting some of those too.

Can you try this csproj and send me the output?

@rrelyea rrelyea added Area:ErrorHandling warnings and errors/log messages & related error codes. Viewed labels Aug 21, 2017
@Sumo-MBryant
Copy link

According to the blog post here: https://blog.nuget.org/20170815/Whats-nu-in-NuGet-with-VS2017-15-3.html#msbuild-integration-of-nuget-warnings-and-errors

Suppress the warning in the project on a PackageReference basis

To suppress the warning, you can go to the package properties window and add NU1701 to the NoWarn property:

This results in the following entry being created in the project file:

<PackageReference Include="RestSharp" Version="105.2.3">
  <NoWarn>NU1701</NoWarn>
</PackageReference>

However trying restore the following project reports a warning:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NEST" Version="2.4.1">
      <NoWarn>NU1603</NoWarn>
    </PackageReference>
  </ItemGroup>
</Project>
$ dotnet --info
.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9
$ dotnet restore Test.csproj
  Restoring packages for C:\Prog\Test.csproj...
  Restore completed in 33.74 ms for C:\Prog\Test.csproj.
C:\Prog\Test.csproj : warning NU1603: NEST 2.4.1 depends on
Newtonsoft.Json (>= 9.0.0 && < 10.0.0) but Newtonsoft.Json 9.0.0 was not found.
An approximate best match of Newtonsoft.Json 9.0.1 was resolved.
  Restore completed in 1.09 sec for C:\Prog\Test.csproj.

Changing the project thusly does however appear to work:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
    <NoWarn>NU1603</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NEST" Version="2.4.1" />
  </ItemGroup>
</Project>
$ dotnet restore Test.csproj
  Restoring packages for C:\Prog\CoreTech\SumoServer\Test.csproj...
  Restore completed in 33.93 ms for C:\Prog\CoreTech\SumoServer\Test.csproj.
  Restore completed in 11.06 sec for C:\Prog\CoreTech\SumoServer\Test.csproj.

Does this imply that package reference based warning suppression isn't working?

@mishra14
Copy link
Contributor

mishra14 commented Aug 23, 2017

@Sumo-MBryant : Thanks for the details in your comment.

The problem here is that the issue occurs not for NEST but for Newtonsoft.Json, hence the Package Specific NoWarn does not work.

To be sure, take a look at the assets file in the project/obj directory. At the bottom, you will see that the error is for newtonsoft -

  "logs": [
    {
      "code": "NU1603",
      "level": "Warning",
      "warningLevel": 1,
      "message": "NEST 2.4.1 depends on Newtonsoft.Json (>= 9.0.0 && < 10.0.0) but Newtonsoft.Json 9.0.0 was not found. An approximate best match of Newtonsoft.Json 9.0.1 was resolved.",
      "libraryId": "Newtonsoft.Json",
      "targetGraphs": [
        ".NETStandard,Version=v1.6"
      ]
    }

I hope this clarifies the case here. Please let us know if you need any more help!

@mishra14
Copy link
Contributor

mishra14 commented Sep 7, 2017

@xlegalles @Sumo-MBryant I am closing this bug as there is no new issue here.

I have another related issue at - #5712.

Please let me know if you feel this issue needs more attention.

@mishra14 mishra14 closed this as completed Sep 7, 2017
@xlegalles
Copy link
Author

Well, if you think both bugs are linked, I'm ok. But it is still really annoying to have so many warnings.

@mishra14
Copy link
Contributor

mishra14 commented Sep 8, 2017

@xlegalles I agree. Ideally you should address and resolve the warnings. But sometimes it is not possible. Hence for restore you should be able to NoWarn them. If that is not working for you then let me know and I will work with you to understand/fix the problem there.

We do not have the support for NoWarn for the other commands yet. If you feel that is something you need then please let us know and we will discuss the feasibility for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Functionality:Restore
Projects
None yet
Development

No branches or pull requests

4 participants