From e3d17f5c3435c3b280efb81cc240c4bcefd77993 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 8 Feb 2023 06:01:31 +0800 Subject: [PATCH] Add aot option to gRPC template (#46462) --- .../GrpcService-CSharp.csproj.in | 3 ++ .../.template.config/dotnetcli.host.json | 4 +++ .../.template.config/ide.host.json | 4 +++ .../localize/templatestrings.cs.json | 2 ++ .../localize/templatestrings.de.json | 2 ++ .../localize/templatestrings.en.json | 2 ++ .../localize/templatestrings.es.json | 2 ++ .../localize/templatestrings.fr.json | 2 ++ .../localize/templatestrings.it.json | 2 ++ .../localize/templatestrings.ja.json | 2 ++ .../localize/templatestrings.ko.json | 2 ++ .../localize/templatestrings.pl.json | 2 ++ .../localize/templatestrings.pt-BR.json | 2 ++ .../localize/templatestrings.ru.json | 2 ++ .../localize/templatestrings.tr.json | 2 ++ .../localize/templatestrings.zh-Hans.json | 2 ++ .../localize/templatestrings.zh-Hant.json | 2 ++ .../.template.config/template.json | 7 ++++ .../scripts/Run-GrpcNativeAot-Locally.ps1 | 12 +++++++ .../test/Templates.Tests/GrpcTemplateTest.cs | 36 ++++++++++++++++--- 20 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 src/ProjectTemplates/scripts/Run-GrpcNativeAot-Locally.ps1 diff --git a/src/ProjectTemplates/Web.ProjectTemplates/GrpcService-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/GrpcService-CSharp.csproj.in index 2aeeafb11873..3554a4084796 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/GrpcService-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/GrpcService-CSharp.csproj.in @@ -4,6 +4,9 @@ ${DefaultNetCoreTargetFramework} enable enable + + true + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/dotnetcli.host.json index 7e579691bb66..0dbb71595eb9 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/dotnetcli.host.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/dotnetcli.host.json @@ -21,6 +21,10 @@ "UseProgramMain": { "longName": "use-program-main", "shortName": "" + }, + "NativeAot": { + "longName": "publish-native-aot", + "shortName": "aot" } }, "usageExamples": [ diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/ide.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/ide.host.json index 77451b983c08..35ce47e49ad9 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/ide.host.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/ide.host.json @@ -9,6 +9,10 @@ "isVisible": true, "persistenceScope": "shared", "persistenceScopeName": "Microsoft" + }, + { + "id": "NativeAot", + "isVisible": true } ] } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.cs.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.cs.json index e72d1047ebb3..454b4d0fd6b5 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.cs.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.cs.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Číslo portu, který se má použít pro koncový bod HTTPS v souboru launchSettings.json. Tato možnost se dá použít jenom v případě, že se nepoužije parametr no-https (no-https se bude ignorovat, pokud se použije IndividualAuth nebo OrganizationalAuth).", "symbols/UseProgramMain/displayName": "Nepoužívat _příkazy nejvyšší úrovně", "symbols/UseProgramMain/description": "Určuje, jestli se má místo příkazů nejvyšší úrovně generovat explicitní třída Program a metoda Main.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.", "postActions/restore/manualInstructions/default/text": "Spustit dotnet restore" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.de.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.de.json index 4d3f2e9010e1..a0b3cbf57f40 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.de.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.de.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Portnummer, die für den HTTPS Endpunkt in launchSettings.json verwendet werden soll. Diese Option ist nur anwendbar, wenn der Parameter no-https nicht verwendet wird (no-https wird ignoriert, wenn entweder IndividualAuth oder OrganizationalAuth verwendet wird).", "symbols/UseProgramMain/displayName": "Keine Anweisungen_der obersten Ebene verwenden", "symbols/UseProgramMain/description": "Gibt an, ob anstelle von Anweisungen der obersten Ebene eine explizite Programmklasse und eine Main-Methode generiert werden soll.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "„NuGet-Pakete“ wiederherstellen, die für dieses Projekt erforderlich sind.", "postActions/restore/manualInstructions/default/text": "„dotnet restore“ ausführen" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.en.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.en.json index e31f3549cca5..4bae5a47d735 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.en.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.en.json @@ -12,6 +12,8 @@ "symbols/UseProgramMain/displayName": "Do not use _top-level statements", "_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.", "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'" } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.es.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.es.json index 979f51a69106..b3aaa8d57271 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.es.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.es.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Número de puerto que se va a usar para el punto de conexión HTTPS en launchSettings.json. Esta opción solo es aplicable cuando no se usa el parámetro no-https (no-https se omitirá si se usa IndividualAuth o OrganizationalAuth).", "symbols/UseProgramMain/displayName": "No usar instrucciones de _nivel superior", "symbols/UseProgramMain/description": "Indica si se debe generar una clase Program explícita y un método Main en lugar de instrucciones de nivel superior.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Restaure los paquetes NuGet necesarios para este proyecto.", "postActions/restore/manualInstructions/default/text": "Ejecutar \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.fr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.fr.json index 0b9f0dde7695..ee59a550b133 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.fr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.fr.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Numéro de port à utiliser pour le point de terminaison HTTPS dans launchSettings.json. Cette option s’applique uniquement lorsque le paramètre no-https n’est pas utilisé (no-https sera ignoré si IndividualAuth ou OrganizationalAuth est utilisé).", "symbols/UseProgramMain/displayName": "N’utilisez pas _d’instructions de niveau supérieur.", "symbols/UseProgramMain/description": "Indique s’il faut générer une classe Programme explicite et une méthode Main au lieu d’instructions de niveau supérieur.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Restaurez les packages NuGet requis par ce projet.", "postActions/restore/manualInstructions/default/text": "Exécuter « dotnet restore »" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.it.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.it.json index 5b7d2c548f49..1ab207e80526 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.it.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.it.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Numero di porta da usare per l'endpoint HTTPS in launchSettings.json. Questa opzione è applicabile solo quando il parametro no-https non viene usato (no-https verrà ignorato se si usa IndividualAuth o OrganizationalAuth).", "symbols/UseProgramMain/displayName": "Non usare_istruzioni di primo livello", "symbols/UseProgramMain/description": "Indica se generare una classe Program esplicita e un metodo Main anziché istruzioni di primo livello.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Ripristina i pacchetti NuGet richiesti da questo progetto.", "postActions/restore/manualInstructions/default/text": "Esegui 'dotnet restore'" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ja.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ja.json index b4705b5785fe..e4a1b805f629 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ja.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ja.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "launchSettings.json で HTTPS エンドポイントに使用するポート番号。このオプションは、HTTPS 以外のパラメーターが使用されていない場合にのみ適用されます (IndividualAuth または OrganizationalAuth が使用されている場合は、HTTPS 以外は無視されます)。", "symbols/UseProgramMain/displayName": "最上位レベルのステートメントを使用しない(_T)", "symbols/UseProgramMain/description": "最上位レベルのステートメントではなく、明示的な Program クラスと Main メソッドを生成するかどうか。", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "このプロジェクトに必要な NuGet パッケージを復元します。", "postActions/restore/manualInstructions/default/text": "'dotnet restore' を実行する" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ko.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ko.json index cb16abe2070a..4d0c3e72a69f 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ko.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ko.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "launchSettings.json의 HTTPS 엔드포인트에 사용할 포트 번호입니다. 이 옵션은 매개 변수 no-https가 사용되지 않은 경우에만 적용됩니다(IndividualAuth 또는 OrganizationalAuth가 사용되는 경우 no-https는 무시됨).", "symbols/UseProgramMain/displayName": "최상위 문 사용 안 함(_T)", "symbols/UseProgramMain/description": "최상위 문 대신 명시적 Program 클래스 및 Main 메서드를 생성할지 여부입니다.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "이 프로젝트에 필요한 NuGet 패키지를 복원합니다.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' 실행" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pl.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pl.json index edd50f6fd580..6411f8649608 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pl.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pl.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Numer portu do użycia dla punktu końcowego HTTPS w pliku launchSettings.json. Ta opcja ma zastosowanie tylko wtedy, gdy parametr no-https nie jest używany (parametr no-https zostanie zignorowany, jeśli zostanie użyte uwierzytelnianie IndividualAuth lub OrganizationalAuth).", "symbols/UseProgramMain/displayName": "Nie używaj ins_trukcji najwyższego poziomu", "symbols/UseProgramMain/description": "Określa, czy wygenerować jawną klasę Program i metodę Main zamiast instrukcji najwyższego poziomu.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Przywróć pakiety NuGet wymagane przez ten projekt.", "postActions/restore/manualInstructions/default/text": "Uruchom polecenie \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pt-BR.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pt-BR.json index f00ef8932070..fa8c7dfbd0f8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Número da porta a ser usada para o ponto de extremidade HTTPS em launchSettings.json. Essa opção só é aplicável quando o parâmetro no-https não é usado (no-https será ignorado se IndividualAuth ou OrganizationalAuth for usado).", "symbols/UseProgramMain/displayName": "Não use ins_truções de nível superior", "symbols/UseProgramMain/description": "Se deve gerar uma classe de Programa explícita e um método principal em vez de instruções de nível superior.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Restaure os pacotes NuGet exigidos por este projeto.", "postActions/restore/manualInstructions/default/text": "Executar 'dotnet restore'" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ru.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ru.json index 1319ce10088b..c369161e0c91 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ru.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.ru.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "Номер порта, используемый для конечной точки HTTPS в launchSettings.json. Этот параметр применим только в том случае, если no-https не используется (при использовании IndividualAuth или OrganizationalAuth no-https игнорируется).", "symbols/UseProgramMain/displayName": "Не использовать _операторы верхнего уровня", "symbols/UseProgramMain/description": "Следует ли создавать явный класс Program и метод Main вместо операторов верхнего уровня.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Восстановление пакетов NuGet, необходимых для этого проекта.", "postActions/restore/manualInstructions/default/text": "Выполнить команду \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.tr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.tr.json index 8079161e0baa..acf42a4d9505 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.tr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.tr.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "launchSettings.json içinde HTTPS uç noktası için kullanılacak bağlantı noktası numarası. Bu seçenek yalnızca no-https parametresi kullanılmazsa uygulanabilir (IndividualAuth veya OrganizationalAuth kullanılırsa no-https yoksayılır).", "symbols/UseProgramMain/displayName": "_Üst düzey deyimler kullanmayın", "symbols/UseProgramMain/description": "Üst düzey deyimler yerine açık bir Program sınıfı ve Ana yöntem oluşturup oluşturulmayacağını belirtir.", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "Bu projenin gerektirdiği NuGet paketlerini geri yükleyin.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' çalıştır" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hans.json index 6226b45c1677..987c96b1170e 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "要用于 launchSettings.json 中 HTTPS 终结点的端口号。仅当不使用参数 no-https 时,此选项才适用(如果使用 IndividualAuth 或 OrganizationalAuth,则将忽略 no-https)。", "symbols/UseProgramMain/displayName": "不使用顶级语句(_T)", "symbols/UseProgramMain/description": "是否生成显式程序类和主方法,而不是顶级语句。", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "还原此项目所需的 NuGet 包。", "postActions/restore/manualInstructions/default/text": "运行 \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hant.json index 587c55d71e3a..89cb0abc981a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -10,6 +10,8 @@ "symbols/kestrelHttpsPort/description": "launchSettings.json 中 HTTPS 端點要使用的連接埠號碼。只有在未使用參數 no-https 時,才適用此選項 (如果使用 IndividualAuth 或 OrganizationalAuth,則會忽略 no-https)。", "symbols/UseProgramMain/displayName": "不要使用最上層陳述式(_T)", "symbols/UseProgramMain/description": "是否要產生明確的 Program 類別和 Main 方法,而非最上層語句。", + "symbols/NativeAot/displayName": "Enable _native AOT publish", + "symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.", "postActions/restore/description": "還原此專案所需的 NuGet 套件。", "postActions/restore/manualInstructions/default/text": "執行 'dotnet restore'" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/template.json b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/template.json index e6257aeab828..38b64f2c14a3 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/.template.config/template.json @@ -124,6 +124,13 @@ "defaultValue": "false", "displayName": "Do not use _top-level statements", "description": "Whether to generate an explicit Program class and Main method instead of top-level statements." + }, + "NativeAot" : { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "displayName": "Enable _native AOT publish", + "description": "Whether to enable the project for publishing as native AOT." } }, "primaryOutputs": [ diff --git a/src/ProjectTemplates/scripts/Run-GrpcNativeAot-Locally.ps1 b/src/ProjectTemplates/scripts/Run-GrpcNativeAot-Locally.ps1 new file mode 100644 index 000000000000..f017eacafc8d --- /dev/null +++ b/src/ProjectTemplates/scripts/Run-GrpcNativeAot-Locally.ps1 @@ -0,0 +1,12 @@ +#!/usr/bin/env pwsh +#requires -version 4 + +[CmdletBinding(PositionalBinding = $false)] +param() + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +. $PSScriptRoot\Test-Template.ps1 + +Test-Template "grpc" "grpc -aot" "Microsoft.DotNet.Web.ProjectTemplates.8.0.8.0.0-dev.nupkg" $false diff --git a/src/ProjectTemplates/test/Templates.Tests/GrpcTemplateTest.cs b/src/ProjectTemplates/test/Templates.Tests/GrpcTemplateTest.cs index 8401c39f0a45..86df38b1c8f9 100644 --- a/src/ProjectTemplates/test/Templates.Tests/GrpcTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Tests/GrpcTemplateTest.cs @@ -34,16 +34,42 @@ public ITestOutputHelper Output } } - [ConditionalTheory] + [ConditionalFact] [SkipOnHelix("Not supported queues", Queues = "windows.11.arm64.open;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] [SkipOnAlpine("https://github.com/grpc/grpc/issues/18338")] - [InlineData(true)] - [InlineData(false)] - public async Task GrpcTemplate(bool useProgramMain) + public async Task GrpcTemplate() + { + await GrpcTemplateCore(); + } + + [ConditionalFact(Skip = "Unskip when there are no more build or publish warnings for native AOT.")] + [SkipOnHelix("Not supported queues", Queues = "windows.11.arm64.open;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] + [SkipOnAlpine("https://github.com/grpc/grpc/issues/18338")] + public async Task GrpcTemplateNativeAot() + { + await GrpcTemplateCore(args: new[] { ArgConstants.PublishNativeAot }); + } + + [ConditionalFact] + [SkipOnHelix("Not supported queues", Queues = "windows.11.arm64.open;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] + [SkipOnAlpine("https://github.com/grpc/grpc/issues/18338")] + public async Task GrpcTemplateProgramMain() + { + await GrpcTemplateCore(args: new[] { ArgConstants.UseProgramMain }); + } + + [ConditionalFact(Skip = "Unskip when there are no more build or publish warnings for native AOT.")] + [SkipOnHelix("Not supported queues", Queues = "windows.11.arm64.open;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] + [SkipOnAlpine("https://github.com/grpc/grpc/issues/18338")] + public async Task GrpcTemplateProgramMainNativeAot() + { + await GrpcTemplateCore(args: new[] { ArgConstants.UseProgramMain, ArgConstants.PublishNativeAot }); + } + + private async Task GrpcTemplateCore(string[] args = null) { var project = await ProjectFactory.CreateProject(Output); - var args = useProgramMain ? new[] { ArgConstants.UseProgramMain } : null; await project.RunDotNetNewAsync("grpc", args: args); var expectedLaunchProfileNames = new[] { "http", "https" };