microsoft / testfx

MSTest framework and adapter
MIT License
678 stars 245 forks source link

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

Open drieseng opened 2 weeks ago

drieseng commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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