我正在尝试使用Mono 5在Linux构建服务器上编译我的新C# 7代码。不幸的是,当我使用新的ValueTuple语法时,项目失败:
MyClass.cs(100,38):错误CS1003:语法错误,需要'('[/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
有人在Linux上使用Mono 5成功编译C#新的ValueTuple语法吗?它是否正常工作,还是需要调整环境才能使其正常工作?
我的构建服务器正在运行Ubuntu 16.04,并安装了mono-devel 5.0.1.1-0xamarin5+ubuntu1604b1。
<PackageReference />
元素安装了 NuGet 包。我将编辑问题以包含该信息。MSBuild 在调用 csc.exe 时正确地从 NuGet 包缓存中引用 System.ValueTuple.dll。 - seniorquico