dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.11k stars 220 forks source link

Init script exception calling "DownloadFile" 404 Not Found #614

Closed willibrandon closed 1 year ago

willibrandon commented 1 year ago

When I run the init script init -installlocality machine from an elevated command prompt.

Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."

The exception occurs in Install-DotNetSdk.ps1. If I output the Uri in Get-InstallerExe:

https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.402/dotnet-sdk-6.0.402-win-X64.exe

Note the capital X in X64 https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.402/dotnet-sdk-6.0.402-win-X64.exe

Changing the uppercase X64 to a lowercase x64 alleviates the issue.

https://dotnetcli.blob.core.windows.net/dotnet/Sdk/6.0.402/dotnet-sdk-6.0.402-win-x64.exe

I suspect the capital X comes from here.

https://github.com/dotnet/pinvoke/blob/46248960498eba12f2f4a881504cc2d4f98d4dca/tools/Install-DotNetSdk.ps1#L32

Which returns an Architecture Enum value containing a capital X.

AArnott commented 1 year ago

Nice catch. I'll fix it with a fresh merge from the Library.Template on which it's based.

AArnott commented 1 year ago

On second thought, that's going to be a lot of trouble, so we'll take a PR to fix just this problem if you'd like to submit it.

willibrandon commented 1 year ago

I can do that. After reading dotnet-install scripts reference, Options -Architecture:

Architecture of the .NET binaries to install. Possible values are , amd64, x64, x86, arm64, arm, and s390x.

Do you think its safe for me to assume that the architecture elements of the file name will always be lowercase? That seems to be the case after downloading and inspecting all of the files from the Downlaod .NET page.

AArnott commented 1 year ago

Yes, I think that's a reasonable assumption. I may still merge Library.Template ... I'm not sure. So whatever you come up with just needs to fix the immediate problem -- it doesn't have to be sure to work for years to come. :)

willibrandon commented 1 year ago

I need to build a library so I can use your library template.