"You must install .NET to run this application"
Spongman opened this issue ยท 8 comments
Description
all the other issues realted to this error message are either closed, or contain irrelevant information.
this is a trivial repro case that shows that the scripted dotnet sdk install is fundamentally broken.
Reproduction Steps
run a rocky9 docker container:
docker run -it rockylinux:9 /bin/bash
in the container's bash prompt, run the following commands:
dnf install -qy libicu # required library
curl -s https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash # install dotnet sdk
export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools # add dotnet and tools to path
dotnet --info
dotnet tool install --global dotnet-outdated-tool # install a tool
dotnet tool list --global # demonstrate that it's installed correctly
dotnet-outdated # attempt to run it
this will install the latest dotnet SDK, install a command (dotnet-outdated-tool
), and attempt to run it.
the entire output is:
Importing GPG key 0x350D275D:
Userid : "Rocky Enterprise Software Foundation - Release key 2022 <releng@rockylinux.org>"
Fingerprint: 21CB 256A E16F C54C 6E65 2949 702D 426D 350D 275D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
Installed:
libicu-67.1-9.el9.x86_64
dotnet-install: Attempting to download using aka.ms link https://dotnetcli.azureedge.net/dotnet/Sdk/8.0.401/dotnet-sdk-8.0.401-linux-x64.tar.gz
dotnet-install: Remote file https://dotnetcli.azureedge.net/dotnet/Sdk/8.0.401/dotnet-sdk-8.0.401-linux-x64.tar.gz size is 211866896 bytes.
dotnet-install: Extracting archive from https://dotnetcli.azureedge.net/dotnet/Sdk/8.0.401/dotnet-sdk-8.0.401-linux-x64.tar.gz
dotnet-install: Downloaded file size is 211866896 bytes.
dotnet-install: The remote and local file sizes are equal.
dotnet-install: Installed version is 8.0.401
dotnet-install: Adding to current process PATH: `/root/.dotnet`. Note: This change will be visible only when sourcing script.
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, select your operating system and check the "Dependencies" section.
dotnet-install: Installation finished successfully.
.NET SDK:
Version: 8.0.401
Commit: 811edcc344
Workload version: 8.0.400-manifests.b6724b7a
MSBuild version: 17.11.4+37eb419ad
Runtime Environment:
OS Name: rocky
OS Version: 9.3
OS Platform: Linux
RID: linux-x64
Base Path: /root/.dotnet/sdk/8.0.401/
.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.
Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5
.NET SDKs installed:
8.0.401 [/root/.dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [/root/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [/root/.dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.401
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
You can invoke the tool using the following command: dotnet-outdated
Tool 'dotnet-outdated-tool' (version '4.6.4') was successfully installed.
Package Id Version Commands
------------------------------------------------------
dotnet-outdated-tool 4.6.4 dotnet-outdated
You must install .NET to run this application.
App: /root/.dotnet/tools/dotnet-outdated
Architecture: x64
App host version: 8.0.8
.NET location: Not found
Learn more:
https://aka.ms/dotnet/app-launch-failed
Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=rocky.9&apphost_version=8.0.8
Expected behavior
sdk is functional after install
Actual behavior
"You must install .NET to run this application"
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
This belongs to dotnet/sdk repo. Not sure why --allow-roll-forward
is not helping global tools either (which is new in .NET 9 #37231). Maybe it requires #38210?
Workaround is to install it locally with the manifest option:
# install it for this project once
$ dotnet tool install --local --create-manifest-if-needed dotnet-outdated-tool
# use it with `dotnet` executable
$ dotnet dotnet-outdated
We'd need a runtime host trace to be certain about what's going on here. My suspicion is that DOTNET_ROOT
not being set is making it hard for global tools (which are Framework-dependent tools, remember!) to find the installed runtime.
Ah, spot on! That was a simpler explanation; one I almost always forget! export DOTNET_ROOT=~/.dotnet
fixed it! ๐
@baronfel, is there a way we can make the flow fallback to DOTNET_HOST_PATH
before giving up and issuing that error? I assume the number of times this "set DOTNET_ROOT
and you are good to go" has resolved the problem as in; https://github.com/search?q=org%3Adotnet+DOTNET_ROOT+%22You+must+install+.NET+to+run+this+application%22&type=issues, it doesn't seem like (or I don't see how) there is any harm in that sort of a fallback.
Dockerfile with the fix:
FROM rockylinux:9
RUN dnf install -qy libicu
RUN curl -s https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash
ENV PATH=${PATH}:/root/.dotnet:/root/.dotnet/tools
ENV DOTNET_ROOT=/root/.dotnet
# ^ this is the fix
RUN dotnet tool install --global dotnet-outdated-tool
RUN dotnet new console -n foo
RUN cd foo && dotnet-outdated
DOTNET_HOST_PATH
is only a setting that applies during MSBuild
at the moment - nothing actually in the .NET Runtime looks for or cares about it. It's used by tools within the context of a build to know where to find the dotnet
to use when spawning tools. The goal is to make sure that all spawned processes use the same dotnet
for the duration of a given build, that's all.
Ah, oops. I used it in roslyn and started advocating others to use it too https://github.com/search?q=org%3Adotnet+DOTNET_HOST_PATH&type=code ๐
Yes, it's a bit contentious right now across the product group. We're a bit scatter-brained across various teams here.