5
votes

I'm attempting to compile my new C# 7 code on a Linux build server using Mono 5. Unfortunately, the project fails when I use the new ValueTuple syntax:

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

I have the following package reference in my project file:

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

and I'm using the following commands in my quick build script:

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

and the MSBuild log indicates a language version of 7 and shows a reference to 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

Has anyone successfully compiled C# using the new ValueTuple syntax on Linux using Mono 5? Did it just work, or did you need to adjust the environment to make it work?

My build server is running Ubuntu 16.04 and has mono-devel 5.0.1.1-0xamarin5+ubuntu1604b1 installed.

1
Maybe this can help you.DdarkSideE
@DdarkSideE Thanks! I already have the NuGet package installed via the corresponding <PackageReference /> element in my csproj file. I'll edit the question to include that information. MSBuild is correctly referencing System.ValueTuple.dll from the NuGet package cache in the call to csc.exe.seniorquico
This error appears to be due to running from MSBuild or a setting in the sln or csproj files. I just created a simple test and manually compiled using csc (and referencing the same System.TupleValue.dll from the 4.3.0 NuGet package). The simple test compiled and ran without error. I'll try to find a solution and post an answer.seniorquico

1 Answers

5
votes

I uninstalled the stable mono-devel 5.0.1.1-0xamarin5+ubuntu1604b1 and replaced it with the beta mono-devel 5.2.0.196-0xamarin7+ubuntu1604b1. The project now compiles without error.

I will assume that a bug in mono has been fixed that resolves this issue.