Search code examples
visual-studioobject.net-coresystemvisual-studio-mac

Asp.NetCore 1.1->2.0 Migration Error - `System.Object' is not defined or imported


I have a project I've been messing with and adding features to, and it was aspnet core 1.1. I am migrating it to 2.0.

I use Visual Studio for Mac, and it's up-to-date.

I am following this documentation:

https://learn.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/

The exact error I'm getting is:

The predefined type `System.Object' is not defined or imported

Solution

  • I found the answer:

    In VS for Mac, it didn't let me get to a menu for selecting the target framework for a project. This is usually opened by right-clicking the project, and selecting "properties."

    VS for Mac didn't show this.

    Upon using my windows install on my iMac, I found the menu and saw AspNetCore2.0 wasn't listed (but 1.0 and 1.1 were). There was also another option to install more. this led me to:

    https://www.microsoft.com/net/targeting?utm_source=getdotnetsdk&utm_medium=referral

    At this page, there are SDK's for the AspNet Core 2.0 for macOS and windows 64-bit. You need to install these, and then it'll build.

    The fact that visual studio doesn't indicate that you're missing a selected framework for the project you're trying to build (as defined in its config file) is absurd. They need to fix this to avoid these kind of headaches. I was under the impression that it wasn't needed, as the NUGET package for 2.0 had all o this.