Reputation: 101
I'm building a project with a .fsx script using FAKE and MSBuild. When building with MSBuild, i give it several parameters:
Target "BuildProject" (fun _ ->
CleanDir ProjectDir
[ProjectPath]
|> MSBuild ProjectDir "Build" ["Configuration", "Release"; "Platform","x64"; "Verbosity", "quiet"; "TreatWarningsAsErrors", "true"]
|> ignore)
However, when i run my script, warnings are not treated as errors:
Build succeeded.
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:11.36
Finished Target: BuildProject
Here is my commandline input:
Building project: MyProject/MyProject.fsproj
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
MyProject/MyProject.fsproj /t:Build /m /nodeReuse:False /p:RestorePackages="False"
/p:OutputPath="D:\MyProjectFolder\build\MyProject" /p:Configuration="Release" /p:Platform="x64"
/p:Verbosity="quiet" /p:TreatWarningsAsErrors="true" /logger:Fake.MsBuildLogger+ErrorLogger,"D:\MyProjectFolder\Project\packages\FAKE\tools\FakeLib.dll"
I'm not sure if the property is set correctly, but i've tried various versions by reading the documentation of FAKE and MSBuild.
From what i've read online, the property has to be given to the compiler, and will not work if the property is defined in a XML file.
Im using FAKE 4.64.11.
I want all warnings to be treated as errors, and not just specific warnings.
Hope someone can help.
Upvotes: 2
Views: 1423
Reputation: 101
So... after reasearching a bit further, it seems that MSB errors such as missing assemblys, cannot be caught by the TreatWarningsAsErrors-approach as i stated above. A way to get around this, is by having a custom build-wrapper that catches these errors.
I found the answer in the answer to this question: Treat all warnings as errors
Another similar thread: How can I treat MSB3245 (could not resolve reference) warning as an error?
Upvotes: 1