Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Enable CSC and MSBuild warning as errors #170

Closed
mikeharder opened this issue Feb 14, 2017 · 15 comments
Closed

Enable CSC and MSBuild warning as errors #170

mikeharder opened this issue Feb 14, 2017 · 15 comments
Assignees
Milestone

Comments

@mikeharder
Copy link
Contributor

mikeharder commented Feb 14, 2017

We should ensure that warnings-as-errors is enabled by default for both MSBuild and CSC for src, test, and samples in all repos. If needed, this can be disabled for individual repos/projects/warnings.

This change should allow us to enable warnings-as-errors by default for MSBuild:

dotnet/msbuild#1366

It appears that CSC warnings are currently not be treated as errors, at least for the Entropy\samples projects (aspnet/Entropy#238). Also ensure this MSBuild/NuGet warning from Entropy would be an error: aspnet/Entropy#239.

The Internal.AspNetCore.Sdk sets WarningsAsErrors:

https://github.com/aspnet/BuildTools/blob/dev/src/Internal.AspNetCore.Sdk/targets/Common.props#L27

However, samples don't reference this SDK, so we'll need to find some other way to enable warnings-as-errors for samples.

@natemcmaster
Copy link
Contributor

To be clear, you're talking about MSBuild warnings, not CSC warnings, right?

@mikeharder
Copy link
Contributor Author

I think both should be treated as errors by default, with exceptions as needed. My understanding is that our build is already configured to treat CSC warnings as errors, but we should verify. If true, then the only remaining work is to treat MSBuild warnings as errors.

@natemcmaster
Copy link
Contributor

natemcmaster commented Feb 14, 2017 via email

@natemcmaster natemcmaster removed their assignment Feb 22, 2017
@natemcmaster
Copy link
Contributor

We're pretty close to having eliminated all build warnings. We still have a few assembly conflicts, and we still have an issue with NuGet NuGet/Home#4587, but otherwise I think this is something we can do soon.

@natemcmaster natemcmaster self-assigned this Mar 7, 2017
@natemcmaster natemcmaster removed their assignment Mar 24, 2017
@Eilon Eilon changed the title Enable MSBuild warning as errors Enable CSC and MSBuild warning as errors Apr 18, 2017
@Eilon Eilon modified the milestones: 2.0.0-preview1, 2.0.0-preview2 Apr 18, 2017
@Eilon
Copy link
Member

Eilon commented Apr 18, 2017

FYI: This is not for preview1.

We want to make sure that warnings-as-errors is enabled for both MSBuild and CSC.

@mikeharder mikeharder assigned ryanbrandenburg and unassigned dougbu May 25, 2017
@dougbu
Copy link
Member

dougbu commented May 25, 2017

@mikeharder why did you change the assignment here?

@mikeharder
Copy link
Contributor Author

I thought @ryanbrandenburg could take this since he's working on other build-related stuff. Do you want to keep it?

@dougbu
Copy link
Member

dougbu commented May 25, 2017

@mikeharder yes, this work naturally follows on after my work on API Check (aspnet/BuildTools#146). Both issues involve lots of local Universe builds 😺 Plus, I'm not fighting fires as @ryanbrandenburg is right now.

Any objection to me taking this back @ryanbrandenburg or @mikeharder?

@mikeharder mikeharder assigned dougbu and unassigned ryanbrandenburg May 25, 2017
@mikeharder
Copy link
Contributor Author

It's yours.

@dougbu
Copy link
Member

dougbu commented May 25, 2017

CSC warnings are currently limited to the [Obsolete] warnings discussed in aspnet/Entropy#238 and the new xUnit1004 noise. We should be able to centralize disabling xUnit1004.

MSBuild warnings fall into two categories:

  • 60 (❗️❗️) missing Api Check baseline files. It's relatively simple to disable the warnings or generate the baselines. But, must research whether the packages have been released on NuGet to know which is the correct choice for a project. The repo owners should own this process.
  • Various NuGet.targets or Microsoft.Common.CurrentVersion.targets warnings related to mixed dependency versions. I believe @ryanbrandenburg is already working on some of these. I'll take another look next time our build passes.

@natemcmaster
Copy link
Contributor

FYI for context on xUnit1004 - this warning happens when tests are permanently skipped, i.e. [Fact(Skip = "Flaky")]. xUnit1004 is a symptom of flaky tests or dead code. Both conditions warrant action: fix it or remove it.

@dougbu
Copy link
Member

dougbu commented May 25, 2017

@natemcmaster sure, action is necessary but these particular warnings should not fail our CI builds. I'm saying these particular warnings should not included in a broad "all warnings should be treated as errors" mandate, not that they should be hidden or ignored.

In any case, we should have issues for all disabled tests already -- ready for triage decisions et cetera. Our teams have a clear preference for disabling tests temporarily over removing code (that'll come back soon-ish).

@natemcmaster
Copy link
Contributor

these particular warnings should not fail our CI builds

One more piece of context...before upgraded to xunit.analyzers, we added this particular warning to CSC's WarningsNotAsErrors list to avoid just this problem. aspnet/BuildTools#254.

On a separate note, MSBuild's flag /warnaserrors is good, but not perfect at preventing builds from passing that shouldn't. /warnaserrors allows the build to complete as if the flag is not set, but just turns warnings to errors at the end. Because CSC is incremental and analyzers only run when CSC is actually executed, this means you can easily hit this:

dotnet clean
dotnet build /warnaserrors     # fails because xUnit1004 was upgraded to an error, yet compilation was allowed to finish
dotnet build /warnaserrors     # succeeds. xUnit1004 was not produced because CSC did not recompile

@mikeharder
Copy link
Contributor Author

@natemcmaster: Good to know for dev scenarios, but I don't think this will impact the CI builds since they only build once.

@muratg muratg modified the milestones: 2.0.0, 2.0.0-preview2 Jun 6, 2017
@muratg muratg removed the 2 - Working label Jun 6, 2017
@Eilon Eilon modified the milestones: 2.1.0, 2.0.0 Jun 13, 2017
@Eilon
Copy link
Member

Eilon commented Aug 22, 2017

@mikeharder please check if there's any work left.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants