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.04k stars 1.73k forks source link

NuGet restore is failing while building the project #504

Closed angshuman-agarwal closed 3 years ago

angshuman-agarwal commented 3 years ago

Description

Getting Build error related to NuGet packages not being able to restore

Steps to Reproduce

  1. Download Visual studio Preview (latest)
  2. Follow the instructions on MAUI readme page.
  3. execute : dotnet build src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj -t:Run

Expected Behavior

Build should be successful

Actual Behavior

NuGet restore is failing

Basic Information

Exception Output:

 Determining projects to restore...
  Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/mdoc/index.json'.
  The SSL connection could not be established, see inner exception.
    Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host..
    An existing connection was forcibly closed by the remote host.

C:\Program Files\dotnet\sdk\6.0.100-preview.2.21155.3\NuGet.targets(131,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json. [C:\Users\aa\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.2.21155.3\NuGet.targets(131,5): error :   The SSL connection could not be established, see inner exception. [C:\Users\aa\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.2.21155.3\NuGet.targets(131,5): error :   Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. [C:\Users\aa\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.2.21155.3\NuGet.targets(131,5): error :   An existing connection was forcibly closed by the remote host. [C:\Users\aa\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj]
davidortinau commented 3 years ago

Check the instructions here and the NuGet.config. https://github.com/dotnet/maui/wiki/Getting-Started

angshuman-agarwal commented 3 years ago

Thanks, it progressed a bit, i.e. tried to restore, but stuck here now : when I tried to execute this command: dotnet build src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj -t:Run

PS: I have already installed the Android and iOS workloads as per the instruction here - https://github.com/dotnet/net6-mobile-samples

Output:

  Determining projects to restore...
  Restored C:\maui\src\Compatibility\Core\src\Android.FormsViewGroup\Compatibility.Android.FormsViewGroup-net6.csproj (in 114 ms).
  Restored C:\maui\src\Controls\src\Build.Tasks\Controls.Build.Tasks-net6.csproj (in 313 ms).
  Restored C:\maui\src\Essentials\src\Essentials-net6.csproj (in 13.67 sec).
  Restored C:\maui\src\Controls\src\Core\Controls.Core-net6.csproj (in 21.27 sec).
  Restored C:\maui\src\Controls\samples\Controls.Sample\Maui.Controls.Sample-net6.csproj (in 21.28 sec).
  Restored C:\maui\src\Controls\src\Xaml\Controls.Xaml-net6.csproj (in 21.27 sec).
  Restored C:\maui\src\Compatibility\Core\src\Compatibility-net6.csproj (in 21.31 sec).
  Restored C:\maui\src\Core\src\Core-net6.csproj (in 21.31 sec).
  Restored C:\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj (in 49.77 sec).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/Theme.AppCompat.Light.DarkActionBar (aka Microsoft.Maui:style/Theme.AppCompat.Light.DarkActionBar) not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorAccent (aka Microsoft.Maui:attr/colorAccent)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorPrimary (aka Microsoft.Maui:attr/colorPrimary)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorPrimaryDark (aka Microsoft.Maui:attr/colorPrimaryDark)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/ThemeOverlay.AppCompat.Dark.ActionBar (aka Microsoft.Maui:style/ThemeOverlay.AppCompat.Dark.ActionBar) not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/windowActionBar (aka Microsoft.Maui:attr/windowActionBar)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/windowNoTitle (aka Microsoft.Maui:attr/windowNoTitle)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/ThemeOverlay.AppCompat.Light (aka Microsoft.Maui:style/ThemeOverlay.AppCompat.Light) not found. [C:\maui\src\Core\src\Core-net6.csproj]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2062: failed linking references. [C:\maui\src\Core\src\Core-net6.csproj]
C:\maui\src\Essentials\src\AppInfo\AppInfo.android.cs(7,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Browser\Browser.android.cs(5,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Permissions\Permissions.android.cs(9,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Permissions\Permissions.android.cs(10,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Types\FileProvider.android.cs(9,29): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\WebAuthenticator\WebAuthenticator.android.cs(5,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\WebAuthenticator\WebAuthenticator.android.cs(108,38): error CS0246: The type or namespace name 'CustomTabsActivityManager' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
  Compatibility.Android.FormsViewGroup-net6 -> C:\maui\src\Compatibility\Core\src\Android.FormsViewGroup\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll

Build FAILED.

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/Theme.AppCompat.Light.DarkActionBar (aka Microsoft.Maui:style/Theme.AppCompat.Light.DarkActionBar) not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorAccent (aka Microsoft.Maui:attr/colorAccent)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorPrimary (aka Microsoft.Maui:attr/colorPrimary)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorPrimaryDark (aka Microsoft.Maui:attr/colorPrimaryDark)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/ThemeOverlay.AppCompat.Dark.ActionBar (aka Microsoft.Maui:style/ThemeOverlay.AppCompat.Dark.ActionBar) not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/windowActionBar (aka Microsoft.Maui:attr/windowActionBar)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/windowNoTitle (aka Microsoft.Maui:attr/windowNoTitle)' not found. [C:\maui\src\Core\src\Core-net6.csproj]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/ThemeOverlay.AppCompat.Light (aka Microsoft.Maui:style/ThemeOverlay.AppCompat.Light) not found. [C:\maui\src\Core\src\Core-net6.csproj]
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Aapt2.targets(157,3): error APT2062: failed linking references. [C:\maui\src\Core\src\Core-net6.csproj]
C:\maui\src\Essentials\src\AppInfo\AppInfo.android.cs(7,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Browser\Browser.android.cs(5,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Permissions\Permissions.android.cs(9,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Permissions\Permissions.android.cs(10,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\Types\FileProvider.android.cs(9,29): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\WebAuthenticator\WebAuthenticator.android.cs(5,7): error CS0246: The type or namespace name 'AndroidX' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
C:\maui\src\Essentials\src\WebAuthenticator\WebAuthenticator.android.cs(108,38): error CS0246: The type or namespace name 'CustomTabsActivityManager' could not be found (are you missing a using directive or an assembly reference?) [C:\maui\src\Essentials\src\Essentials-net6.csproj]
    0 Warning(s)
    16 Error(s)

Time Elapsed 00:01:03.86
angshuman-agarwal commented 3 years ago

I enabled Hyper V, restarted Windows around 3 times, it worked ! I am not able to say why exactly though. In between restarts, I could see that dot net run command failed with various errors

Example: 1.

C:\maui\FirstLook>dotnet build -t:Run -f net6.0-android --no-restore
Microsoft (R) Build Engine version 16.10.0-preview-21126-01+6819f7ab0 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  FirstLook -> C:\maui\FirstLook\bin\Debug\net6.0-android\FirstLook.dll
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Common.Debugging.targets(605,5): error XA0010: No available device. [C:\maui\FirstLook\FirstLook.csproj]

Build FAILED.

2. I attached my phone at this point now as adb devices was not listing any emulator although I enabled via Tools > Android in VS. I saw the emulator for v30 was throwing error. image

  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  FirstLook -> C:\maui\FirstLook\bin\Debug\net6.0-android\FirstLook.dll
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.win-x64\11.0.200-ci.main.148\tools\Xamarin.Android.Common.Debugging.targets(605,5): error XA0010: Could not retrieve the Android ABI for the attached device or emulator. Please reconnect the device or restart the emulator, and try again. [C:\maui\FirstLook\FirstLook.csproj]

Build FAILED.

After attaching my phone, I followed this doc - https://docs.microsoft.com/en-us/xamarin/android/get-started/installation/set-up-device-for-development. Still did not run.

I restarted Windows twice as I did not know what to do because errors were not consistent. And, it worked. Little confused though. Need to try the steps on a new machine again to understand what I just did as I am not able to sum up.

Determining projects to restore...
  All projects are up-to-date for restore.
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Essentials-net6 -> C:\maui\src\Essentials\src\bin\Debug\net6.0-android\Microsoft.Maui.Essentials.dll
  Compatibility.Android.FormsViewGroup-net6 -> C:\maui\src\Compatibility\Core\src\Android.FormsViewGroup\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll
  Core-net6 -> C:\maui\src\Core\src\bin\Debug\net6.0-android\Microsoft.Maui.dll
  Controls.Core-net6 -> C:\maui\src\Controls\src\Core\bin\Debug\net6.0-android\Microsoft.Maui.Controls.dll
  Controls.Xaml-net6 -> C:\maui\src\Controls\src\Xaml\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Xaml.dll
  Compatibility-net6 -> C:\maui\src\Compatibility\Core\src\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Compatibility.dll
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Core-net6 -> C:\maui\src\Core\src\bin\Debug\netstandard2.0\Microsoft.Maui.dll
  Controls.Core-net6 -> C:\maui\src\Controls\src\Core\bin\Debug\netstandard2.0\Microsoft.Maui.Controls.dll
  Controls.Xaml-net6 -> C:\maui\src\Controls\src\Xaml\bin\Debug\netstandard2.0\Microsoft.Maui.Controls.Xaml.dll
  Controls.Build.Tasks-net6 -> C:\maui\src\Controls\src\Build.Tasks\bin\Debug\netstandard2.0\Microsoft.Maui.Controls.Build.Tasks.dll
  Maui.Controls.Sample-net6 -> C:\maui\src\Controls\samples\Controls.Sample\bin\Debug\net6.0-android\Maui.Controls.Sample.dll
  Maui.Controls.Sample.Droid-net6 -> C:\maui\src\Controls\samples\Controls.Sample.Droid\bin\Debug\net6.0-android\Maui.Controls.Sample.Droid.dll
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Essentials-net6 -> C:\maui\src\Essentials\src\bin\Debug\net6.0-android\Microsoft.Maui.Essentials.dll
  Compatibility.Android.FormsViewGroup-net6 -> C:\maui\src\Compatibility\Core\src\Android.FormsViewGroup\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Compatibility.Android.FormsViewGroup.dll
  Core-net6 -> C:\maui\src\Core\src\bin\Debug\net6.0-android\Microsoft.Maui.dll
  Controls.Core-net6 -> C:\maui\src\Controls\src\Core\bin\Debug\net6.0-android\Microsoft.Maui.Controls.dll
  Compatibility-net6 -> C:\maui\src\Compatibility\Core\src\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Compatibility.dll
  Controls.Xaml-net6 -> C:\maui\src\Controls\src\Xaml\bin\Debug\net6.0-android\Microsoft.Maui.Controls.Xaml.dll
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Core-net6 -> C:\maui\src\Core\src\bin\Debug\netstandard2.0\Microsoft.Maui.dll
  Controls.Core-net6 -> C:\maui\src\Controls\src\Core\bin\Debug\netstandard2.0\Microsoft.Maui.Controls.dll
  Controls.Xaml-net6 -> C:\maui\src\Controls\src\Xaml\bin\Debug\netstandard2.0\Microsoft.Maui.Controls.Xaml.dll
  Controls.Build.Tasks-net6 -> C:\maui\src\Controls\src\Build.Tasks\bin\Debug\netstandard2.0\Microsoft.Maui.Controls.Build.Tasks.dll
  Maui.Controls.Sample-net6 -> C:\maui\src\Controls\samples\Controls.Sample\bin\Debug\net6.0-android\Maui.Controls.Sample.dll
C:\Users\aa\.nuget\packages\runtime.linux-arm64.runtime.native.system.io.ports\5.0.0-rtm.20519.4\runtimes\linux-arm64\native\libSystem.IO.Ports.Native.so : warning XA4301: Cannot determine ABI of native library 'C:\Users\aa\.nuget\packages\runtime.linux-arm64.runtime.native.system.io.ports\5.0.0-rtm.20519.4\runtimes\linux-arm64\native\libSystem.IO.Ports.Native.so'. Remove the 'runtime.linux-arm64.runtime.native.System.IO.Ports' NuGet package, or notify the library author. [C:\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj]

**Build succeeded.**

C:\Users\aa\.nuget\packages\runtime.linux-arm64.runtime.native.system.io.ports\5.0.0-rtm.20519.4\runtimes\linux-arm64\native\libSystem.IO.Ports.Native.so : warning XA4301: Cannot determine ABI of native library 'C:\Users\aa\.nuget\packages\runtime.linux-arm64.runtime.native.system.io.ports\5.0.0-rtm.20519.4\runtimes\linux-arm64\native\libSystem.IO.Ports.Native.so'. Remove the 'runtime.linux-arm64.runtime.native.System.IO.Ports' NuGet package, or notify the library author. [C:\maui\src\Controls\samples\Controls.Sample.Droid\Maui.Controls.Sample.Droid-net6.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:01:11.55

From my Android phone:

image

Redth commented 3 years ago

Public previews now ship on NuGet.org and should restore without specifying additional feeds.