New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error CS0017: Program has more than one entry point defined. #636

Closed
NotMyself opened this Issue Mar 20, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@NotMyself

NotMyself commented Mar 20, 2017

Description

I have a small single project console app called DotNetCoreKoans. It has embedded xunit tests in the project. After running dotnet migrate I can no longer build the project. In case it is not clear what my project looks like here is a screenshot showing the test location and my program.cs where my main method is.

image

This bug is also submitted to xunit/xunit#1172

Steps to reproduce

  1. Clone DotnetCoreKoans
  2. Checkout the vs2017 branch git checkout vs2017
  3. Perform a dotnet restore
  4. Perform a dotnet build

Expected behavior

Console project should successfully build with no errors.

Actual behavior

Engine\Program.cs(8,27,8,31): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.

Environment

image

@NickCraver

This comment has been minimized.

Show comment
Hide comment
@NickCraver

NickCraver Mar 24, 2017

I hit this hard with porting Dapper as well, why is VSTest (if it is), injecting another entry point?

NickCraver commented Mar 24, 2017

I hit this hard with porting Dapper as well, why is VSTest (if it is), injecting another entry point?

@NickCraver

This comment has been minimized.

Show comment
Hide comment
@NickCraver

NickCraver Mar 24, 2017

Note: there's another bug here: VS reports the issue is with my net451 build (incorrectly), not the netcoreapp1.0 build that actually has the problem. So there's also an IDE reporting bug around this.

NickCraver commented Mar 24, 2017

Note: there's another bug here: VS reports the issue is with my net451 build (incorrectly), not the netcoreapp1.0 build that actually has the problem. So there's also an IDE reporting bug around this.

@NotMyself

This comment has been minimized.

Show comment
Hide comment
@NotMyself

NotMyself Mar 24, 2017

@NickCraver FWIW xUnit looks to be solving this by assuming the responsibility over in xunit/xunit#1172

NotMyself commented Mar 24, 2017

@NickCraver FWIW xUnit looks to be solving this by assuming the responsibility over in xunit/xunit#1172

@Faizan2304

This comment has been minimized.

Show comment
Hide comment
@Faizan2304

Faizan2304 Mar 27, 2017

Contributor

@NotMyself : You are hitting this issue because vstest is injecting an entry point for all test project. This is done to help users, where test project targets netcoreapp ( we have a tracking bug where entry point is getting added for projects targeting Full .Net here #608 and we plan to fix this in our upcoming releases)

Since your test project is adding entry point itself, you can suppress automatic injection of entry point by adding following line in your csproj

  <PropertyGroup>
    <GenerateProgramFile>false</GenerateProgramFile>
  </PropertyGroup>
Contributor

Faizan2304 commented Mar 27, 2017

@NotMyself : You are hitting this issue because vstest is injecting an entry point for all test project. This is done to help users, where test project targets netcoreapp ( we have a tracking bug where entry point is getting added for projects targeting Full .Net here #608 and we plan to fix this in our upcoming releases)

Since your test project is adding entry point itself, you can suppress automatic injection of entry point by adding following line in your csproj

  <PropertyGroup>
    <GenerateProgramFile>false</GenerateProgramFile>
  </PropertyGroup>
@NotMyself

This comment has been minimized.

Show comment
Hide comment
@NotMyself

NotMyself Mar 27, 2017

@Faizan2304 this seems to resolve my immediate issue. Adding the new property group to my csproj allowed me to successfully run dotnet build, dotnet test and dotnet run. I am resolving this bug in my project.

NotMyself commented Mar 27, 2017

@Faizan2304 this seems to resolve my immediate issue. Adding the new property group to my csproj allowed me to successfully run dotnet build, dotnet test and dotnet run. I am resolving this bug in my project.

@Faizan2304 Faizan2304 closed this Mar 28, 2017

Smilefounder added a commit to Swastika-IO/Swastika-IO-Core that referenced this issue Mar 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment