Skip to content

Commit 4535ea1

Browse files
Add new "api" project template that supports native AOT (#46064)
* Added "api" project template * Add script for running "dotnet new api -aot" locally * Update Test-Template.ps1 to handle RID-specific publish output and disable TreatWarningsAsErrors
1 parent e852e90 commit 4535ea1

File tree

54 files changed

+884
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+884
-25
lines changed

Diff for: src/ProjectTemplates/Shared/ArgConstants.cs

+1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ internal static class ArgConstants
2525
public const string AadB2cInstance = "--aad-b2c-instance";
2626
public const string UseLocalDb = "-uld";
2727
public const string NoHttps = "--no-https";
28+
public const string PublishNativeAot = "--publish-native-aot";
2829
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">true</NoDefaultLaunchSettingsFile>
8+
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
9+
<ServerGarbageCollection>False</ServerGarbageCollection>
10+
<!--#if (NativeAot) -->
11+
<PublishAot>true</PublishAot>
12+
<TrimMode>full</TrimMode>
13+
<PublishIISAssets>false</PublishIISAssets>
14+
<!--#endif -->
15+
</PropertyGroup>
16+
17+
</Project>

Diff for: src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</PropertyGroup>
3131

3232
<ItemGroup>
33-
<!-- These projects product packages that the templates depend on. See GenerateContent.targets -->
33+
<!-- These projects produce packages that the templates depend on. See GenerateContent.targets -->
3434
<PackageVersionVariableReference Include="$(RepoRoot)src\Components\Components\src\Microsoft.AspNetCore.Components.csproj" />
3535
<PackageVersionVariableReference Include="$(RepoRoot)src\Components\Web\src\Microsoft.AspNetCore.Components.Web.csproj" />
3636
<PackageVersionVariableReference Include="$(RepoRoot)src\Identity\EntityFrameworkCore\src\Microsoft.AspNetCore.Identity.EntityFrameworkCore.csproj" />
@@ -59,6 +59,7 @@
5959
<GeneratedContent Include="RazorClassLibrary-CSharp.csproj.in" OutputPath="content/RazorClassLibrary-CSharp/Company.RazorClassLibrary1.csproj" />
6060
<GeneratedContent Include="StarterWeb-CSharp.csproj.in" OutputPath="content/StarterWeb-CSharp/Company.WebApplication1.csproj" />
6161
<GeneratedContent Include="StarterWeb-FSharp.fsproj.in" OutputPath="content/StarterWeb-FSharp/Company.WebApplication1.fsproj" />
62+
<GeneratedContent Include="Api-CSharp.csproj.in" OutputPath="content/Api-CSharp/Company.ApiApplication1.csproj" />
6263
<GeneratedContent Include="WebApi-CSharp.csproj.in" OutputPath="content/WebApi-CSharp/Company.WebApplication1.csproj" />
6364
<GeneratedContent Include="WebApi-FSharp.fsproj.in" OutputPath="content/WebApi-FSharp/Company.WebApplication1.fsproj" />
6465
<GeneratedContent Include="Worker-CSharp.csproj.in" OutputPath="content/Worker-CSharp/Company.Application1.csproj" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "http://json.schemastore.org/dotnetcli.host",
3+
"symbolInfo": {
4+
"Framework": {
5+
"longName": "framework"
6+
},
7+
"skipRestore": {
8+
"longName": "no-restore",
9+
"shortName": ""
10+
},
11+
"kestrelHttpPort": {
12+
"isHidden": true
13+
},
14+
"iisHttpPort": {
15+
"isHidden": true
16+
},
17+
"ExcludeLaunchSettings": {
18+
"longName": "exclude-launch-settings",
19+
"shortName": ""
20+
},
21+
"UseProgramMain": {
22+
"longName": "use-program-main",
23+
"shortName": ""
24+
},
25+
"NativeAot": {
26+
"longName": "publish-native-aot",
27+
"shortName": "aot"
28+
}
29+
},
30+
"usageExamples": [
31+
""
32+
]
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "http://json.schemastore.org/ide.host",
3+
"order": 100,
4+
"icon": "ide/API.png",
5+
"supportsDocker": true,
6+
"symbolInfo": [
7+
{
8+
"id": "UseProgramMain",
9+
"isVisible": true,
10+
"persistenceScope": "shared",
11+
"persistenceScopeName": "Microsoft"
12+
},
13+
{
14+
"id": "NativeAot",
15+
"isVisible": true
16+
}
17+
],
18+
"unsupportedHosts": [
19+
{
20+
"id": "vs"
21+
}
22+
]
23+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "ASP.NET Core API",
4+
"description": "A project template for creating an ASP.NET Core API application.",
5+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
6+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
7+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
8+
"symbols/Framework/description": "The target framework for the project.",
9+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
10+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
11+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
12+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
13+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
14+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
15+
"postActions/restore/description": "Restore NuGet packages required by this project.",
16+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
17+
}

0 commit comments

Comments
 (0)