Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Create new Web API using dotnet new webapi
with use-minimal-apis and use-program-main options set, you get a warning on build.
The entry point of the program is global code; ignoring 'Program.Main(string[])' entry point.
This seems to be happening because it creates both a Program.Main.cs and a Program.cs.
Expected Behavior
No warnings or errors on build
Steps To Reproduce
INSTALL STEPS
- Clean Windows 10 x64 machine
- Install .NET SDK 6.0.300
REPRO STEPS
- Create new Web API using
dotnet new
with use-minimal-apis and use-program-main options set - Build project
dotnet build
>dotnet new webapi -o WebApi02 --use-minimal-apis --use-program-main
The template "ASP.NET Core Web API" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on C:\Users\<user>\Solutions\Projects02\WebApi02\WebApi02.csproj...
Determining projects to restore...
Restored C:\Users\<user>\Solutions\Projects02\WebApi02\WebApi02.csproj (in 352 ms).
Restore succeeded.
>cd WebApi02
>dotnet build
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
C:\Users\<user>\Solutions\Projects02\WebApi02\Program.Main.cs(5,24): warning CS7022: The entry point of the program is
global code; ignoring 'Program.Main(string[])' entry point. [C:\Users\<user>\Solutions\Projects02\WebApi02\WebApi02.csp
roj]
WebApi02 -> C:\Users\<user>\Solutions\Projects02\WebApi02\bin\Debug\net6.0\WebApi02.dll
Build succeeded.
C:\Users\<user>\Solutions\Projects02\WebApi02\Program.Main.cs(5,24): warning CS7022: The entry point of the program is
global code; ignoring 'Program.Main(string[])' entry point. [C:\Users\<user>\Solutions\Projects02\WebApi02\WebApi02.csp
roj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:05.16
Exceptions (if any)
No response
.NET Version
6.0.300
Anything else?
I'm also able to reproduce this with SDK 6.0.203.