maui
maui copied to clipboard
Nuget connectivity/ Android Device manager connectivity
Description
This appears to be the same issue as #4550. I have been accessing Nuget packages from VS on this machine for over 5 years without and issue, but if I create a new Maui Project I get the following errors when trying to restore Nuget packages:
An error occurred while sending the request. The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. The remote certificate is invalid according to the validation procedure. Unable to load the service index for source https://api.nuget.org/v3/index.json.
What is different about the way .NET maui attempts to restore Nuget packages?
Please note I have tried deleting and recreating my nuget.config file, downloading sample offical projects from GitHub, always with the same outcome. I am behind a firewall, but as I have said, Nuget works fine from any other VS project type.
Steps to Reproduce
- Create a new .Net Maui project
- Build the project
- The error appears in the console
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows SDK 10.0.19041.0
Did you find any workaround?
no
Relevant log output
FROM PACKAGE MANAGER:
Error occurred while restoring NuGet packages: Unable to load the service index for source https://api.nuget.org/v3/index.json.
[nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
The remote certificate is invalid according to the validation procedure.
Unable to load the service index for source https://api.nuget.org/v3/index.json.
FROM BUILD:
1>------ Build started: Project: MauiApp1, Configuration: Debug Any CPU ------
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Error occurred while restoring NuGet packages: Unable to load the service index for source https://api.nuget.org/v3/index.json.
1>C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file 'C:\Users\ra092\Documents\CSDMaui\MauiApp1\MauiApp1\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
1>Done building project "MauiApp1.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file 'C:\Users\ra092\Documents\CSDMaui\MauiApp1\MauiApp1\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
1>Done building project "MauiApp1.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file 'C:\Users\ra092\Documents\CSDMaui\MauiApp1\MauiApp1\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
1>Done building project "MauiApp1.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file 'C:\Users\ra092\Documents\CSDMaui\MauiApp1\MauiApp1\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
1>Done building project "MauiApp1.csproj" -- FAILED.
There should be no difference between any other project type and a MAUI one. While the MAUI Single Project type has special tooling to handle cases like images, resources, and deployment, the actual act of building the code and getting sources (So, calling Nuget) should be one and the same. If you reference the MAUI NuGet packages in your project in any other csproj (Say, for native embedding), it should be able to download them. So I doubt there is anything specific with this project type that would create SSL errors.
Did you try building and deploying from the command line? If it works there, maybe there is an issue with Visual Studio blocking the connection?
e. regarding that other issue you linked to, IMO it was probably closed too early (the tester saw it working on their machine and closed it, but the issue was probably specific to something on that users machine) but even in that case, I think it's slim that the issue with something specific with MAUI itself, but an issue with that specific computer and some configuration issue with it and Visual Studio.
Hi @austirob. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Do you mean from the Package Manager Console? This is particularly strange.
- create .net maui app
- use the PMC to install a package, it works
- go to Manage Nuget Packages and attempt to browse. Error described previously occurs
- Go back to PMC and attempt to install any package, I now get the error
i_nstall-package : Unable to find package 'postsharp' at source ''. At line:1 char:1
- install-package postsharp
-
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand_
Not only does this affect this Maui project, it now occurs in any project I open, of ANY type. If I close VS and re-open again, it works again until I try and Manage 'NuGet Packages' again
Something very significant I have realised though, if I try and create a new Android emulator I immediately get the error "Network is unreachable". Is there a way to install an emulator from the command line?
Thanks
I'd be grateful if you would reply to my question regarding whether or not its possible to download and use a new Android emulator outside of Android Device Manager? Many thanks
OK I got to the reason for the problem with Android Device Manager. Our organisation does not allow dns requests over ssl which occurs when trying to download a new device. Is there a config where this can be changed?
We're experiencing the same issue on Visual Studio 17.8.4.
NuGet packages from private feed with custom cert work fine - as long as no MAUI project is present. As soon as a MAUI project is inside the solution we're getting the error:
An error occurred while sending the request.
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
The remote certificate is invalid according to the validation procedure.
Issue has also popped up on Stackoverflow
Any workaround for this? I'm experiencing the same...everything works for other project types even if we are behind a proxy, but for MAUI projects it doesn't.
We experience the same issue, it works when using dotnet restore
so building / restoring from the commandline may be a suitable workaround.
In our case we are restoring from a private upstream feed which has an outdated certificate, so SSL warnings / workarounds are to be expected. However, this has never been an issue except in the one solution using MAUI.
OK, so the problems in my corporate environment were resolved as follows:
-
Android Device manager connectivity (downloads) In my setup this was being blocked by the NetSkope client. To get it working I needed a netskope ssl bypass policy for www.microsoft.com for Visual Studio.
-
Nuget notworking (only in .NET Maui) The domains listed here https://learn.microsoft.com/en-us/visualstudio/install/install-and-use-visual-studio-behind-a-firewall-or-proxy-server?view=vs-2022 under "Nuget package discovery" also needed bypassing in netskope
So may be only .NETMaui uses SSL, or only MAUI uses certificate pinning.....but it does something different! It would be good to get some clarification from the development team.
Verified this issue with Visual Studio 17.10.0 Preview 4 (8.0.20). Can not repro this issue.
Hi @austirob. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.