dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.61k stars 1.04k forks source link

Cannot restore dotnet 7 csproj due to missing nuget package in WSL #33982

Open stormmuller opened 1 year ago

stormmuller commented 1 year ago

When running:

dotnet restore /home/myusername/a/b/c/MyProject.csproj --interactive

I get the following error:

/home/myusername/a/b/c/MyProject.csproj : error NU1101: Unable to find package Microsoft.NETCore.App.Host.ubuntu.22.04-x64. No packages exist with this id in source(s): nuget.org

That package isn't one I added and appears in /home/myusername/a/b/c/obj/MyProject.csproj.nuget.dgspec.json after the build. A clean build did not help.

Here is my csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Common\Common.csproj" />
  </ItemGroup>

</Project>

The "Common" project is a class library that targets netstandard2.1

Further technical details

.NET SDK:
 Version:   7.0.109
 Commit:    3e9283a8e9

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/sdk/7.0.109/

Host:
  Version:      7.0.9
  Architecture: x64
  Commit:       8e9a17b221

.NET SDKs installed:
  7.0.109 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.9 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.9 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found
Amanuel94 commented 11 months ago

The only way that worked out for me is to reinstall the sdk after purge-removing them.

baronfel commented 11 months ago

This looks like the source-build distro-specific RID is slipping into host selection - is this still relevant now that the RID graph is being simplified? EDIT: no, RID simplification only comes into play in 8.x.

marcpopMSFT commented 11 months ago

Given the listed RID, where did you install the SDK from as this is likely a source built SDK specific to ubuntu? can you provide an https://aka.ms/binlog for the restore failure? CC @dotnet/source-build-internal we think this might be an issue with the source built sdk either it's not providing the matching host or not falling back to the linux- version of the host.

Kielek commented 10 months ago

I have seen similar issue. I was able to solve when I installed https://ubuntu.pkgs.org/22.04/ubuntu-updates-universe-amd64/dotnet-apphost-pack-7.0_7.0.111-0ubuntu1~22.04.1_amd64.deb.html After

akselikap commented 10 months ago

I have the same error message on native Ubuntu 22.04. dotnet info

.NET SDK:
 Version:   7.0.111
 Commit:    06c8b346e4

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/sdk/7.0.111/

Host:
  Version:      7.0.11
  Architecture: x64
  Commit:       ecb34f85ec

.NET SDKs installed:
  6.0.122 [/usr/lib/dotnet/sdk]
  7.0.111 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.22 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.22 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found
CrshOverride commented 8 months ago

Running into this on a fresh WSL2 setup w/ dotnet-sdk-7.0 installed from the Ubuntu APT repo. Unfortunately GitHub doesn't support attaching binary files. @marcpopMSFT What's the best way to send it?

marcpopMSFT commented 8 months ago

You can potentially create a devcom ticket against VS as that will support attaching files (this is the best bet as it will match our privacy compliance and have limited access). I have seen others able to attach binlogs to github issues but perhaps they've changed their rules.

larrasket commented 2 months ago

Same error on arch linux.

larrasket commented 2 months ago

Edit: fixed with pacman -Syu dotnet-targeting-pack.

Salih Muhammed @.***> writes:

Same error on arch linux.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

-- Regards, Salih