Skip to content
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

TestingPlatformEntryPoint.Main is generated in project referencing unit test project #3129

Closed
drieseng opened this issue Jun 19, 2024 · 3 comments · Fixed by dotnet/docs#41680

Comments

@drieseng
Copy link

Describe the bug

After upgrading MSTest (V2) from version 3.1.1 to version 3.4.3, the following diagnostic is reported for one of our solutions:

error CS8892: Method 'TestingPlatformEntryPoint.Main(string[])' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found

This diagnostic is reported when we have a (console) project - that is not a unit test project - which references a unit test project.
I don't see why such an entrypoint is generated in projects that reference a unit test project. It should only be generated in the unit test project itself.

Steps To Reproduce

  1. Clone https://github.com/drieseng/duplicate-entrypoint.git
  2. Open the DuplicateEntrypoint.sln solution in Visual Studio.
  3. Build the solution.

Expected behavior

No warnings or error are reported.

Actual behavior

The following diagnostic is reported:

error CS8892: Method 'TestingPlatformEntryPoint.Main(string[])' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found

@nohwnd
Copy link
Member

nohwnd commented Jun 20, 2024

This additional entrypoint is generated by our TestingPlatform.MSBuild target. This target is transitive and so it gets included to all projects that reference the test project. You can disable the entry point generation by:

<PropertyGroup>
    <IsTestingPlatformApplication>false</IsTestingPlatformApplication>
</PropertyGroup>

@nohwnd
Copy link
Member

nohwnd commented Jun 20, 2024

This is desired behavior, but it does not seem to be documented. Changing the type to docs.

@Evangelink
Copy link
Member

Closing as resolved as we are just waiting for the doc PR to be merged.

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

Successfully merging a pull request may close this issue.

3 participants