开发者

MSBuild fails on VB.NET lambda expressions

I have an issue with building a project using the MSBuild (ver 4) from the command line when declaring lambda expression like this:

Private Sub Foo(ByVal s As String)
    Dim WL = Sub(str As String)
                 If Not String.IsNullOrEmpty(str) Then
                     Console.WriteLine(str)
                 End If
             End Sub
    WL(s)
End Sub

The error occurs at second line of code above:

error BC30201: Expression expected.

In Visual Studio 2010 it compiles just fine.

MSBuild BAT file:

SET MSBUILD="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
SET LogDll="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Engine.Dll"

SET VSBuildSolName="d:\Projects\Source\Test.sln"

SET VSBuildConfigNameD="Debug"
SET VSBuildConfigNameR="Release"

SET VSBuildErrFileNameD="d:\Projects\build\Test_errD.txt"
SET VSBuildErrFileName开发者_运维问答R="d:\Projects\build\Test_errR.txt"

CALL %MSBUILD% %VSBuildSolName% /p:Configuration=%VSBuildConfigNameD% /logger:FileLogger,%LogDll%;LogFile=%VSBuildErrFileNameD% /verbosity:normal /P:NOWARN= /tv:3.5


As an answer to your question

1) why Visual Studio 2010 builds it without errors?

It is of course possible to write code in each subsequent version of Visual Studio that will not work in earlier versions especially when such code uses new features of the current version or current IDE of Visual Studio or the Express Edition.

Take for example a one line PROPERTY, you can not do that in previous versions of VB.Net prior to 2010, as another example, you can not omit the line continuation character in versions prior to 2010 where you can in 2010 in certain parts of your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