Reputation: 2685
I have just went through one of my projects and used a bunch of the new c# 6 features like the null propagation operator handler?.Invoke(null, e)
, which builds in Visual Studio. However, when I run my script to publish out the NuGet packages, I get compilation errors saying:
EventName.cs(14,66): error CS1056: Unexpected character '$'
EventName.cs(69,68): error CS1519: Invalid token '=' in class, struct, or interface member declaration
EventName.cs(69,74): error CS1520: Method must have a return type
It would appear NuGet is using an older version of the compiler, but I was wondering if anyone knew a work around or configuration that could be set to resolve the issue.
Upvotes: 8
Views: 758
Reputation: 1640
Looks like you have also found this bug in the Nuget which is still not resolved: https://github.com/NuGet/Home/issues/1107
You can use the following workaround:
Modify the script to build your project using correct version of MSBuild - just call MSBuild.exe
yourself, supply the path to the csproj or sln file and build your project in a correct configuration yourself.
Create a nuspec file that describes your package (https://docs.nuget.org/create/nuspec-reference). You can use the Nuget Package Explorer app. Use DLLs produced in step 1.
Use nuget pack mypackage.nuspec
to build the package.
Upvotes: 2