简体   繁体   中英

Why does my release build fail with error APPX0002: Task 'ValidateAppxManifest' failed?

I am trying to develop a UWP app for Windows desktop machines. Everything has been going well, but within the last few days I've lost the ability to build a release version (building a debug version still works fine). I get the following error messages:

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(2810,5): error APPX0002: Task 'ValidateAppxManifest' failed. Unspecified error

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(2810,5): error APPX0002: [My App] violates pattern constraint of '\bms-resource:.{1,256}'.

I've tried a number of "fixes" that worked for people over the last few years. Some people report the problem fixed itself in the latest version of Visual Studio. Unfortunately, the versions they mention are older than the version I'm using, which is Microsoft Visual Studio Community 2019 Version 16.6.3 Many fixes from the net are similar to the ones below, from the URL https://social.msdn.microsoft.com/Forums/en-US/4cc2cbfb-fa0d-4f12-a0a1-9072d78e26d6/vs2019-error-task-validateappxmanifest-failed-unspecified-error-again-and-again?forum=msbuild

One fix was:

  1. Clear nuget packages,
  2. Clean solution
  3. Close VS
  4. Delete bin & obj folders of the main (startup) project
  5. Open VS - solution
  6. Restore solution nuget packages
  7. Rebuild 'n go

Another fix was:

  1. uninstalling vs & sdks,
  2. removing every nuget folder,
  3. clean the registry and restart the system,
  4. the last step once more,
  5. reinstall vs.

I have tried all of these (several times) except for "clean registry." I'm not sure what part of the registry we're talking about. So, has anyone overcome this problem in a different way, or know what the registry idea is?
Oh, some other data is

  1. Maybe my machine is too old (about 6 years old). I'm speculating that even if my machine seems to have the latest version of Windows an Visual Studio, maybe it doesn't have exactly the latest code.
  2. Things went bad while I was adding two new features. The first was to ask the user for a rating, via _storeContext.RequestRateAndReviewAppAsync(); The second was allowing the user to share some data via DataTransferManager.ShowShareUI(); I was thinking maybe these APIs might require some declarations in the manifest that I don't have, but I don't see from the documentation that they do. Any ideas would be greatly appreciated. I'm out of ideas at the moment.

Dan

Here is the answer, for me. I'm not confident that this as the answer for all cases, but all is good now.

You may remember that I said I had the latest version of Windows, and I did. However, when I checked with Windows Update last night, it confirmed I was “up to date” but it offered me a “Feature update” to Windows 10, version 2004. I decided to go for it.

The update took hours to complete, and this morning it was still only 94% complete when Nico Zhu suggested to try using Visual Studio 2017. I figured I'd install VS 2017 after the update, but when it was finally complete, I decided to try VS 2019 one more time with my fresh new version of Windows. Amazingly, it worked the first time.

I should mention that my new procedure for making an app package now includes

  1. close VS 2019
  2. delete the project's obj folder
  3. delete the project's bin folder (I used to just delete the obj folder, but after seeing others suggestions I've added this step)
  4. launch VS 2019
  5. create the App Package

I wanted to do another build/package so I fixed a couple of cosmetic bugs and tried again. On the second try I fell back into my old pattern and I did NOT delete the bin folder. Immediately VS 2019 popped up with an error message something like “Cannot complete build. Fix problem with your app manifest.” Rather than pouring over the manifest file as I've been doing for the last couple of days, I deleted both the obj and bin folders and tried again. The build/package process then worked perfectly.

So, I want to say that the app manifest file was not the culprit (in this case anyway) and I'm now a fan of deleting both the obj and bin folders, and having Win 10 version 2014, before attempting a release build with VS 2019.

Dan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM