Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio for Mac- Error CS1902

I just recently swapped my MS PC for an Mac, I'm trying to continue working on an MVC project, but I'm getting an error (Error CS1902: Invalid option 'portable' for /debug; must be full or pdbonly (CS1902)).

Are there any good documents that explain how to make it work? I have seen people porting MVC to .NET Core, but I can't get the analyser to work on my Mac (not sure it's supported yet).

like image 581
S.Hefer Avatar asked Dec 15 '16 19:12

S.Hefer


2 Answers

I did two things.

  1. I update the Microsoft.Net.Compliers via nuget. https://www.nuget.org/packages/Microsoft.Net.Compilers/

  2. Change one value in the properties of project. https://johnharold.wordpress.com/2017/08/16/csc-error-cs1902-invalid-option-portable-for-debug-must-be-full-or-pdbonly-cs1902/

I wish you can solve the problem

like image 153
Sebastianvz Avatar answered Nov 02 '22 14:11

Sebastianvz


I had this same problem when trying to use Visual Studio for Mac to build a solution that works fine in Windows. Turns out the /debug:portable flag was being passed to the build command, even though the 'Debug Information' was correctly set to 'Full' in my project settings. Search the build output for 'portable' and you will indeed find the flag there regardless of your settings.

The fix is to upgrade the Microsoft.Net.Compilers nuget package. In my case, it upgraded from 1.0 to 2.7, and then the project built successfully.

like image 32
wjm03 Avatar answered Nov 02 '22 14:11

wjm03