dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Workload installation fails with "Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory" #4203

Closed philippjbauer closed 2 years ago

philippjbauer commented 2 years ago

Description

Can't install Maui workload on macOS Monterey (12.1) on Apple Silicon ARM64 with sudo dotnet workload install maui or subset of maui, like maui-ios.

I am getting the following error, every single time:

Workload installation failed: 
Number of entries expected in End Of Central Directory 
does not correspond to number of entries in Central Directory.

All prerequisites are installed according to official install instructions. Fresh install of latest .NET 6 SDK 6.0.101. maui-check is checking out without problems.

Steps to Reproduce

Run sudo dotnet workload install maui in CLI.

Version with bug

Preview 11

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS 12.1

Did you find any workaround?

I found a workaround encountering download issues with the dotnet workload install command. This involves some helpful, but unfortunately undocumented, command options I figured out by looking into the source code in the .NET SDK GitHub repo. 😮‍💨

⚠️ Attention
This requires a \*nix shell environment. You can probably get this working in Powershell as well.

🗒 Note
The following commands use sources specifically for installation of MAUI Preview 12.
If you want to use stable workloads the same instructions should apply but without the 
need for the rollback file or sources.

Download URLS

First you have to download the URLs to the needed workload nuget packages.

# Get all URLS
dotnet workload install maui \
    --print-download-link-only \
    --skip-manifest-update \
    --from-rollback-file https://aka.ms/dotnet/maui/preview.12.json \
    --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json \
    --source https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json
# Example Output
Resolving package URLs for workload(s) maui...
    ==allPackageLinksJsonOutputStart==
["https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.netcore.app.runtime.mono.android-arm/6.0.2-mauipre.1.22054.8/microsoft.netcore.app.runtime.mono.android-arm.6.0.2-mauipre.1.22054.8.nupkg",
 ... ]
==allPackageLinksJsonOutputEnd==

Create list of URLs

Then you follow the next steps to create a file with all links, ready to be used with wget.

  1. Paste package links JSON into a new text file, e.g. maui.workload.preview-12.txt.
  2. Replace all , with newline, remove [, ] and ".
  3. Create new folder, e.g. maui.nuget.cache.
  4. Change into new folder.

Download packages

Use wget command inside of new cache folder to download all packages from text file.

wget -nv --show-progress -nc -c -i maui.workload.preview-12.txt

You can retry as often as needed, use ctrl-c to cancel when the download gets stuck and use the command again to continue where the download stopped. wget will skip files you already downloaded.

Install workload from disk

Now use the downloaded files from your local cache to install the workload.

sudo dotnet workload install maui \
    --from-cache ~/path/to/maui.nuget.cache \
    --skip-manifest-update \
    --from-rollback-file https://aka.ms/dotnet/maui/preview.12.json \
    --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json \
    --source https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json

Use the same sources to restore a project

dotnet restore \
    --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json \
    --source https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json

That should do it.



Relevant log output

➜ sudo dotnet workload install maui

Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.101

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------

