core icon indicating copy to clipboard operation
core copied to clipboard

Unable to create asp.net core api with dotnet cli

Open imjamesb opened this issue 3 years ago • 20 comments

Describe the bug

Unable to run newly created ASP.NET Core App

To Reproduce

  1. Install dotnet cli 6.0
  2. No sources are installed by default, so add nuget source. dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
  3. Install Microsoft.Identity.Web.ProjectTemplates template. dotnet new -i Microsoft.Identity.Web.ProjectTemplates
  4. Create project. dotnet new webapi2 -o ..
  5. Run project. dotnet run

Exceptions (if any)

Building...
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '3.1.0' (x64) was not found.
  - The following frameworks were found:
      6.0.0 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64

Further technical details

dotnet --info Output
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100\

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

imjamesb avatar Dec 10 '21 15:12 imjamesb

Creating it with Visual Studio 2022 did not work either.

image

imjamesb avatar Dec 10 '21 15:12 imjamesb

The Identity.Web templates are owned by https://github.com/AzureAD/microsoft-identity-web.

The WebApi project targets 3.1 which you don't have installed: https://github.com/AzureAD/microsoft-identity-web/blob/eb618181d42599ee45e6ddf44ed919e2fa2f71ec/ProjectTemplates/templates/WebApi-CSharp/Company.WebApplication1.csproj#L3

You need to install 3.1 or retarget to 6.0.

Tratcher avatar Dec 10 '21 17:12 Tratcher

Hi @ihack2712. We have added the "Needs: Author Feedback" 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.

ghost avatar Dec 10 '21 17:12 ghost

I did install it estimer through the link on the error, still not working

imjamesb avatar Dec 10 '21 17:12 imjamesb

Is the dotnet --info above from before or after? It shows you have .NET 3.1 but not ASP.NET 3.1 (not sure how you managed that).

  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Tratcher avatar Dec 10 '21 17:12 Tratcher

Unsure*

imjamesb avatar Dec 10 '21 17:12 imjamesb

Ok, what does it show now?

Tratcher avatar Dec 10 '21 17:12 Tratcher

C:\Users\krsjbr>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100\

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

imjamesb avatar Dec 10 '21 17:12 imjamesb

You're still missing Microsoft.AspNetCore.App 3.1. You installed dotnet-runtime-3.1.21-win-x64.exe? Try this one instead: https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-3.1.21-windows-hosting-bundle-installer

Tratcher avatar Dec 10 '21 17:12 Tratcher

Oh.. Thanks.. It works :D

imjamesb avatar Dec 10 '21 17:12 imjamesb

Re-opening to figure out why this link doesn't download the right installer: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64

It links to https://dotnet.microsoft.com/en-us/download/dotnet/3.1/runtime, when it should go to https://dotnet.microsoft.com/en-us/download/dotnet/3.1

Tratcher avatar Dec 10 '21 17:12 Tratcher

/cc @richlander @mairaw

sebastienros avatar Dec 13 '21 21:12 sebastienros

It links to dotnet.microsoft.com/en-us/download/dotnet/3.1/runtime, when it should go to dotnet.microsoft.com/en-us/download/dotnet/3.1

@Tratcher I think this is correct...the message indicated a missing runtime and provides a link to the specific runtime installers. Removing the /runtime in the URI takes you to the general download pages which becomes even more a choose-your-own-adventure place (do I need SDK, do I need linux, do i need...). The runtime download page (while still not perfect as I think this specific one should have just taken you to the server runtime bundle IMO) has the download links that provide you the version-specific downloads.

timheuer avatar Dec 14 '21 20:12 timheuer

@timheuer the link is aspnet specific, but 2/3's of the downloads on /3.1/runtime do no install aspnet. That's where the customer got confused. Most of the downloads offered on from /3.1 do include aspnet, or are at least much more clearly labeled.

Tratcher avatar Dec 14 '21 20:12 Tratcher

ack on the much-more clearly labeled! Yeah if the querystring has the absolute need, agreed giving the download direct is a better experience. I opine that the base download page is more confusing (wall of links) -- would love to see the runtime-specific links in this scenario just give me the right thing as it seems we have the info in the QS

timheuer avatar Dec 14 '21 20:12 timheuer

Giving a direct download is on our backlog and I hope my team is able to take on that work soon (timeline still TBD).

BTW, the info is in the QS, but when the request gets to the site that info has been lost. @richlander and I were trying to come up with a URL scheme that could work for different scenarios as well.

mairaw avatar Dec 14 '21 22:12 mairaw

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Dec 20 '21 21:12 ghost

@mairaw @bradygaster Any update on this? Should this issue be tracked somewhere else?

adityamandaleeka avatar Aug 02 '22 23:08 adityamandaleeka

This seems like a bug on the .NET site repo, can @mairaw transfer to there? Or create an issue to which we can link this one and close?

bradygaster avatar Aug 02 '22 23:08 bradygaster

We're still working on this. We can transfer this to the core repo if you'd like.

richlander avatar Aug 05 '22 03:08 richlander