question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet run command should set DOTNET_ROOT environment variable

See original GitHub issue

#Repro steps

  • Install a local copy of the .NET Core SDK (ie unzip it to a local folder, or install it to a local folder using the dotnet-install script)
  • Create a new console app (dotnet new console)
  • Run the app via dotnet run

Expected

App runs

Actual

Host can’t find the right shared framework (unless a matching shared framework is also installed in the global location, such as Program Files).

Discussion

This is because we now copy the apphost as <appname>.exe, and dotnet run uses that apphost. Previously it used dotnet <appname>.dll, which had the context of where the dotnet root was, but the apphost by itself doesn’t have that context, so it only looks in the globally installed location.

We can fix this by setting the DOTNET_ROOT environment variable in dotnet run before launching the app. We could also consider always setting this environment variable, which we considered in the past.

These solutions still won’t help if <appname>.exe is launched directly instead of via a dotnet command. In the past we’ve discussed that probing the PATH from the muxer could help, but so far have decided against it.

FYI @natemcmaster @peterhuene

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
dsplaistedcommented, Oct 18, 2018

Note: This should set DOTNET_ROOT(x86) instead if the version of .NET is x86

1reaction
peterhuenecommented, Nov 3, 2018

I’m going to fix this now to get the CLI tests green.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the expected value for DOTNET_ROOT variable ...
I'm installing dotnet core on Linux ARM64 using tarball as explained here. After installing I followed the suggestion to set DOTNET_ROOT=$PATH:$ ...
Read more >
NET environment variables - .NET CLI
Specifies the location of the .NET runtimes, if they are not installed in the default location. The default location on Windows is C:\Program ......
Read more >
Setting up the .NET Core SDKs for Fire - Elements Docs
NET Core projects. Once installed, make sure the DOTNET_ROOT environment variable is set as outlined in the installation instructions, and the compiler and...
Read more >
NET Core Buildpack Reference
The DOTNET_ROOT environment variable specifies the path to the directory where .NET Runtimes and SDKs are installed. Set by: dotnet-core-runtime , dotnet-core- ...
Read more >
DOTNET_ROOT is not set properly when upgrading
The dotnet command is not affected (so `dotnet run` can be used perfectly). The variable is set in the dotnet.sh file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found