Skip NuGet package signing validation. NuGet signing validation is not available on Linux or macOS https://aka.ms/workloadskippackagevalidation .
Updated advertising manifest microsoft.net.sdk.ios.
Updated advertising manifest microsoft.net.sdk.tvos.
Updated advertising manifest microsoft.net.sdk.android.
Updated advertising manifest microsoft.net.workload.emscripten.
Updated advertising manifest microsoft.net.sdk.maui.
Updated advertising manifest microsoft.net.sdk.macos.
Updated advertising manifest microsoft.net.sdk.maccatalyst.
Updated advertising manifest microsoft.net.workload.mono.toolchain.
Installing workload manifest microsoft.net.sdk.tvos version 15.0.101-preview.11.551…
Installing workload manifest microsoft.net.sdk.android version 31.0.101-preview.11.117…
Installing workload manifest microsoft.net.sdk.maui version 6.0.101-preview.11.2349…
Installing workload manifest microsoft.net.sdk.macos version 12.0.101-preview.11.551…
Installing workload manifest microsoft.net.sdk.maccatalyst version 15.0.101-preview.11.551…
Installing workload manifest microsoft.net.sdk.ios version 15.0.101-preview.11.551…
Installing pack Microsoft.Maui.Core.Ref.android version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Core.Ref.android version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Core.Runtime.android version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Core.Runtime.android version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Controls.Ref.android version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Controls.Ref.android version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Controls.Runtime.android version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Controls.Runtime.android version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Essentials.Ref.android version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Essentials.Ref.android version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Essentials.Runtime.android version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Essentials.Runtime.android version 6.0.101-preview.11.2349...
Installing pack Microsoft.AspNetCore.Components.WebView.Maui version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.AspNetCore.Components.WebView.Maui version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Dependencies version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Dependencies version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Controls.Build.Tasks version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Controls.Build.Tasks version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Sdk version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Sdk version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Extensions version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Extensions version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Resizetizer.Sdk version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Resizetizer.Sdk version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Templates version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Templates version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Core.Ref.any version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Core.Ref.any version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Core.Runtime.any version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Core.Runtime.any version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Controls.Ref.any version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Controls.Ref.any version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Controls.Runtime.any version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Controls.Runtime.any version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Essentials.Ref.any version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Essentials.Ref.any version 6.0.101-preview.11.2349...
Installing pack Microsoft.Maui.Essentials.Runtime.any version 6.0.101-preview.11.2349...
Writing workload pack installation record for Microsoft.Maui.Essentials.Runtime.any version 6.0.101-preview.11.2349...
Installing pack Microsoft.Android.Sdk version 31.0.101-preview.11.117...
Writing workload pack installation record for Microsoft.Android.Sdk version 31.0.101-preview.11.117...
Installing pack Microsoft.Android.Sdk.BundleTool version 31.0.101-preview.11.117...
Writing workload pack installation record for Microsoft.Android.Sdk.BundleTool version 31.0.101-preview.11.117...
Installing pack Microsoft.Android.Ref.31 version 31.0.101-preview.11.117...
Writing workload pack installation record for Microsoft.Android.Ref.31 version 31.0.101-preview.11.117...
Installing pack Microsoft.Android.Runtime.31.android-arm version 31.0.101-preview.11.117...
Workload installation failed. Rolling back installed packs...
Installing workload manifest microsoft.net.sdk.tvos version 15.0.101-preview.9.31…
Installation rollback failed: Failed to install manifest microsoft.net.sdk.tvos version 15.0.101-preview.9.31: The transaction has aborted..
Rolling back pack Microsoft.Maui.Core.Ref.android installation...
Uninstalling workload pack Microsoft.Maui.Core.Ref.android version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Core.Runtime.android installation...
Uninstalling workload pack Microsoft.Maui.Core.Runtime.android version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Controls.Ref.android installation...
Uninstalling workload pack Microsoft.Maui.Controls.Ref.android version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Controls.Runtime.android installation...
Uninstalling workload pack Microsoft.Maui.Controls.Runtime.android version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Essentials.Ref.android installation...
Uninstalling workload pack Microsoft.Maui.Essentials.Ref.android version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Essentials.Runtime.android installation...
Uninstalling workload pack Microsoft.Maui.Essentials.Runtime.android version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.AspNetCore.Components.WebView.Maui installation...
Uninstalling workload pack Microsoft.AspNetCore.Components.WebView.Maui version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Dependencies installation...
Uninstalling workload pack Microsoft.Maui.Dependencies version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Controls.Build.Tasks installation...
Uninstalling workload pack Microsoft.Maui.Controls.Build.Tasks version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Sdk installation...
Uninstalling workload pack Microsoft.Maui.Sdk version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Extensions installation...
Uninstalling workload pack Microsoft.Maui.Extensions version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Resizetizer.Sdk installation...
Uninstalling workload pack Microsoft.Maui.Resizetizer.Sdk version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Templates installation...
Uninstalling workload pack Microsoft.Maui.Templates version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Core.Ref.any installation...
Uninstalling workload pack Microsoft.Maui.Core.Ref.any version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Core.Runtime.any installation...
Uninstalling workload pack Microsoft.Maui.Core.Runtime.any version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Controls.Ref.any installation...
Uninstalling workload pack Microsoft.Maui.Controls.Ref.any version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Controls.Runtime.any installation...
Uninstalling workload pack Microsoft.Maui.Controls.Runtime.any version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Essentials.Ref.any installation...
Uninstalling workload pack Microsoft.Maui.Essentials.Ref.any version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Maui.Essentials.Runtime.any installation...
Uninstalling workload pack Microsoft.Maui.Essentials.Runtime.any version 6.0.101-preview.11.2349…
Rolling back pack Microsoft.Android.Sdk installation...
Uninstalling workload pack Microsoft.Android.Sdk version 31.0.101-preview.11.117…
Rolling back pack Microsoft.Android.Sdk.BundleTool installation...
Uninstalling workload pack Microsoft.Android.Sdk.BundleTool version 31.0.101-preview.11.117…
Rolling back pack Microsoft.Android.Ref.31 installation...
Uninstalling workload pack Microsoft.Android.Ref.31 version 31.0.101-preview.11.117…
Rolling back pack Microsoft.Android.Runtime.31.android-arm installation...
Workload installation failed: Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory.
philippjbauer commented 2 years ago

Related to #3021

The last comment points to documentation that was moved / official docs were no help.

Redth commented 2 years ago

Unfortunately the answer as of now is basically try again, this appears to be a transient network error of some type.

You can track discussion/progress here, as this is a dotnet/sdk level bug: https://github.com/dotnet/sdk/issues/20849

philippjbauer commented 2 years ago

Thank you for the quick reply and reference @Redth!

philippjbauer commented 2 years ago

It worked eventually after retrying a bunch of times.

philippjbauer commented 2 years ago

@Redth I found a workaround for this and added it to the OP. Do you think this could find a place over in the SDK issue you linked to help people with similar download issues that discover that thread?

Redth commented 2 years ago

Please add your findings to the issue in their repo. I'm not familiar with their code base but I can raise the issue again with the team if you've shared new/more info.

Thanks!