Всякий раз, когда я пытаюсь опубликовать свое гибридное приложение .NET MAUI Blazor с использованием последней версии Visual Studio 2022, я получаю сообщение об ошибке The target "_GenerateAppxPackage" does not exist in the project.
. Локально все работает отлично.
Я удалил поддержку всех других платформ, кроме Windows.
Мой csproj выглядит так:
<Project Sdk = "Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFrameworks>net8.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>SaveIt.App.UI</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<EnableDefaultCssItems>false</EnableDefaultCssItems>
<Nullable>enable</Nullable>
<!-- Display name -->
<ApplicationTitle>SaveIT</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.thesecurity.saveit</ApplicationId>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition = "$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition = "$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>XXXXXXXXXXX</PackageCertificateThumbprint>
</PropertyGroup>
<PropertyGroup Condition = "$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(Configuration)' == 'Release'">
<AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>XXXXXXXXXXX</PackageCertificateThumbprint>
</PropertyGroup>
<PropertyGroup Condition = "$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(RuntimeIdentifierOverride)' != ''">
<RuntimeIdentifier>$(RuntimeIdentifierOverride)</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include = "Resources\AppIcon\saveit_icon.svg" />
<!-- Splash Screen -->
<MauiSplashScreen Include = "Resources\Splash\splash.svg" Color = "#512BD4" BaseSize = "128,128" />
<!-- Images -->
<MauiImage Include = "Resources\Images\*" />
<MauiImage Update = "Resources\Images\dotnet_bot.svg" BaseSize = "168,208" />
<!-- Custom Fonts -->
<MauiFont Include = "Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include = "Resources\Raw\**" LogicalName = "%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include = "appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>appsettings.json</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include = "appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include = "appsettings.Production.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>appsettings.json</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include = "Blazor.Bootstrap" Version = "2.2.1" />
<PackageReference Include = "Blazored.FluentValidation" Version = "2.2.0" />
<PackageReference Include = "Microsoft.AspNetCore.WebUtilities" Version = "8.0.6" />
<PackageReference Include = "Microsoft.Maui.Controls" Version = "8.0.60" />
<PackageReference Include = "Microsoft.Maui.Controls.Compatibility" Version = "8.0.60" />
<PackageReference Include = "Microsoft.AspNetCore.Components.WebView.Maui" Version = "8.0.60" />
<PackageReference Include = "Microsoft.Extensions.Logging.Debug" Version = "8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include = "..\SaveIt.App.Infrastructure\SaveIt.App.Infrastructure.csproj" />
<ProjectReference Include = "..\SaveIt.App.Persistence\SaveIt.App.Persistence.csproj" />
</ItemGroup>
</Project>
Я пробовал менять версии сборки .NET, обновлять Visual Studio, удалять папку .vs
и очищать решение.
Ожидаемый результат: я могу опубликовать свое приложение в Microsoft Store.
Вы можете попробовать напрямую использовать команду dotnetPublish.
Например:
dotnet publish -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64
Для получения дополнительной информации ознакомьтесь с документом: Опубликуйте упакованное приложение .NET MAUI для Windows с помощью CLI.