Skip to content

Compile error Program does not contain a static 'Main' method suitable for an entry point #3863

@maskedmouse

Description

@maskedmouse

I'm trying to add TUnit testing to my already existing Blazor hybrid + Web API project but I keep receiving the error CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point

Even in a completely new web api project it keeps throwing this error.
I am not sure what is expected here since the documentation says:
And then remove any automatically generated Program.cs or main method, as this'll be taken care of by the TUnit package.

In visual studio there isn't even a "Use testing platform server mode" anymore in the insiders version.
Primarily I use Rider which I already enabled the Testing platform support.

This is the Tests.csproj it references the main project.
The main project does include a Program.Main
The Tests project does not.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Name\InsertProjectName.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0" />
    <PackageReference Include="TUnit" Version="1.2.3" />
  </ItemGroup>

</Project>

So have I forgotten something, is it not compatible with the latest version or did I do something wrong?
The template seems to have the same error.

Using the latest version of Rider (2025.3.0.1), Visual Studio Community 2026 (11206.111) and TUnit 1.2.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions