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

Support NoWarn as MSBuildWarningsAsMessages #4421

Closed
nguerrera opened this issue Jun 4, 2019 · 13 comments · Fixed by #5671
Closed

Support NoWarn as MSBuildWarningsAsMessages #4421

nguerrera opened this issue Jun 4, 2019 · 13 comments · Fixed by #5671
Assignees
Labels
For consideration Used for items on the backlog to raise them to the top of that list for discussion Partner request triaged
Milestone

Comments

@nguerrera
Copy link
Contributor

nguerrera commented Jun 4, 2019

Currently, it is not very discoverable how to disable a warning that comes from an sdk target or wherever else that is not one of the fixed components that read $(NoWarn) and police themselves, which includes NuGet and csc, but not sdk targets.

The nice thing about NoWarn is that it has project property page UI ready to go.

And even once you find MSBuildWarningsAsMessages, it's quite a mouthful and requires explaining a technicality when teaching: that it will still be logged as a low importance message. NoWarn really conveys the user intent much better.

cc @dsplaisted @rainersigwald

@rainersigwald
Copy link
Member

My only concern with this is it's a potentially confusing change in behavior for users: if they were using NoWarn on things that didn't opt into it, those warnings would now disappear. That's not unreasonable, but is it worth the change?

@nguerrera
Copy link
Contributor Author

I'm not sure I understand. Why would they be doing that?

@rainersigwald
Copy link
Member

It would have been a harmless "error" of misunderstanding: at some point, someone tried to silence a warning. It didn't work, but they left it in. Now it would be silenced, which I think is a breaking (but admittedly not that breaking) change from current behavior.

@nguerrera
Copy link
Contributor Author

I see. Maybe we save this for 17? It is technically breaking.

@jeffkl
Copy link
Contributor

jeffkl commented Jun 5, 2019

One issue is that NoWarn supports just the integers but MSBuildWarningsAsMessages treats everything as a string. Not that this couldn't be changed but that's how its currently implemented. So for instance /p:NoWarn=123 would not suppress a warning like MSB123. Another reason we didn't use NoWarn was because we wanted suppression and elevation of warnings. Is there a property like NoWarn to indicate which warnings should be errors?

@dsplaisted
Copy link
Member

We talked about this and decided we should try to do this for the next major version. Mainly because NoWarn currently works for NuGet warnings as well as compiler warnings, so it is weird that MSBuild warnings are the odd one out.

@zivkan
Copy link
Member

zivkan commented Jan 13, 2020

From our meeting today, I'd like to ask for this issue to be extended to all related warning/error properties such as WarnAsError and WarnNotAsError.

From the original email:

My understanding is that currently each component (NuGet and Roslyn/compilers at least) are responsible for their own WarnAsError implementation. NuGet has a bug in our pack task, so while WarnAsErrors are reported as errors, the task does not return a failed status, so people’s CI builds are not failing despite the logs showing an error. Plus, no NuGet task support WarnNotAsError. I was wondering if it would be worthwhile for msbuild to provide functionality around elevating warnings to errors to minimise code duplication and to minimise risk that bugs happen.

@sbomer
Copy link
Member

sbomer commented Apr 1, 2020

@rainersigwald @dsplaisted is this planned for the next release? We are hoping to rely on it for disabling linker warnings.

@sbomer
Copy link
Member

sbomer commented Jul 13, 2020

Just FYI, we have added a --nowarn flag to the linker, so we aren't relying on this for NoWarn. It would still be great to have WarnAsError flow to MSBuildWarningsAsErrors - though we might also need to add our own option to work around #5511.

Forgind added a commit to Forgind/msbuild that referenced this issue Aug 21, 2020
Fixes dotnet#4421

Currently not behind a warning wave, so will have to update that when it's available.
@Forgind Forgind self-assigned this Aug 24, 2020
@marcpopMSFT marcpopMSFT modified the milestones: MSBuild 16.8, MSBuild 16.9 Sep 4, 2020
Forgind added a commit that referenced this issue Oct 2, 2020
Enable NoWarn

Fixes #4421
@sbomer
Copy link
Member

sbomer commented Oct 2, 2020

@Forgind awesome! Are there plans to do the same for the other properties? (See #4421 (comment))

@Forgind
Copy link
Member

Forgind commented Oct 2, 2020

@sbomer, I think we wanted to go one at a time, since this could be a breaking change.

In any case, adding support for letting MSBuildWarningsAsErrors default to WarnAsError is straightforward, but I'm not sure how I'd implement WarnNotAsError. Could be a new intrinsic function or converting it to an item and converting it back, but both feel like overkill. Do you have any suggestions for that? I also couldn't find any documentation on it, just another issue in this repo explaining roughly how it should work, so I'm not sure how used it would be.

@sbomer
Copy link
Member

sbomer commented Oct 3, 2020

I had assumed there was a MSBuildWarningsNotAsErrors, but it doesn't look like that's the case - I guess because msbuild doesn't have an option like --warnaserror-:CODE to turn off warnings as errors.

The way it works in Roslyn and ILLink is that TreatWarningsAsErrors will pass --warnaserror to turn all warnings into errors, then WarningsNotAsErrors will pass --warnaserror-:CODE to turn it back off for individual ones.

@rainersigwald
Copy link
Member

#3062 tracks adding WarnNotAsError.

sujitnayak pushed a commit to NikolaMilosavljevic/msbuild that referenced this issue Oct 12, 2020
rainersigwald pushed a commit that referenced this issue Oct 30, 2020
In same feature flag as NoWarn (can change to a separate feature flag if desired.)

Addition to #4421.
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For consideration Used for items on the backlog to raise them to the top of that list for discussion Partner request triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants