我的 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.
最佳答案
APPX4001 警告的简单解决方法见 this issue .
But I am more interested in why this warning does not occur when creating another empty project on the same platform?
我搜索了关于这个警告的相关信息,发现了这个 similar issue .见
...\AppxPackage\Microsoft.AppXPackage.Targets(2459,5): warning ...
,所以似乎这个警告是由 Microsoft.AppXPackage.Targets
抛出的文件。不知道为什么警告有时不显示它来自哪里,但我认为目标文件是 APPX4001.dll 的原因。我在
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage
中找到了该文件. (对于vs2017企业版)让我们检查一下它抛出警告的内容:所以很明显,如果 Condition 中的值为真,它会抛出警告 APPX4001。这个问题好像跟
AppxBundle
有关.所以我创建了一个新的uwp项目并构建它,一切正常。然后我将此行添加到其 xx.csproj 文件中:<AppxBundle>Always</AppxBundle>
然后出现同样的警告:
所以如果你尝试
build with Appxbundle or set the AppxBundle property in project file
就会出现这个警告而您没有设置 AppxBundlePlatforms 属性。这就是新的简单项目不会显示此警告的原因。此警告的简单解决方法是设置 AppxBundlePlatforms 属性,请参阅我的答案中的第一行。
希望以上所有内容可以帮助解决为什么会出现警告并解决警告的难题。
如果我误解了什么,请告诉我:)
关于c# - APPX4001 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57643594/