2011-11-15 85 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