2011-11-15 87 views
2

我试图让VS将下列警告视为错误。我没有取得任何成功,既没有具体的警告,也没有任何警告(在项目选项中)。将警告视为错误

输出

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. 

错误列表

Warning 1 Found conflicts between different versions of the same dependent assembly. 

我试图解决的问题是这样的:MyApp的引用力霸V1和V1 LibB。 LibB v1引用了LibA v2。起初没有关于版本差异的通知。签署组件会给出警告。如果可能的话,我想把它看成是一个错误,因为这些会比注意到的警告快得多。

更新 在与菲尔的答案工作后,我现在使用这个宏。可能为此做一个插件,但我现在没有时间这样做。

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 
+0

VS的什么版本? – Connell

+0

我试图在VS2010中,但我也使用VS2008的WinCE项目。 – Stijn

回答

4

请注意,MSB警告不是编译器警告,因此无法通过/ warningaserror进行处理。

也许你可以添加后生成的行动来分析您的构建输出,如果你发现MSB3247,你可以删除生成输出和播放命运交响曲

+0

我在帖子中提到该选项不会改变任何内容。 – Stijn

+0

对不起,没有注意到。似乎你应该削减一张票到微软。 – ComfortablyNumb

+0

我用一个宏去了,但我会将它标记为答案,因为它使我走上了正确的道路。 – Stijn