昨晚我的每晚構建失敗。這個問題是一個代碼更改,它實現了一個ReadOnly Property
作爲一個完整的讀/寫Property
它說這是不允許的。訪問級別不匹配接口實現在Visual Studio中編譯,但不能在msbuild中編譯
這很好(我可以看到兩種方式的參數,但很明顯)。但是,在Visual Studio(2015)中,相同的代碼完全可以編譯。但是從命令行調用msbuild的腳本構建失敗。
一個簡單的例子來說明這個問題,下面的代碼編譯在VS OK(然後運行也沒關係):
Module Module1
Interface IFoo
ReadOnly Property Bar As String
End Interface
Class Foo
Implements IFoo
Private _Bar As String
Public Property Bar As String Implements IFoo.Bar
Get
Return _Bar
End Get
Set(value As String)
_Bar = value
End Set
End Property
End Class
Sub Main()
Dim F As New Foo
F.Bar = "baz"
Console.WriteLine(F.Bar)
End Sub
End Module
但運行以下命令
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe Foo.vbproj
失敗
Build FAILED.
"C:\Users\...\Foo\Foo\Foo.vbproj" (default target) (1) ->
(CoreCompile target) ->
C:\Users\...\Foo\Foo\Module1.vb(10,20): error BC30154: Class 'Foo' must
implement 'ReadOnly Property Bar As String' for interface 'IFoo'.
Implementing property must have matching 'ReadOnly'
or 'WriteOnly' specifiers. [C:\Users\..\Foo\Foo.vbproj]
C:\Users\...\Foo\Foo\Module1.vb(13,50): error BC30401: 'Bar' cannot
implement 'Bar' because there is no matching property on interface
'IFoo'. [C:\Users\...\Foo\Foo.vbproj]
0 Warning(s)
2 Error(s)
將ReadOnly Property Bar As String
更改爲Property Bar As String
意味着它bui用相同的命令很好。
問題:
有某種改變,這是現在而不是更早允許? 我應該使用更新的msbuild嗎? (目前似乎沒有安裝一個 )
有沒有什麼辦法讓Visual Studio的行爲與msbuild相同? ?我想知道,當我在VS中構建時,它 意味着它將使用msbuild構建。我很高興接受 這是一個錯誤,但我希望VS將其顯示爲錯誤。
請參閱:[MSBuild VS Visual Studio - 編譯差異?](http://stackoverflow.com/questions/42787906/msbuild-vs-visual-studio-differences-in-compilation?rq=1) – TnTinMn
設置沒有VS許可證的構建服務器從來就不是錯誤。你的開發機器使用Roslyn,你的構建服務器沒有。它使用與VS2012兼容的VB.NET編譯器和語言版本。降級你的VS2015的味道[可能但很尷尬](http://stackoverflow.com/a/32123363/17034)。 –
@亞當,這個問題的任何更新?你能從答案和評論中得到任何有用的信息嗎?如果沒有,請讓我們瞭解這個問題的最新狀態? –