Skip to content

Commit

Permalink
Add new "api" project template that supports native AOT (#46064)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DamianEdwards authored Jan 13, 2023
1 parent e852e90 commit 4535ea1
Show file tree
Hide file tree
Showing 54 changed files with 884 additions and 25 deletions.
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>
<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

0 comments on commit 4535ea1

Please sign in to comment.