This should be obvious to do, but I just couldn't make it work...
What I'm trying to do is simple: I would like my compilation to fail with an error if there is a warning. Yes, the famous TreatWarningsAsErrors
...
I configured it in my C# project properties
This results in the expected TreatWarningsAsErrors
section in my csproj:
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
So far so good, if I add an useless private
variable in my code, it results in a compilation error:
private int unused;
Error 3 Warning as Error: The field 'XXXX.unused' is never used
But the whole problem is, I can't make it work for assembly reference issues. If I have a reference to an unknown assembly, the compiler (either devenv or msbuild) throws a warning, but I want an error instead.
Ultimately, I'm trying to configure a gated check-in TFS build configuration, so TFS would reject a commit in case there is a "The referenced component 'XXXX' could not be found." warning. Something simpler than modifying the build process template would be great.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…