Reputation: 24232
I'm trying to have VS treat the following warning as an error. I've had no success with neither a specific warning nor all warnings (in the project options).
Output
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1490,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
Error List
Warning 1 Found conflicts between different versions of the same dependent assembly.
The problem I'm trying to solve is this: MyApp references LibA v1 and LibB v1. LibB v1 references LibA v2. At first there was no notice of the version difference. Signing the assemblies gives the warning. If possible, I'd like to treat it as an error, as those will be notices a lot quicker than a warning which can be overlooked.
Update After working with Phil's answer, I'm now using this macro. It's probably possible to make an addin for this but I don't have the time to do that right now.
Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
' Create a tool window handle for the Output window.
Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
' Create handles to the Output window and its panes.
Dim OW As OutputWindow = win.Object
OW.ActivePane.TextDocument.Selection.SelectAll()
If OW.ActivePane.TextDocument.Selection.Text.Contains("MSB3247") Then
System.Windows.Forms.MessageBox.Show("Found conflicts between different versions of the same dependent assembly.", "warning MSB3247")
End If
End Sub
Upvotes: 2
Views: 726
Reputation: 3511
Just be aware that MSB warning is not a compiler warning, so it is not able to be handled by /warningaserror.
Maybe you can add post build action to parse your build output, and if you find MSB3247, you can just delete the build output and play destiny symphony
Upvotes: 5