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

Suppress compilation warnings CS1701, CS1702, and CS1705 #3337

Closed
2 tasks done
augustoproiete opened this issue May 7, 2021 · 1 comment · Fixed by #3338
Closed
2 tasks done

Suppress compilation warnings CS1701, CS1702, and CS1705 #3337

augustoproiete opened this issue May 7, 2021 · 1 comment · Fixed by #3338
Assignees
Milestone

Comments

@augustoproiete
Copy link
Member

augustoproiete commented May 7, 2021

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool, Cake Frosting, Cake runner for .NET Framework, Cake runner for .NET Core

Cake version

1.1.0

Operating system

N/A

Operating system architecture

N/A

CI Server

N/A

What are you seeing?

When Cake addins reference assemblies that have already been loaded by Cake, and the version loaded in the assembly load context doesn't match the version targeted by the Cake addin, the user sees a warning written to the Console (even with the default Verbosity).

For example, using the latest version (as of this writing) of the Cake.ExtendedNuGet addin (v4.0.2) with the latest version of Cake (v1.1.0) produces the following warning:

(3145,12): warning CS1701: Assuming assembly reference 'NuGet.Versioning, Version=5.4.0.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35' used by 'Cake.ExtendedNuGet' matches identity 'NuGet.Versioning, Version=5.8.1.7021, Culture=neutral, PublicKeyToken=31bf3856ad364e35' of 'NuGet.Versioning', you may need to supply runtime policy

This happens because Cake references a newer version of the NuGet packages (v5.8.1) whilst the latest version of the Cake.ExtendedNuGet addin references an older version of NuGet (v5.4.0) which is still compatible, but different. More details described in cake-contrib/Cake.ExtendedNuGet#35 (comment)

What is expected?

These warnings should be suppressed given that they provide little value to the Cake user (i.e. NuGet upgrades are a common scenario when loading transitive dependencies) and there's nothing that the user can do about it other than ignoring the "noise".

There seems to be general agreement in the .NET community and within Microsoft that these warnings should be suppressed by default and potentially completely removed (1).

These warnings have had to be disabled in project templates for a long time. Searching for "NoWarn" 1701 on GitHub at the moment yields over 500K results: https://github.com/search?q=NoWarn+1701&type=Code&utf8=%E2%9C%93

I propose suppressing the warnings CS1701, CS1702 and CS1705 completely, or at the very least, changing its severity so that it only appears when running Cake with Diagnostic verbosity.

Steps to Reproduce

  1. Add the following to a build.cake file:
#addin nuget:?package=Cake.ExtendedNuGet&version=4.0.2
  1. Run dotnet cake

Output log

No response

@augustoproiete augustoproiete added this to the v1.x Next Candidate milestone May 7, 2021
@augustoproiete augustoproiete self-assigned this May 7, 2021
@augustoproiete augustoproiete changed the title Suppress compilation warnings CS1701 and CS1702 Suppress compilation warnings CS1701, CS1702, and CS1705 May 7, 2021
augustoproiete added a commit to augustoproiete-forks/cake-build--cake that referenced this issue May 7, 2021
augustoproiete added a commit to augustoproiete-forks/cake-build--cake that referenced this issue May 7, 2021
augustoproiete added a commit to augustoproiete-forks/cake-build--cake that referenced this issue May 8, 2021
@gep13 gep13 modified the milestones: v1.x Next Candidate, v1.2.0 May 9, 2021
@cake-build-bot
Copy link

🎉 This issue has been resolved in version v1.2.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants