-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add option for "warning as errors except ..." #3062
Comments
Just sent a PR for inclusion in F# project system request as well dotnet/fsharp#3395 😄 |
I need that too. |
@MarkKharitonov That is already the case. This is a request to make some warnings produced as warnings even when $ type warnaserror.proj
<Project>
<Target Name="Warn">
<Warning Code="Code1" Text="Warning 1" />
<Warning Code="Code2" Text="Warning 2" />
</Target>
</Project>
$ msbuild warnaserror.proj -warnAsError
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 11/19/2018 10:02:37 AM.
Project "s:\warnaserror.proj" on node 1 (default targets).
s:\warnaserror.proj(3,3): error Code1: Warning 1
s:\warnaserror.proj(4,3): error Code2: Warning 2
Done Building Project "s:\warnaserror.proj" (default targets).
Build FAILED.
"s:\warnaserror.proj" (default target) (1) ->
(Warn target) ->
s:\warnaserror.proj(3,3): error Code1: Warning 1
"s:\warnaserror.proj" (default target) (1) ->
s:\warnaserror.proj(4,3): error Code2: Warning 2
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:00.10
$ msbuild warnaserror.proj -warnAsError -nowarn:Code1
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 11/19/2018 10:02:47 AM.
Project "s:\warnaserror.proj" on node 1 (default targets).
s:\warnaserror.proj(4,3): error Code2: Warning 2
Done Building Project "s:\warnaserror.proj" (default targets).
Build FAILED.
"s:\warnaserror.proj" (default target) (1) ->
(Warn target) ->
s:\warnaserror.proj(4,3): error Code2: Warning 2
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.12
$ msbuild warnaserror.proj -warnAsError -nowarn:Code1 -verbosity:detailed
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 11/19/2018 10:03:03 AM.
Project "s:\warnaserror.proj" on node 1 (default targets).
Building with tools version "15.0".
Target "Warn" in project "s:\warnaserror.proj" (entry point):
Using "Warning" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5
f7f11d50a3a".
Task "Warning"
s:\warnaserror.proj(3,3): message Code1: Warning 1
Done executing task "Warning".
Task "Warning"
s:\warnaserror.proj(4,3): error Code2: Warning 2
Done executing task "Warning".
Done building target "Warn" in project "warnaserror.proj".
Done Building Project "s:\warnaserror.proj" (default targets).
Build FAILED.
"s:\warnaserror.proj" (default target) (1) ->
(Warn target) ->
s:\warnaserror.proj(4,3): error Code2: Warning 2
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.18 |
Excellent, then we do not have a problem. So, I can pass /err /nowarn:MSB3026 to treat all the warnings as errors except for MSB3026 I do not know if this is your thing, but could you answer to https://stackoverflow.com/questions/53375076/does-the-new-msbuild-15-warnaserror-switch-allow-to-fail-on-all-the-warnings-ex?noredirect=1#comment93638635_53375076 so that I could credit you? |
This would be very useful, so that build output still shows the warnings, but simply doesn't treat them as errors. |
Is there still demand for a feature like this despite the workaround @rainersigwald suggested further up in this thread? |
We also bumped into the problem in C# projects:
We expected the warning to be displayed as warning, but it's displayed as error. |
Yes, I would still like this feature. So would the people commenting on #5053. |
Will make sure we at least discuss this during our next planning meeting. |
Fixes #3062 Context We previously had warnaserror (and a property for it) that, when you specified error codes, upgraded those error codes from warnings to errors. If you just left it empty, it upgraded all warnings to errors. (Null meant don't upgrade.) This adds that you can ask for all error codes to be upgraded, then downgrade just a few of them (via codes) back to warnings. Changes Made Implement WarnNotAsError both as a command line switch and as a property. Testing Added a unit test. Tried it out from the command line.
Thanks! |
Added the Documentation label to signal that we need a Docs addition for this feature. |
Follow up to #68
I would like to have the ability to make all warnings by errors, but with some exclusions.
This is not the same as
-nowarn
which would make the warning a low-importance message and hide the warning. I still want the warnings to appear as warnings so show the user there may be a problem, but I want to be able to specify which problems are non-fatal.My scenario:
We would like to enable
-warnAsError
by default in the build system that produces ASP.NET Core, but we can't because there are a handful of warning that we can't always do anything about. We would like the warnings to appear, but to be non-fatal to a build passing.For comparison, C# supports a
WarningsNotAsErrors
properties which allows users to setTreatWarningsAsErrors=true
which exclusions defined asWarningsNotAsErrors
.The text was updated successfully, but these errors were encountered: