On our continous integration server (Teamcity 5.1.3) we have a msbuild script that is automatically building our applications.
When we enable "Warning as error": in Visual Studio, it build fine (it ignores the methods within "*.designer.cs" files. But on the build server we always receive the following error:
[(Rebuild target(s)):] somefile.Designer.cs(XX, XX): error CS1591: Warning as Error: Missing XML comment for publicly visible type or member...
The MSBuild script that is being used looks like this:
<MSBuild Projects="proj\$(ProjectName).sln"
Targets="Clean;Rebuild"
Properties="Configuration=Release"
StopOnFirstFailure="True">
</MSBuild>
I can understand why it does that, but there must be a way to tell msbuild to ignore missing comments in generated files?
EDITED
Digging a little further: In the Visual Studio Solution we had "Warning as error" checked but we also add error 1591 listed in the "Suppress warning" textbox. MSBuild does'nt seem to pick up that "suppress warning" textbox and fails the build. Anything I can do?
EDITED Again The problem was that MSBuild was targetting any CPU (and in the "ANY CPU" configuration we didnt suppressed error 1591). Once we changed ANY CPU to exclude error 1591 it all started to build correctly on the build server. Thanks for those that helped.
You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).
Turn off the warning for a project in Visual StudioSelect the Configuration Properties > C/C++ > Advanced property page. Edit the Disable Specific Warnings property to add 4996 . Choose OK to apply your changes.
Yes, even once in a while you will encounter the occasional warning you'd be better off leaving as a warning or even disabling completely. Those should be the exception to the rule, though. Here's some practical advise: at the start of a new project, start treating all warnings as errors, by default.
You can ignore comments warning by adding the following property in your msbuildcall : nowarn="1591,1573".
<MSBuild Projects="proj\$(ProjectName).sln"
Targets="Clean;Rebuild"
Properties="Configuration=Release;nowarn=1591,1573"
StopOnFirstFailure="True">
</MSBuild>
No, MSBuild isn't picky about XML comments. Whatever code analysis tool you use is. Guessing at something like StyleCop. It does complain about this exact problem, it's not very smart, about on par with the Windows Forms project templates.
You are only ever going to solve this problem if you enforce the same kind of build rules on the devs as you apply to the build server. Because it will take one of them to edit the do-not-edit code that it is in a Mumble.Designer.cs file and apply the [GeneratedCode] attribute. It is not there now.
That's a political problem, one I cannot really help you with. Nor the Microsoft groups that worked on this at different times and different buildings. But you can count on the devs barking loudly if you ask them to solve the problem.
Make it consistent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With