I am trying to port my Asp.Net WebApi project, based on the Onion Architecture design approach, over to Asp.Net Core. However, when I build my class libraries, the compiler
<PropertyGroup>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
</PropertyGroup>
One obvious solution is to check the official MSDN error code description here
I had async modifier and had to move to C# language version 7.1+
If the Main method has an async modifier, make sure that the selected C# language version is 7.1 or higher. You can fix the issue by adding below element to the .csproj file manually. Reference
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
I updated the output type of non-startup projects in solution to class library, and the problem was fixed.
I have been dealing with this error on macOS with .NET Core 2.0, and it appears to be related to my storing my solution in a Google Drive folder. It's certainly not because I am missing main methods in my projects, although intermittently I am seeing files/folders disappear from Rider and re-adding them (add existing item) is resolving the issue. I get the same error in VS for Mac and VS Code, but they don't seem to be updating the folder contents to reflect missing files, so it was harder to pinpoint the issue.
tl;dr Try moving your solution/project out of a synced network drive!
Solved a similar issue by explicitly setting the OutputType
tag in my classlib.csproj file:
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <OutputType>Library</OutputType> </PropertyGroup>