I have installed dotnet-sdk-7.0.101-win-x86.exe by downloading it and running it. This is verified by the fact that if I try to run it again it goes to a different screen where I can modify it.
I am attempting to follow the instructions for a course on Udemy on creating a console app, however I am purposely doing something different. In the course the instructor is explaining to set everything up under his user directory (in windows). I would like not to do that.
The reason I don't want to do that Is I have a folder already that has my work stuff in it and I want this to work for my work stuff also. For me, this folder is C:\SourceCode\ (something). I have a folder called GitHub that has all the repositories I've downloaded for work and I have another folder called 'Local' which I am using for learning. So, this is the output I try to create a new HelloWorld console app:
PS C:\SourceCode\Local\dotnet-course-code> dotnet new -n HelloWorld
The command could not be loaded, possibly because:
* You intended to execute a .NET application:
The application 'new' does not exist.
* You intended to execute a .NET SDK command:
No .NET SDKs were found.
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
PS C:\SourceCode\Local\dotnet-course-code>
I did some googling already to try to solve the problem, One insightful post had me run the following command which I believe proves that the dotnet thing was installed (but I could be wrong)
PS C:\SourceCode\Local\dotnet-course-code> Get-Command dotnet |Format-List
Name : dotnet.exe
CommandType : Application
Definition : C:\Program Files\dotnet\dotnet.exe
Extension : .exe
Path : C:\Program Files\dotnet\dotnet.exe
FileVersionInfo : File: C:\Program Files\dotnet\dotnet.exe
InternalName: .NET Host
OriginalFilename: .NET Host
FileVersion: 6,0,922,41905 @Commit: 163a63591cf9e9b682063cf3995948c2b885a042
FileDescription: .NET Host
Product: Microsoft® .NET Framework
ProductVersion: 6.0.9 @Commit: 163a63591cf9e9b682063cf3995948c2b885a042
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language: English (United States)
I would like to know why this doesn't work as expected. Note this is on a brand new machine running windows 11 and these commands are being run in powershell.
CodePudding user response:
This is the crucial part of the error message:
* You intended to execute a .NET SDK command:
No .NET SDKs were found.
In order to create source-code projects, you need to download the .NET SDK, specifically.
The presence of dotnet.exe
alone does not imply that an SDK installed, given that it is possible to install a runtime only.
If you run dotnet --info
, you'll see what SDKs and runtimes are installed.
If no SDK is listed, you'll have to install one.
Update: As you note, the problem was that you had accidentally created parallel installations (a x86 version alongside an x64 one), and the one you tried to use lacked an SDK.
Once one is installed, your command should work if you also specify a project type, which is required, as topsail points out; e.g., to create a console application in subfolder HelloWorld
:
# OK, once an SDK is installed.
dotnet new console -n HelloWorld