Skip to content

Commit d10b354

Browse files
Add -aot parameter to the console template (#31739)
This is similar to the `api` template in ASP.NET that also allows `-aot` (or `--publish-native-aot`) option (see dotnet/aspnetcore#46064). We set similar properties: * `<PublishAot>true</PublishAot>` (this is the obvious one) * `<InvariantGlobalization>true</InvariantGlobalization>` to get rid of ICU dependency on Linux and make the hello world executable ~20% smaller in general, even outside Linux. * a commented out `<StripSymbols>true</StripSymbols>`. This is for discoverability. We default this to `false` due to platform conventions, but many users would be fine setting this to `true`. `true` is the .NET convention. I took the string from ASP.NET. I could have also copied the localized strings but I guess it's better to not step on the toes of the localization team.
1 parent 3eafa1f commit d10b354

File tree

46 files changed

+229
-0
lines changed

Some content is hidden

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

46 files changed

+229
-0
lines changed

src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.TemplateCommand_GetAllSuggestions.verified.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ Default: false
8181
InsertText: --output,
8282
Detail: Location to place the generated output.
8383
},
84+
{
85+
Label: --publish-native-aot,
86+
Kind: Keyword,
87+
SortText: --publish-native-aot,
88+
InsertText: --publish-native-aot,
89+
Detail:
90+
Whether to enable the project for publishing as native AOT.
91+
Type: bool
92+
Default: false
93+
94+
},
8495
{
8596
Label: --type,
8697
Kind: Keyword,
@@ -106,6 +117,17 @@ Default: false
106117
InsertText: -?,
107118
Detail: Show help and usage information
108119
},
120+
{
121+
Label: -aot,
122+
Kind: Keyword,
123+
SortText: -aot,
124+
InsertText: -aot,
125+
Detail:
126+
Whether to enable the project for publishing as native AOT.
127+
Type: bool
128+
Default: false
129+
130+
},
109131
{
110132
Label: -f,
111133
Kind: Keyword,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// See https://aka.ms/new-console-template for more information
2+
Console.WriteLine("Hello, World!");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>%FRAMEWORK%</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<PublishAot>true</PublishAot>
9+
<InvariantGlobalization>true</InvariantGlobalization>
10+
11+
<!-- Uncomment below line to make native publish outputs a lot smaller on Linux and macOS -->
12+
<!-- <StripSymbols>true</StripSymbols> -->
13+
</PropertyGroup>
14+
15+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The template "Console App" was created successfully.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// See https://aka.ms/new-console-template for more information
2+
Console.WriteLine("Hello, World!");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>%FRAMEWORK%</TargetFramework>
6+
<RootNamespace>vb_console</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<PublishAot>true</PublishAot>
10+
<InvariantGlobalization>true</InvariantGlobalization>
11+
12+
<!-- Uncomment below line to make native publish outputs a lot smaller on Linux and macOS -->
13+
<!-- <StripSymbols>true</StripSymbols> -->
14+
</PropertyGroup>
15+
16+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The template "Console App" was created successfully.

src/Tests/dotnet-new.Tests/Approvals/DotnetNewHelpTests.CanShowHelpForTemplate_MatchOnNonChoiceParam.verified.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Template options:
3030
--use-program-main Whether to generate an explicit Program class and Main method instead of top-level statements.
3131
Type: bool
3232
Default: false
33+
-aot, --publish-native-aot Whether to enable the project for publishing as native AOT.
34+
Type: bool
35+
Default: false
3336

3437
To see help for other template languages (F#, VB), use --language option:
3538
dotnet new console -h --language F#

src/Tests/dotnet-new.Tests/Approvals/DotnetNewHelpTests.CanShowHelpForTemplate_console.verified.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Template options:
3030
--use-program-main Whether to generate an explicit Program class and Main method instead of top-level statements.
3131
Type: bool
3232
Default: false
33+
-aot, --publish-native-aot Whether to enable the project for publishing as native AOT.
34+
Type: bool
35+
Default: false
3336

3437
To see help for other template languages (F#, VB), use --language option:
3538
dotnet new console -h --language F#

src/Tests/dotnet-new.Tests/CommonTemplatesTests.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,66 @@ public void NuGetConfigPermissions()
164164
Directory.Delete(workingDir, true);
165165
}
166166

167+
[Theory]
168+
[InlineData(new object[] { "console", "C#" })]
169+
[InlineData(new object[] { "console", "VB" })]
170+
public async void AotVariants(string name, string language)
171+
{
172+
// "net8.0";
173+
string currentDefaultFramework = $"net{Environment.Version.Major}.{Environment.Version.Minor}";
174+
175+
string workingDir = CreateTemporaryFolder(folderName: $"{name}-{language}");
176+
string outputDir = "MyProject";
177+
string projName = name;
178+
179+
List<string> args = new() { "-o", outputDir };
180+
// VB build would fail for name 'console' (root namespace would conflict with BCL namespace)
181+
if (language.Equals("VB") == true && name.Equals("console"))
182+
{
183+
projName = "vb-console";
184+
args.Add("-n");
185+
args.Add(projName);
186+
}
187+
args.Add("-aot");
188+
189+
// Do not bother restoring. This would need to restore the AOT compiler.
190+
// We would need a nuget.config for that and it's a waste of time anyway.
191+
args.Add("--no-restore");
192+
193+
string extension = language == "VB" ? "vbproj" : "csproj";
194+
195+
string projectDir = Path.Combine(workingDir, outputDir);
196+
string finalProjectName = Path.Combine(projectDir, $"{projName}.{extension}");
197+
198+
Dictionary<string, string> environmentUnderTest = new() { ["DOTNET_NOLOGO"] = false.ToString() };
199+
TestContext.Current.AddTestEnvironmentVariables(environmentUnderTest);
200+
201+
TemplateVerifierOptions options = new TemplateVerifierOptions(templateName: name)
202+
{
203+
TemplateSpecificArgs = args,
204+
SnapshotsDirectory = "Approvals",
205+
OutputDirectory = workingDir,
206+
SettingsDirectory = _fixture.HomeDirectory,
207+
VerifyCommandOutput = true,
208+
DoNotPrependTemplateNameToScenarioName = false,
209+
DoNotAppendTemplateArgsToScenarioName = true,
210+
ScenarioName = language.Replace('#', 's').ToLower(),
211+
VerificationExcludePatterns = new[] { "*/stderr.txt", "*\\stderr.txt" },
212+
DotnetExecutablePath = TestContext.Current.ToolsetUnderTest.DotNetHostPath,
213+
}
214+
.WithCustomEnvironment(environmentUnderTest)
215+
.WithCustomScrubbers(
216+
ScrubbersDefinition.Empty
217+
.AddScrubber(sb => sb.Replace($"<TargetFramework>{currentDefaultFramework}</TargetFramework>", "<TargetFramework>%FRAMEWORK%</TargetFramework>"))
218+
.AddScrubber(sb => sb.Replace(finalProjectName, "%PROJECT_PATH%").UnixifyDirSeparators().ScrubByRegex("(^ Restored .* \\()(.*)(\\)\\.)", "$1%DURATION%$3", RegexOptions.Multiline), "txt")
219+
);
220+
221+
VerificationEngine engine = new VerificationEngine(_logger);
222+
await engine.Execute(options).ConfigureAwait(false);
223+
224+
Directory.Delete(workingDir, true);
225+
}
226+
167227
#region Project templates language features tests
168228

169229
/// <summary>

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
"UseProgramMain": {
2121
"longName": "use-program-main",
2222
"shortName": ""
23+
},
24+
"NativeAot": {
25+
"longName": "publish-native-aot",
26+
"shortName": "aot"
2327
}
2428
},
2529
"usageExamples": [

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/ide.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"isVisible": true,
1414
"PersistenceScope": "Shared",
1515
"PersistenceScopeName": "Microsoft"
16+
},
17+
{
18+
"id": "NativeAot",
19+
"isVisible": true
1620
}
1721
]
1822
}

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.cs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Přeskočit obnovení",
1515
"symbols/UseProgramMain/description": "Určuje, jestli se má místo příkazů nejvyšší úrovně generovat explicitní třída Program a metoda Main.",
1616
"symbols/UseProgramMain/displayName": "Nepoužívat _příkazy nejvyšší úrovně",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.",
1820
"postActions/restore/manualInstructions/default/text": "Spustit dotnet restore",
1921
"postActions/open-file/description": "Otevře Program.cs v editoru."

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Wiederherstellung überspringen",
1515
"symbols/UseProgramMain/description": "Gibt an, ob anstelle von Anweisungen der obersten Ebene eine explizite Programmklasse und eine Main-Methode generiert werden soll.",
1616
"symbols/UseProgramMain/displayName": "Keine Anweisungen _der obersten Ebene verwenden",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "„NuGet-Pakete“ wiederherstellen, die für dieses Projekt erforderlich sind.",
1820
"postActions/restore/manualInstructions/default/text": "„dotnet restore“ ausführen",
1921
"postActions/open-file/description": "Öffnet „Program.cs“ im Editor."

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
1616
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
1717
"_symbols/UseProgramMain/displayName.comment": "Use '_' as accelerator key when translating.",
18+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
19+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
20+
"_symbols/NativeAot/displayName.comment": "Use '_' as accelerator key when translating.",
1821
"postActions/restore/description": "Restore NuGet packages required by this project.",
1922
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'",
2023
"postActions/open-file/description": "Opens Program.cs in the editor"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.es.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Omitir restauración",
1515
"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.",
1616
"symbols/UseProgramMain/displayName": "No usar instrucciones de _nivel superior",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Restaure los paquetes NuGet necesarios para este proyecto.",
1820
"postActions/restore/manualInstructions/default/text": "Ejecutar \"dotnet restore\"",
1921
"postActions/open-file/description": "Abre Program.cs en el editor"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Ignorer la restauration",
1515
"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.",
1616
"symbols/UseProgramMain/displayName": "N’utilisez pas _d’instructions de niveau supérieur.",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Restaurez les packages NuGet requis par ce projet.",
1820
"postActions/restore/manualInstructions/default/text": "Exécuter « dotnet restore »",
1921
"postActions/open-file/description": "Ouvre Program.cs dans l’éditeur"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.it.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Salta ripristino",
1515
"symbols/UseProgramMain/description": "Indica se generare una classe Program esplicita e un metodo Main anziché istruzioni di primo livello.",
1616
"symbols/UseProgramMain/displayName": "Non usare_istruzioni di primo livello",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Ripristina i pacchetti NuGet richiesti da questo progetto.",
1820
"postActions/restore/manualInstructions/default/text": "Esegui 'dotnet restore'",
1921
"postActions/open-file/description": "Apre Program.cs nell'editor"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.ja.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "復元のスキップ",
1515
"symbols/UseProgramMain/description": "最上位レベルのステートメントではなく、明示的な Program クラスと Main メソッドを生成するかどうか。",
1616
"symbols/UseProgramMain/displayName": "最上位レベルのステートメントを使用しない(_T)",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "このプロジェクトに必要な NuGet パッケージを復元します。",
1820
"postActions/restore/manualInstructions/default/text": "'dotnet restore' を実行する",
1921
"postActions/open-file/description": "エディターで Program.cs を開く"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.ko.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "복원 건너뛰기",
1515
"symbols/UseProgramMain/description": "최상위 문 대신 명시적 Program 클래스 및 Main 메서드를 생성할지 여부입니다.",
1616
"symbols/UseProgramMain/displayName": "최상위 문 사용 안 함(_T)",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "이 프로젝트에 필요한 NuGet 패키지를 복원합니다.",
1820
"postActions/restore/manualInstructions/default/text": "'dotnet restore' 실행",
1921
"postActions/open-file/description": "편집기에서 Program.cs를 엽니다"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.pl.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Pomiń przywracanie",
1515
"symbols/UseProgramMain/description": "Określa, czy wygenerować jawną klasę Program i metodę Main zamiast instrukcji najwyższego poziomu.",
1616
"symbols/UseProgramMain/displayName": "Nie używaj ins_trukcji najwyższego poziomu",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Przywróć pakiety NuGet wymagane przez ten projekt.",
1820
"postActions/restore/manualInstructions/default/text": "Uruchom polecenie \"dotnet restore\"",
1921
"postActions/open-file/description": "Otwiera plik Program.cs w edytorze"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.pt-BR.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Ignorar restauração",
1515
"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.",
1616
"symbols/UseProgramMain/displayName": "Não use ins_truções de nível superior",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Restaure os pacotes NuGet exigidos por este projeto.",
1820
"postActions/restore/manualInstructions/default/text": "Executa 'dotnet restore'",
1921
"postActions/open-file/description": "Abre Program.cs no editor"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.ru.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Пропустить восстановление",
1515
"symbols/UseProgramMain/description": "Следует ли создавать явный класс Program и метод Main вместо операторов верхнего уровня.",
1616
"symbols/UseProgramMain/displayName": "Не использовать _операторы верхнего уровня",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Восстановление пакетов NuGet, необходимых для этого проекта.",
1820
"postActions/restore/manualInstructions/default/text": "Выполнить команду \"dotnet restore\"",
1921
"postActions/open-file/description": "Открывает файл Program.cs в редакторе"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.tr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "Geri yüklemeyi atla",
1515
"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.",
1616
"symbols/UseProgramMain/displayName": "_Üst düzey deyimler kullanmayın",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "Bu projenin gerektirdiği NuGet paketlerini geri yükleyin.",
1820
"postActions/restore/manualInstructions/default/text": "'dotnet restore' çalıştır",
1921
"postActions/open-file/description": "Düzenleyicide Program.cs’yi açar"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.zh-Hans.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "跳过还原",
1515
"symbols/UseProgramMain/description": "是否生成显式程序类和主方法,而不是顶级语句。",
1616
"symbols/UseProgramMain/displayName": "不使用顶级语句(_T)",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "还原此项目所需的 NuGet 包。",
1820
"postActions/restore/manualInstructions/default/text": "运行 \"dotnet restore\"",
1921
"postActions/open-file/description": "在编辑器中打开 Program.cs"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/localize/templatestrings.zh-Hant.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"symbols/skipRestore/displayName": "略過還原",
1515
"symbols/UseProgramMain/description": "是否要產生明確的 Program 類別和 Main 方法,而非最上層語句。",
1616
"symbols/UseProgramMain/displayName": "不要使用最上層陳述式(_T)",
17+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
18+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1719
"postActions/restore/description": "還原此專案所需的 NuGet 套件。",
1820
"postActions/restore/manualInstructions/default/text": "執行 'dotnet restore'",
1921
"postActions/open-file/description": "在編輯器中開啟 Program.cs"

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/.template.config/template.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868
"description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
6969
"displayName": "Do not use _top-level statements"
7070
},
71+
"NativeAot" : {
72+
"type": "parameter",
73+
"datatype": "bool",
74+
"defaultValue": "false",
75+
"displayName": "Enable _native AOT publish",
76+
"description": "Whether to enable the project for publishing as native AOT."
77+
},
7178
"csharp9orOlder": {
7279
"type": "generated",
7380
"generator": "regexMatch",

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-CSharp/Company.ConsoleApplication1.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
<LangVersion Condition="'$(langVersion)' != ''">$(ProjectLanguageVersion)</LangVersion>
99
<ImplicitUsings Condition="'$(csharpFeature_ImplicitUsings)' == 'true'">enable</ImplicitUsings>
1010
<Nullable Condition="'$(csharpFeature_Nullable)' == 'true'">enable</Nullable>
11+
<!--#if (NativeAot) -->
12+
<PublishAot>true</PublishAot>
13+
<InvariantGlobalization>true</InvariantGlobalization>
14+
15+
<!-- Uncomment below line to make native publish outputs a lot smaller on Linux and macOS -->
16+
<!-- <StripSymbols>true</StripSymbols> -->
17+
<!--#endif -->
1118
</PropertyGroup>
1219

1320
</Project>

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-VisualBasic/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"langVersion": {
1717
"longName": "langVersion",
1818
"shortName": ""
19+
},
20+
"NativeAot": {
21+
"longName": "publish-native-aot",
22+
"shortName": "aot"
1923
}
2024
},
2125
"usageExamples": [

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-VisualBasic/.template.config/ide.host.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
"add": [],
77
"remove": [ "Common" ]
88
}
9+
],
10+
"symbolInfo": [
11+
{
12+
"id": "NativeAot",
13+
"isVisible": true
14+
}
915
]
1016
}

template_feed/Microsoft.DotNet.Common.ProjectTemplates.8.0/content/ConsoleApplication-VisualBasic/.template.config/localize/templatestrings.cs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"symbols/langVersion/displayName": "Verze jazyka",
1313
"symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.",
1414
"symbols/skipRestore/displayName": "Přeskočit obnovení",
15+
"symbols/NativeAot/description": "Whether to enable the project for publishing as native AOT.",
16+
"symbols/NativeAot/displayName": "Enable _native AOT publish",
1517
"postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.",
1618
"postActions/restore/manualInstructions/default/text": "Spustit dotnet restore",
1719
"postActions/open-file/description": "Otevře Program.vb v editoru."

0 commit comments

Comments
 (0)