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. #1172
Comments
.NET Core test projects are exe's. They just provide the main method for you... not sure there's a way around that. This would belong in https://github.com/microsoft/vstest/issues as it's an issue with the test platform, not xunit. |
That's a mandate right now from VSTest. I don't think it'll be required for |
Thanks @bradwilson I'll come up with something until that releases. @onovotny I submitted a bug to vstest. Really weird that they would inject a static void Main into a console application like that and just let it fail to build. |
@bradwilson did you see the resolution to this over in microsoft/vstest#636 ? Looks like there is a flag you can set in your csproj to disable this silly behavior. |
I honestly have no idea why they did that in the first place. My work showed it to be completely unnecessary now (obviously, since you can provide your own entry point, you don't need theirs). It used to be that a unit test project in DNX had to be an executable, because of the architecture of that system (the runner was literally an entry point to the program, so that you can write your own Main and accept command line arguments). That hasn't been true since they changed to VSTest. It's possible that they're just doing it out of habit rather than any technical need. |
There are some things I'm injecting into the project to get it to generate the artifacts I need (with tons of nods to Nate McMaster who is like my guidebook for .NET Core). Maybe VSTest should take this strategy rather than flipping the project into an executable. <Project>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<CopyNuGetImplementations>true</CopyNuGetImplementations>
<DebugType Condition=""'$(TargetFrameworkIdentifier)' != '.NETCoreApp'"">Full</DebugType>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateDependencyFile>true</GenerateDependencyFile>
</PropertyGroup>
</Project> |
Closing this as external, because (a) there's a workaround, and (b) it's not our bug. |
I also have this issue in a Window form project. Please help if someone can! |
Please don't respond to closed issues. Open a new one, and provide a repro project (otherwise it'll be closed). Thanks! |
|
To be able to upgrade to MSTest.TestAdapter version 3.2.0, and since we are using the mocks in some of our example projects I had to move the mocks into a separate test library to avoid the error: "CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point." Not sure why this didn't hit us before, but at least this approach fixes the problem. For more information see: xunit/xunit#1172
To be able to upgrade to MSTest.TestAdapter version 3.2.0, and since we are using the mocks in some of our example projects I had to move the mocks into a separate test library to avoid the error: "CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point." Not sure why this didn't hit us before, but at least this approach fixes the problem. For more information see: xunit/xunit#1172
To be able to upgrade to MSTest.TestAdapter version 3.2.0, and since we are using the mocks in some of our example projects I had to move the mocks into a separate library to avoid the error: "CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point." Not sure why this didn't hit us before, but at least this approach fixes the problem. For more information see: xunit/xunit#1172
To be able to upgrade to MSTest.TestAdapter version 3.2.0, and since we are using the mocks in some of our example projects I had to move the mocks into a separate library to avoid the error: "CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point." Not sure why this didn't hit us before, but at least this approach fixes the problem. For more information see: xunit/xunit#1172
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. I get the following error:Incase 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.
The text was updated successfully, but these errors were encountered: