从 Xamarin.Forms 更新到 .Net MAUI 后出现兼容性问题

问题描述 投票:0回答:1

在 Visual Studio 2022 中,我开发了一个 Xamarin.Forms 解决方案,可以在 Android 和 UWP (Windows) 上编译和运行。我使用微软的升级助手升级到.Net 8.0和.Net MAUI。这导致 UWP 项目(VS 的德语版本)出现 4 个错误:

Fehler  NU1202  Das Paket System.Security.Principal.Windows 5.0.0 ist nicht mit net8.0-windows10.0.19041 (.NETCoreApp,Version=v8.0)/win10-x64 kompatibel. Paket System.Security.Principal.Windows 5.0.0 unterstützt Folgendes: uap10.0.16299 (UAP,Version=v10.0.16299)

这意味着:数据包

System.Security.Principal.Windows 5.0.0
net8.0-windows10.0.19041 (.NETCoreApp,Version=v8.0)
不兼容。

数据包

System.Security.Principal.Windows 5.0.0
支持
uap10.0.16299 (UAP,Version=v10.0.16299)

有什么想法要做什么吗?

编辑: 这是我应用升级助手后的项目文件:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <TemplateGuid>{98C37F10-6541-44BE-B1E6-7EB3EB8C08F1}</TemplateGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>BeMoSoft.Packer.UWP</RootNamespace>
    <DefaultLanguage>en-US</DefaultLanguage>
    <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
    <EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
    <UseWinUI>true</UseWinUI>
    <Platforms>x86;x64;arm64</Platforms>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
    <RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
    <PublishProfile>win10-$(Platform).pubxml</PublishProfile>
    <TargetFrameworks>net8.0-windows10.0.19041.0</TargetFrameworks>
    <UseMaui>True</UseMaui>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
    <OutputPath>bin\ARM\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
    <OutputPath>bin\ARM\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
  </PropertyGroup>
  <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
      <SubType>Designer</SubType>
    </AppxManifest>
  </ItemGroup>
  <ItemGroup>
    <Content Include="icon_backup.png" />
    <Content Include="icon_journeys.png" />
    <Content Include="icon_settings.png" />
    <Content Include="icon_task.png" />
    <Content Include="icon_journey.png" />
    <Content Include="icon_templates.png" />
    <Content Include="packer_logo.png" />
    <Content Include="Properties\Default.rd.xml" />
    <Content Include="Assets\LargeTile.scale-100.png" />
    <Content Include="Assets\LargeTile.scale-200.png" />
    <Content Include="Assets\LargeTile.scale-400.png" />
    <Content Include="Assets\SmallTile.scale-100.png" />
    <Content Include="Assets\SmallTile.scale-200.png" />
    <Content Include="Assets\SmallTile.scale-400.png" />
    <Content Include="Assets\SplashScreen.scale-100.png" />
    <Content Include="Assets\SplashScreen.scale-200.png" />
    <Content Include="Assets\SplashScreen.scale-400.png" />
    <Content Include="Assets\Square150x150Logo.scale-100.png" />
    <Content Include="Assets\Square150x150Logo.scale-200.png" />
    <Content Include="Assets\Square150x150Logo.scale-400.png" />
    <Content Include="Assets\Square44x44Logo.altform-unplated_targetsize-16.png" />
    <Content Include="Assets\Square44x44Logo.altform-unplated_targetsize-256.png" />
    <Content Include="Assets\Square44x44Logo.altform-unplated_targetsize-48.png" />
    <Content Include="Assets\Square44x44Logo.scale-100.png" />
    <Content Include="Assets\Square44x44Logo.scale-200.png" />
    <Content Include="Assets\Square44x44Logo.scale-400.png" />
    <Content Include="Assets\Square44x44Logo.targetsize-16.png" />
    <Content Include="Assets\Square44x44Logo.targetsize-256.png" />
    <Content Include="Assets\Square44x44Logo.targetsize-48.png" />
    <Content Include="Assets\StoreLogo.scale-100.png" />
    <Content Include="Assets\StoreLogo.scale-200.png" />
    <Content Include="Assets\StoreLogo.scale-400.png" />
    <Content Include="Assets\Wide310x150Logo.scale-100.png" />
    <Content Include="Assets\Wide310x150Logo.scale-200.png" />
    <Content Include="Assets\Wide310x150Logo.scale-400.png" />
    <Content Include="xamarin_logo.png" />
    <Content Include="icon_about.png" />
    <Content Include="icon_feed.png" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Packer\Packer.csproj" />
    <ProjectReference Include="..\UpdateClient\UpdateClient.csproj" />
  </ItemGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|ARM'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\ARM\Test\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Test\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Test\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>
  <PropertyGroup />
  <ItemGroup>
    <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240311000" />
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.2.0" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.3" />
  </ItemGroup>
</Project>
c# .net maui upgrade nuget-package
1个回答
0
投票

UWP 没有(也不会)针对 NET 8 进行更新,这就是错误源。UWP 的正常替代品是 WinUI 3,但现在您有另一种选择,因为您可以在 Windows 桌面上使用 NET-MAUI 应用程序(实际上它在 Windows 上包装 WinUI 3)。

© www.soinside.com 2019 - 2024. All rights reserved.