Skip to content

Commit 1b7971d

Browse files
authored
Add error for incorrect aot publish (#46070)
For the following project (note it uses the nativeaot runtime pack): ```xml <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net10.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <PublishAot>true</PublishAot> <PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack> <SelfContained>true</SelfContained> </PropertyGroup> </Project> ``` This command produces an error: ``` > dotnet build -t:Publish Restore complete (0.6s) You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy project failed with 2 error(s) (0.7s) → bin/Debug/net10.0/linux-x64/project.dll EXEC : error : Failed to load assembly 'System.Private.StackTraceMetadata' .nuget/packages/microsoft.dotnet.ilcompiler/10.0.0-alpha.1.25052.4/build/Microsoft.NETCore.Native.targets(316,5): error MSB3073: The command "".nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/10.0.0-alpha.1.25052.4/tools/ilc" @"obj/Debug/net10.0/linux-x64/native/project.ilc.rsp"" exited with code 1. ``` This is due to ILC being passed assemblies from the coreclr runtime pack (which doesn't include S.P.StackTraceMetadata) instead of the nativeaot framework assemblies. This adds a better error message for this unsupported scenario.
1 parent 1a0425f commit 1b7971d

File tree

15 files changed

+76
-2
lines changed

15 files changed

+76
-2
lines changed

src/Tasks/Common/Resources/Strings.resx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,10 +977,13 @@ You may need to build the project on another operating system or architecture, o
977977
<value>NETSDK1223: Targeting .NET 9.0 or higher in Visual Studio 2022 17.11 is not supported.</value>
978978
<comment>{StrBegins="NETSDK1223: "}</comment>
979979
</data>
980-
<!-- The latest message added is Net9NotCompatibleWithDev1711. Please update this value with each PR to catch parallel PRs both adding a new message -->
981980
<data name="AspNetCorePackUnsupportedTargetFramework" xml:space="preserve">
982981
<value>NETSDK1224: ASP.NET Core framework assets are not supported for the target framework.</value>
983982
<comment>{StrBegins="NETSDK1224: "}</comment>
984983
</data>
985-
<!-- The latest message added is AspNetCorePackUnsupportedTargetFramework. Please update this value with each PR to catch parallel PRs both adding a new message -->
984+
<!-- The latest message added is NativeCompilationRequiresPublishing. Please update this value with each PR to catch parallel PRs both adding a new message -->
985+
<data name="NativeCompilationRequiresPublishing" xml:space="preserve">
986+
<value>NETSDK1225: Native compilation is not supported when invoking the Publish target directly. Try running dotnet publish.</value>
987+
<comment>{StrBegins="NETSDK1225: "}</comment>
988+
</data>
986989
</root>

src/Tasks/Common/Resources/xlf/Strings.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.ko.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.pl.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)