Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

ASP.NET Core 2.1 gives error CS2017: Cannot specify /main if building a module or library #2398

Closed
pranavkm opened this issue Jun 11, 2018 · 5 comments
Assignees
Labels
3 - Done bug PRI: 0 - Critical Blocks a critical product path. Must be handled immediately

Comments

@pranavkm
Copy link
Contributor

Original issue: https://github.com/aspnet/websdk/issues/350

Steps to reproduce:

  • Install .NET Core SDK 2.1
  • Create a new project with dotnet new "asp.net core web app"
  • The project compiles OK
  • Add element <StartupObject>foo.Program</StartupObject> to the csproj

Build fails with:

1>CSC : error CS2017: Cannot specify /main if building a module or library

This error did not occur with 2.0. Also a plain .NET core console app initialized with dotnet new "console application" does not have this problem.

@mkArtakMSFT mkArtakMSFT added this to the 2.1.3 milestone Jun 11, 2018
@mkArtakMSFT mkArtakMSFT added the SHP: Approval pending Shiproom approval is required for the issue label Jun 11, 2018
@pranavkm pranavkm modified the milestones: 2.1.3, 2.2.0-preview1 Jun 14, 2018
@pranavkm pranavkm removed the SHP: Approval pending Shiproom approval is required for the issue label Jun 14, 2018
@JohnGalt1717
Copy link

JohnGalt1717 commented Jun 15, 2018

So how do you fix it? Just remove the startup object?

@pranavkm
Copy link
Contributor Author

Removing the startup object would be the easiest workaround. Alternatively, you could try resetting the property right before Razor compilation occurs:

<Target Name="FixStartupObjectIssue" BeforeTargets="RazorCoreCompile">
  <PropertyGroup>
    <StartupObject />
  </PropertyGroup>
</Target>

Yet another option would be to edit the actual Sdk target to not pass the property in Razor's call to the Csc task. I wouldn't recommend this fix though, since it's tied to your machine.

@mkArtakMSFT mkArtakMSFT added the PRI: 0 - Critical Blocks a critical product path. Must be handled immediately label Jun 19, 2018
@mkArtakMSFT
Copy link
Member

@pranavkm, do you have a PR ready for this?

@pranavkm
Copy link
Contributor Author

Not as yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 - Done bug PRI: 0 - Critical Blocks a critical product path. Must be handled immediately
Projects
None yet
Development

No branches or pull requests

3 participants