"dotnet" is not recognized

Daniel ‪ 0 Reputation points
2023-01-30T14:38:11.9433333+00:00

I have installed a fresh Windows10, and downloaded the "dotnet-install.ps1" from Microsoft:

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

And I ran it with a powershell window:

> .\dotnet-install.ps1 -Channel 7.0 -Runtime windowsdesktop
dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.
dotnet-install: Extracting the archive.
dotnet-install: Adding to current process PATH: "C:\Users\daniel\AppData\Local\Microsoft\dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Note that the script does not resolve dependencies during installation.
dotnet-install: To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install/windows#dependencies
dotnet-install: Installed version is 7.0.2
dotnet-install: Installation finished

It says, instelled, however, when I try "dotnet" after this (within the same window):

> dotnet
dotnet : The term 'dotnet' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ dotnet
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (dotnet:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

And when I try running my application (dotnet 7):

User's image

If I rerun the install script, it tells me dotnet is already installed:

> .\dotnet-install.ps1 -Channel 7.0 -Runtime windowsdesktop
dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.
dotnet-install: .NET Core Windows Desktop Runtime with version '7.0.2' is already installed.

Note: I did the same with "Runtime dotnet", but I still can't run my application, and if I try dotnet from outside of Powershell (like in a cmd), "dotnet" is not found.

OS Details:

User's image

Any ideas, what am I missing? (Tried rebooting, reinstalling, same)
Shouldn't "windowsdesktop" runtime install "dotnet" core too?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,396 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 48,576 Reputation points
    2023-01-30T15:52:03.47+00:00

    dotnet-install is not really designed for use on your client machine. It is designed to be installed in a hosted/CI environment where the tool may not already be available, it is running in a sandbox such that you cannot install the tool normally, and once the build/task is complete you don't need the tool anymore. It does not modify paths or make the toolset available anywhere else. Note that as soon as you close whatever session you're running this script in then most likely the toolset is gone.

    To install dotnet you should install the dotnet SDK as discussed here. If you already have Visual Studio installed then you don't need to include anything.

    After it is installed then try the dotnet command. If it says it doesn't exist then it wasn't added to the path or your session variables have not been updated yet. Try starting a new session window. If that doesn't work then go to the environment variables in windows and ensure C:\program Files\dotnet is in the path. Then ensure the session refreshes and try again.

    0 comments No comments