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

Framework Conditioned warning properties are not respected for multi-targeting projects #5712

Open
anangaur opened this issue Aug 4, 2017 · 8 comments
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Status:Excluded from icebox cleanup Status:Inactive Icebox issues not updated for a specific long time
Milestone

Comments

@anangaur
Copy link
Member

anangaur commented Aug 4, 2017

From: https://developercommunity.visualstudio.com/content/problem/88109/cannot-suppress-nu1701-from-project-properties.html

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: Duplicate NU1701 warnings when multi-targetting to netcoreapp2.0 and net461 dotnet/sdk#1474
  5. Suppress warning NU1701 from Project->Properties->Build->Suppress Warnings
  6. Rebuild

Expected:Warnings should disappear
Actual: Warnings still show up:

image

Looking at the asset file, the warning is persisted:
image

Edit by @nkolev92; repro below

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

  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.2;netcoreapp2.1</TargetFrameworks>
    <NoWarn Condition="'$(TargetFramework)' == 'netcoreapp2.2'">NU1701</NoWarn>
    <AssetTargetFallback>net46</AssetTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NuGet.Credentials" Version="4.6.2" />
  </ItemGroup>

</Project>
@emgarten emgarten added this to the 4.4 milestone Aug 4, 2017
@emgarten
Copy link
Member

emgarten commented Aug 4, 2017

A restore is needed to update the suppressions, a rebuild should have done that however. @mishra14 would you try this out?

@mishra14
Copy link
Contributor

mishra14 commented Aug 4, 2017

@emgarten @anangaur and I discussed this.

It seems that we do not get the NoWarn property from msbuild. Possibly because the property is added with multiple conditions that @anangaur will post here.

@anangaur
Copy link
Member Author

anangaur commented Aug 4, 2017

The csproj file reads like the following:

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

Issues:

  1. This should not add warnings under conditions: Suppressing a NuGet warning in malti-target project should not add conditions to the warnings' suppression microsoft/VSProjectSystem#241

  2. [This bug] Even with the current conditions, the warnings should be suppressed but it is not.

@rrelyea
Copy link
Contributor

rrelyea commented Aug 7, 2017

@mishra14 - if this is external, please use a label, not just zenhub. can you please look at @anangaur second point and determine how many fixes are necessary, and if this should be one of them.

@rrelyea rrelyea changed the title Warnings do not get suppressed when progect targets multiple frameworks Warnings do not get suppressed when project targets multiple frameworks Aug 7, 2017
@mishra14 mishra14 modified the milestones: 4.4 - 7/31 through 8/18, 4.4 Aug 7, 2017
@mishra14
Copy link
Contributor

mishra14 commented Aug 7, 2017

The reason is that we do not pass conditions to msbuild when requesting properties. I will see if it is possible to get this done as part of #5501

@mishra14 mishra14 changed the title Warnings do not get suppressed when project targets multiple frameworks Conditioned warning properties are not respected Aug 9, 2017
@mishra14
Copy link
Contributor

Update -

I looked more into this and this is a VS only problem. Since, in dotnet restore and msbuild /t:restore calls we can pass in additional properties.

@mishra14 mishra14 added Priority:2 Issues for the current backlog. Product:VS.Client and removed Priority:2 Issues for the current backlog. Triage:Investigate labels Sep 1, 2017
@mishra14 mishra14 removed their assignment Sep 1, 2017
@mishra14 mishra14 added the Area:ErrorHandling warnings and errors/log messages & related error codes. label Sep 7, 2017
@mishra14 mishra14 self-assigned this Sep 7, 2017
@mishra14
Copy link
Contributor

mishra14 commented Sep 7, 2017

Looked more into this -

The core issue is that in multi-targeting projects, the project system adds a condition on the first tfm of the project. I have filed an issue with them - dotnet/project-system#2804

I will wait for their response/traction.

@mishra14 mishra14 modified the milestones: Backlog, 4.4 Sep 7, 2017
@mishra14 mishra14 added the Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. label Sep 7, 2017
@mishra14 mishra14 changed the title Conditioned warning properties are not respected Framework Conditioned warning properties are not respected for multi-targeting projects Sep 7, 2017
@nkolev92
Copy link
Member

nkolev92 commented Jun 6, 2019

Just to clarify the status here;

#5712 (comment)

Framework conditioned no warns are not supported in either CLI or VS.

Repro that shows this:

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

  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.2;netcoreapp2.1</TargetFrameworks>
    <NoWarn Condition="'$(TargetFramework)' == 'netcoreapp2.2'">NU1701</NoWarn>
    <AssetTargetFallback>net46</AssetTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NuGet.Credentials" Version="4.6.2" />
  </ItemGroup>

</Project>

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 Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Status:Excluded from icebox cleanup Status:Inactive Icebox issues not updated for a specific long time
Projects
None yet
Development

No branches or pull requests

7 participants