Program.cs(18, 44): [CS1061] 'AppBuilder' 不包含 'UsePlatformDetect' 的定义并且没有可访问的扩展方法 'UsePlatformDetect'

Program.cs(18, 44): [CS1061] 'AppBuilder' does not contain a definition for 'UsePlatformDetect' and no accessible extension method 'UsePlatformDetect'

  Program.cs(18, 44): [CS1061] 'AppBuilder' does not contain a definition for 'UsePlatformDetect' and no accessible extension method 'UsePlatformDetect' accepting a first argument of type 'AppBuilder' could be found (are you missing a using directive or an assembly reference?)

这是我的代码:

using System;
using Avalonia;
using Avalonia.ReactiveUI;

namespace AvaloniaCrossPlatformApplication1.Desktop
{
    class Program
    {
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        [STAThread]
        public static void Main(string[] args) => BuildAvaloniaApp()
            .StartWithClassicDesktopLifetime(args);

        // Avalonia configuration, don't remove; also used by visual designer.
        public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>().UsePlatformDetect()
                .LogToDebug()
                .UseReactiveUI();
    }
}

我的avalonia版本是avalonia.0.10.13.nupkg.sha512

我正在使用基本模板。

好像Avalonia上没有UsePlatformDetect ...

我使用了 jetbrain rider 和 dotnet new -i Avalonia.Templates

生成模板。

有什么想法吗?我在 ubuntu 22.04.

此致

UsePlatformDetect 扩展在 Avalonia.Desktop 程序集中有其定义,因此您必须在 .csproj

中添加对它的引用
<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />