昨晚我的每晚构建失败。这个问题是一个代码更改,它实现了一个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)。 –
@亚当,这个问题的任何更新?你能从答案和评论中得到任何有用的信息吗?如果没有,请让我们了解这个问题的最新状态? –