编程语言
首页 > 编程语言> > 使用Mono 5编译包含ValueTuple的C#7代码

使用Mono 5编译包含ValueTuple的C#7代码

作者:互联网

我正在尝试使用Mono 5在Linux构建服务器上编译我的新C#7代码.不幸的是,当我使用新的ValueTuple语法时,项目失败:

MyClass.cs(100,38): error CS1003: Syntax error, ‘(‘ expected [/path/to/My.csproj]

我的项目文件中有以下包引用:

<PackageReference Include="System.ValueTuple" Version="4.3.0" />

我在快速构建脚本中使用以下命令:

# msbuild My.sln /t:restore
# msbuild My.sln /p:Configuration=Release /p:Platform="Any CPU"

并且MSBuild日志指示语言版本为7并显示对System.ValueTuple.dll的引用:

CoreCompile:

/usr/lib/mono/4.5/csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705,1701,1702 /langversion:7 /nostdlib+ /errorreport:prompt /warn:4 /doc:bin/Release/net461/My.xml /define:TRACE;RELEASE;NET461 /highentropyva+ … /reference:/root/.nuget/packages/system.valuetuple/4.3.0/lib/netstandard1.0/System.ValueTuple.dll … /debug- /debug:portable /filealign:512 /nologo /optimize+ /out:obj/Release/net461/My.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output /deterministic+ My.cs “/tmp/.NETFramework,Version=v4.6.1.AssemblyAttributes.cs” obj/Release/net461/My.AssemblyInfo.cs

有没有人使用Mono 5在Linux上使用新的ValueTuple语法成功编译C#?它只是工作,还是你需要调整环境才能使它工作?

我的构建服务器正在运行Ubuntu 16.04并安装了mono-devel 5.0.1.1-0xamarin5 ubuntu1604b1.

解决方法:

我卸载了稳定的mono-devel 5.0.1.1-0xamarin5 ubuntu1604b1并将其替换为beta mono-devel 5.2.0.196-0xamarin7 ubuntu1604b1.该项目现在编译没有错误.

我将假设修复了单声道中的错误以解决此问题.

标签:c,linux,mono,c-7-0
来源: https://codeday.me/bug/20190519/1133179.html