Skip to content

Add new "api" project template that supports native AOT #46064

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

Merged
merged 21 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
03ea0a9
Initial draft of API project template
DamianEdwards Jan 7, 2023
dcd6740
Added "api" project template
DamianEdwards Jan 9, 2023
4b06b87
Add script for running "dotnet new api -aot" locally
DamianEdwards Jan 9, 2023
4d5c25e
Fixes to api project template
DamianEdwards Jan 9, 2023
90dc1d1
api project template native AOT fixes
DamianEdwards Jan 10, 2023
87c9ed5
Fix casing
DamianEdwards Jan 10, 2023
ddec1b6
Update Test-Template.ps1 to handle RID-specific publish output
DamianEdwards Jan 10, 2023
6fbe795
Use minimal APIs in api template for native AOT
DamianEdwards Jan 11, 2023
edd2573
Add explicit call to add console logging in api template
DamianEdwards Jan 11, 2023
7abf696
Add more local run scripts for api project template
DamianEdwards Jan 11, 2023
5715313
Hide the api project template in VS
DamianEdwards Jan 11, 2023
1f6e0c7
Disable IIS settings in api project template when native AOT
DamianEdwards Jan 12, 2023
1cbd2c0
Move TrimmerSingleWarn to test infrastructure scripts
DamianEdwards Jan 12, 2023
82de5c7
Fix namespace in api project template
DamianEdwards Jan 12, 2023
db91d0a
Add initial api template tests
DamianEdwards Jan 12, 2023
761e476
Update ApiTemplateTest.cs
DamianEdwards Jan 12, 2023
2800c2d
Rename api project template IDE icon
DamianEdwards Jan 12, 2023
837a60a
Actually publish native aot in api template
DamianEdwards Jan 13, 2023
efd0206
Change api template to todos
DamianEdwards Jan 13, 2023
697bdc0
PR feedback
DamianEdwards Jan 13, 2023
0d6c670
Update api template baseline & launchsettings
DamianEdwards Jan 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ProjectTemplates/Shared/ArgConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ internal static class ArgConstants
public const string AadB2cInstance = "--aad-b2c-instance";
public const string UseLocalDb = "-uld";
public const string NoHttps = "--no-https";
public const string PublishNativeAot = "--publish-native-aot";
}
17 changes: 17 additions & 0 deletions src/ProjectTemplates/Web.ProjectTemplates/Api-CSharp.csproj.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">true</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<ServerGarbageCollection>False</ServerGarbageCollection>
<!--#if (NativeAot) -->
<PublishAot>true</PublishAot>
<TrimMode>full</TrimMode>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - I opened https://github.com/dotnet/aspnetcore/issues/46084 to see if we can remove this from the template and just add it to the SDK.

<PublishIISAssets>false</PublishIISAssets>
<!--#endif -->
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</PropertyGroup>

<ItemGroup>
<!-- These projects product packages that the templates depend on. See GenerateContent.targets -->
<!-- These projects produce packages that the templates depend on. See GenerateContent.targets -->
<PackageVersionVariableReference Include="$(RepoRoot)src\Components\Components\src\Microsoft.AspNetCore.Components.csproj" />
<PackageVersionVariableReference Include="$(RepoRoot)src\Components\Web\src\Microsoft.AspNetCore.Components.Web.csproj" />
<PackageVersionVariableReference Include="$(RepoRoot)src\Identity\EntityFrameworkCore\src\Microsoft.AspNetCore.Identity.EntityFrameworkCore.csproj" />
Expand Down Expand Up @@ -59,6 +59,7 @@
<GeneratedContent Include="RazorClassLibrary-CSharp.csproj.in" OutputPath="content/RazorClassLibrary-CSharp/Company.RazorClassLibrary1.csproj" />
<GeneratedContent Include="StarterWeb-CSharp.csproj.in" OutputPath="content/StarterWeb-CSharp/Company.WebApplication1.csproj" />
<GeneratedContent Include="StarterWeb-FSharp.fsproj.in" OutputPath="content/StarterWeb-FSharp/Company.WebApplication1.fsproj" />
<GeneratedContent Include="Api-CSharp.csproj.in" OutputPath="content/Api-CSharp/Company.ApiApplication1.csproj" />
<GeneratedContent Include="WebApi-CSharp.csproj.in" OutputPath="content/WebApi-CSharp/Company.WebApplication1.csproj" />
<GeneratedContent Include="WebApi-FSharp.fsproj.in" OutputPath="content/WebApi-FSharp/Company.WebApplication1.fsproj" />
<GeneratedContent Include="Worker-CSharp.csproj.in" OutputPath="content/Worker-CSharp/Company.Application1.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"Framework": {
"longName": "framework"
},
"skipRestore": {
"longName": "no-restore",
"shortName": ""
},
"kestrelHttpPort": {
"isHidden": true
},
"iisHttpPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
},
"UseProgramMain": {
"longName": "use-program-main",
"shortName": ""
},
"NativeAot": {
"longName": "publish-native-aot",
"shortName": "aot"
}
},
"usageExamples": [
""
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "http://json.schemastore.org/ide.host",
"order": 100,
"icon": "ide/API.png",
"supportsDocker": true,
"symbolInfo": [
{
"id": "UseProgramMain",
"isVisible": true,
"persistenceScope": "shared",
"persistenceScopeName": "Microsoft"
},
{
"id": "NativeAot",
"isVisible": true
}
],
"unsupportedHosts": [
{
"id": "vs"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"author": "Microsoft",
"name": "ASP.NET Core API",
"description": "A project template for creating an ASP.NET Core API application.",
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
"symbols/Framework/description": "The target framework for the project.",
"symbols/Framework/choices/net8.0/description": "Target net8.0",
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
"symbols/NativeAot/displayName": "Enable _native AOT publish",
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
"postActions/restore/description": "Restore NuGet packages required by this project.",
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
}
Loading