I'm trying to build a command line tool with Spectre.Console.Cli and .NET NativeAOT enabled in .NET 7 (by <PublishAot>true</PublishAot> in csproj). But when I publish this project I get the following warnings:
MSBuild version 17.4.1+9a89d02ff for .NET
正在确定要还原的项目…
所有项目均是最新的,无法还原。
RenameX -> D:\Code\RenameX\RenameX\bin\Release\net7.0\win-x64\renx.dll
Generating native code
C:\Users\b1acksoil\.nuget\packages\spectre.console.cli\0.46.1-preview.0.6\lib\net7.0\Spectre.Console.Cli.dll
: warning IL2104: Assembly 'Spectre.Console.Cli' produced trim warnings. For more information see https://aka
.ms/dotnet-illink/libraries [D:\Code\RenameX\RenameX\RenameX.csproj]
C:\Users\b1acksoil\.nuget\packages\spectre.console.cli\0.46.1-preview.0.6\lib\net7.0\Spectre.Console.Cli.dll
: warning IL3053: Assembly 'Spectre.Console.Cli' produced AOT analysis warnings. [D:\Code\RenameX\RenameX\Ren
ameX.csproj]
C:\Users\b1acksoil\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\7.0.2\framework\System.Private
.Xml.dll : warning IL3053: Assembly 'System.Private.Xml' produced AOT analysis warnings. [D:\Code\RenameX\Ren
ameX\RenameX.csproj]
C:\Users\b1acksoil\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\7.0.2\framework\System.Net.Htt
p.dll : warning IL3053: Assembly 'System.Net.Http' produced AOT analysis warnings. [D:\Code\RenameX\RenameX\R
enameX.csproj]
正在创建库 bin\Release\net7.0\win-x64\native\renx.lib 和对象 bin\Release\net7.0\win-x64\native\renx.exp
RenameX -> D:\Code\RenameX\RenameX\bin\Release\net7.0\win-x64\publish\
After I run the published exe I get the following error:
Error: Could not find a constructor for 'NekoSpace.RenameX.MainCommand'.
The minimal reproducable program is like this:
using Spectre.Console;
using Spectre.Console.Cli;
var app = new CommandApp<MainCommand>();
return app.Run(args);
public sealed class MainCommand : Command
{
public override int Execute(CommandContext context)
{
AnsiConsole.MarkupLine("[blue]Hello, world![/]");
return 0;
}
}
I think it will be amazing if this library could support NativeAOT, for faster startup speed, smaller packaged size, no runtime needed, etc.
I'm trying to build a command line tool with
Spectre.Console.Cliand .NET NativeAOT enabled in .NET 7 (by<PublishAot>true</PublishAot>in csproj). But when I publish this project I get the following warnings:After I run the published exe I get the following error:
The minimal reproducable program is like this:
I think it will be amazing if this library could support NativeAOT, for faster startup speed, smaller packaged size, no runtime needed, etc.