Upgraded from v5.1 -> v.5.4 and getting compiler error: Cannot specify /main if building a module or library


I’ve upgraded my project from v5.1 to v5.4.

I am getting the following errors when compiling:
Cannot specify /main if building a module or library

I’ve tried changing the target framework and still getting the same error.

Please help.


It says you have a static main function when you’re building a class library? You can only have them for exe’s.

But it worked fine for 5.1 and .NET Core 2.0?

How do I go getting around this, it is hosted with IIS integration?

This is due to your project configuration not your dependencies. Compare your csproj before/after.

It is just the version numbers that changes in the csproj file. I’ve tried to update the ASP.NET Core dependencies first and everything is still fine, until I update the ServiceStack dependencies then I am getting this issue.

That doesn’t make sense, dependencies don’t change the project type. Please post a repro to GitHub.

I’ve tried to put a repo together and stripped down all the code, to the minimum required. It works all fine, until I add my Views folder that contain .cshtml razor files. Then I get the above error.

Have a look at the razor and mvc .NET Core project templates for working examples that use v5.4.