问题描述
我已经创建了一个要提交到Windows应用商店的.NET Core Winforms应用(使用C#)。按照here的说明,我向解决方案中添加了一个Windows应用程序打包项目:
我尝试创建程序包,但由于出现此错误消息而失败:
严重性代码描述项目文件行抑制状态 错误处理器的架构之间不匹配。 正在建立的专案「MSIL」和处理器架构 参考 “ C:\ Users \ bclay \ source \ repos \ F4F_Core \ F4F_Core \ bin \ x86 \ Release \ netcoreapp3.1 \ win-x86 \ F4F_Core.dll”, “ x86”。这种不匹配可能会导致运行时失败。请考虑 通过更改项目的目标处理器体系结构 配置管理器以便调整处理器体系结构 在您的项目和参考之间,或依赖 具有与目标匹配的处理器体系结构的引用 您项目的处理器架构。 WapProjTemplate1 C:\ Program 文件(x86)\ Microsoft Visual Studio \ 2019 \ Community \ MSBuild \ Current \ Bin \ Microsoft.Common.CurrentVersion.targets 2124
因此,它说“考虑通过Configuration Manager更改项目的目标处理器体系结构”
WapProjTemplate1.wapproj文件中可能相关的部分是:
<?xml version="1.0" encoding="utf-8"?>
<Project Toolsversion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Anycpu">
<Configuration>Debug</Configuration>
<Platform>Anycpu</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Anycpu">
<Configuration>Release</Configuration>
<Platform>Anycpu</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>235c6e85-cf17-455c-93b8-efdd1826a90e</ProjectGuid>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
. . .
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Anycpu'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Anycpu'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
. . .
<ItemGroup>
<ProjectReference Include="..\F4F_Core\F4F_Core.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>
我没有更改这些(处理器体系结构)值中的任何默认设置。我需要更改什么才能使包成功创建?
为Windows应用程序打包项目选择项目属性将显示以下内容:
如您所见,配置和平台被视为“不适用”,因此不可编辑。
更新
在“创建应用程序包”过程中,我保留了默认的“中性/发布(任何cpu)”选择,如下所示:
更新2
此答案[https://social.msdn.microsoft.com/Forums/windowsapps/en-US/461f4b46-f928-40da-8e49-7fd0f4754fd4/uwpmismatch-between-processor-architecture?forum=wpdevelop] Microsoft论坛指示不应选择“任何”,而应选择“ x86”
但是当我将主项目的目标从Any更改为x86时,它不会更改上面的值:
需要清楚的是,上面的“平台”下拉列表中只有一项:“活动(任何cpu)”
更新3
按照NicoZhu的要求,我“向Visual Studio发送有关此问题的反馈”,我打开了该项目,并立即对此表示欢迎:
更新4
所以我注意到Visual Studio中有一些通知。有人说,为了开发UWP应用程序,我必须打开“开发人员模式”。所以我做到了...
打开后,我得到了:
VS重新启动后,我再次尝试创建App Package,但是得到了这个提示:
...但是我不知道应用清单中的错误是什么,因此如果没有这些知识就无法修复它们。
错误消息msg是否引用Package.appxmanifest中的值?
更新5
解决方案:
Winforms .NET Core应用程序的属性:
Windows应用程序打包项目的属性:
更新6
did 下面的更新答案创建了程序包,但是当我尝试运行Windows Packaging App时,我得到了一个错误:两个项目中的处理器体系结构不匹配。请参阅我的后续问题here。