project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Suppressing warnings through project properties UI adds tfm condition in csproj file for multi targeting project

Open mishra14 opened this issue 8 years ago • 12 comments

Repro steps:

  1. Create a new NetCore 2.0 Console App
  2. Multi-target to netcoreapp2.0;net461: <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
  3. Add a NuGet reference to a net 461 compat package like RestSharp
  4. Build -> Show 2 warnings which seems to be another bug: https://github.com/dotnet/sdk/issues/1474
  5. Suppress warning NU1701 from Project->Properties->Build->Suppress Warnings
  6. Edit the csproj file -
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.0|AnyCPU'">
    <NoWarn>1701;1702;1705;NU1701</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="RestSharp" Version="105.2.3" />
  </ItemGroup>

</Project>

The issue here is that the user did not select netcoreapp2.0 while suppressing the warning but the csproj has netcoreapp2.0 in the condition.

Other Info:

if you try the same steps in a project that does not multi-target then the condition is fine -

<Project Sdk="Microsoft.NET.Sdk">

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

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

  <ItemGroup>
    <PackageReference Include="RestSharp" Version="105.2.3" />
  </ItemGroup>

</Project>

VS Version: 15.4.0 Preview 2 | d15rel/16828.0

cc: @natidea @emgarten

mishra14 avatar Sep 07 '17 23:09 mishra14

We need to design how this is going to work - whether we add a TFM switcher these pages, or we just make sure we don't persist it when we write the condition out.

davkean avatar Sep 12 '17 00:09 davkean

IMO, the ideal solution would be the first one that means implementing the TFM switcher with the default to all/any TFM. This should be followed by any NuGet work required. @emgarten, @mishra14 is there any follow up work required on NuGet side with approach?

I also see this is marked for 15.6. Can this be considered for 15.5? I am okay with either approach - whichever is faster.

anangaur avatar Sep 12 '17 06:09 anangaur

We're not going to be able to fit this in for 15.5. Does NuGet respect suppressing warnings per TFM?

davkean avatar Sep 12 '17 06:09 davkean

I am not positive. @mishra14 can confirm. If not, how difficult is it to remove TFM filter for NuGet warning suppression (2nd option)? For 15.5?

anangaur avatar Sep 12 '17 07:09 anangaur

It needs investigation - we don't own that code. It lives in CPS and we'll need to add an extension point to override the behavior,

davkean avatar Sep 12 '17 07:09 davkean

NuGet currently considers the project wide warning properties to be framework independent. This can be changed if needed. But we need to consider if having no warn or warn as error per framework, make sense from a user point of view.

It would be great to have the framework condition removed as the first step!

mishra14 avatar Sep 13 '17 21:09 mishra14

@davkean, Is this on track for 15.6?

anangaur avatar Nov 09 '17 18:11 anangaur

No, given current priorities this is not on track for 15.6. @Pilchie When are we moving bugs to the "holding" pen that Matt was talking about?

davkean avatar Nov 09 '17 23:11 davkean

Hopefully next week I'll get our 15.6 bugs sorted out.

Pilchie avatar Nov 10 '17 01:11 Pilchie

sigh A bit longer than a week...

Pilchie avatar Dec 22 '17 20:12 Pilchie

Any idea then some progress could happens ?

kant2002 avatar Jan 22 '18 04:01 kant2002

Bump? This is blocking the ability to suppress warnings per specific TFM in multi-targeting projects.

clairernovotny avatar Aug 07 '18 15:08 clairernovotny