以下警告出现在我的UWP项目中。我已经标记了解决方案的示例,但我更感兴趣的是,为什么在同一平台上创建另一个空项目时不会出现此警告?
APPX4001: Build property AppxBundlePlatforms is not explicitly set and is
calculated based on currently building architecture. Use 'Create App
Package' wizard or edit project file to set it.发布于 2019-08-27 19:01:25
有关APPX4001警告的简单解决方法,请参阅this issue。
但我更感兴趣的是,为什么在同一平台上创建另一个空项目时没有出现此警告?
我搜索了关于这个警告的相关信息,找到了这个similar issue。请参见...\AppxPackage\Microsoft.AppXPackage.Targets(2459,5): warning ...,因此该警告似乎是由Microsoft.AppXPackage.Targets文件抛出的。不确定为什么警告有时没有显示它来自哪里,但我认为目标文件是导致APPX4001的原因。
我在C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage里找到了那个文件。(对于vs2017企业版)让我们检查一下抛出警告的内容:

因此很明显,如果Condition中的值为true,它将抛出警告APPX4001。这个问题似乎和AppxBundle有关。所以我创建了一个新的uwp项目并构建它,一切都很好。然后我将这一行添加到它的xx.csproj文件中:
<AppxBundle>Always</AppxBundle>然后出现相同的警告:

因此,如果您在未设置AppxBundlePlatforms属性的情况下尝试build with Appxbundle or set the AppxBundle property in project file,则会出现此警告。
这就是为什么新的简单项目不会显示此警告的原因。此警告的简单解决方法是设置AppxBundlePlatforms属性,请参见我的答案中的第一行。
希望所有这些都能帮助解决为什么会出现警告的问题,并解决警告。如果我误解了什么,请告诉我:)
发布于 2020-02-13 21:27:39
也许this link能帮上忙。
正如文章中所描述的,我尝试打包我的应用程序(只是使用没有签名的Sideload包)。打包过程随后添加了
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>.csproj文件中的条目,并且警告已消失。
发布于 2019-08-31 13:53:07
下面是我的文件。我还创建了一个不显示此警告的空项目,并比较了这些文件,但我没有注意到任何有趣的东西
<PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{4D5DB11B-A55F-4255-A1F7-B58D14137F31}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>myapp2</RootNamespace>
<AssemblyName>myapp2</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>myapp2_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>5F6796FA8483D6C4EDA3E24DB0DC18631F615689
</PackageCertificateThumbprint>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="lightbuzz-smtp">
<Version>1.8.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.2.3</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version>
</PackageReference>
<PackageReference Include="Template10">
<Version>1.1.12</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="WampSharp">
<Version>18.3.2</Version>
</PackageReference>
<PackageReference Include="WampSharp.Default">
<Version>18.3.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<None Include="myapp2_TemporaryKey.pfx" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or
'$(VisualStudioVersion)' < '14.0' ">
<VisualSt udioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import
Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml
v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Target Name="AfterBuild">
<Message Importance="High" Text="Thank you for using Template 10. Find out more at
http://aka.ms/template10" />
</Target>
</Project>https://stackoverflow.com/questions/57643594
复制相似问题