Skip to content
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

Add aot option to gRPC template #46462

Merged
merged 7 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<!--#if (NativeAot) -->
<PublishAot>true</PublishAot>
<TrimMode>full</TrimMode>
<PublishIISAssets>false</PublishIISAssets>
<!--#endif -->
JamesNK marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"UseProgramMain": {
"longName": "use-program-main",
"shortName": ""
},
"NativeAot": {
"longName": "publish-native-aot",
"shortName": "aot"
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"isVisible": true,
"persistenceScope": "shared",
"persistenceScopeName": "Microsoft"
},
{
"id": "NativeAot",
"isVisible": true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 »"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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' を実行する"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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' 실행"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
12 changes: 12 additions & 0 deletions src/ProjectTemplates/scripts/Run-GrpcNativeAot-Locally.ps1
Original file line number Diff line number Diff line change
@@ -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
36 changes: 31 additions & 5 deletions src/ProjectTemplates/test/Templates.Tests/GrpcTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Copy link
Member

Choose a reason for hiding this comment

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

The linked issue was closed 3 years ago. Is this "skip" really necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll investigate in a follow up PR

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" };
Expand Down