Open SDAChess opened 2 years ago
Can you precise which nixpkgs version (ideally the commit) you tested this on?
21.11.336103.40ef692a55b
If that is what you are looking for?
Well, as you see in the error, dotnet-sdk expects the framework to be found under /usr
. This won't work on NixOS, since it doesn't use the standard FHS.
I see several approaches to fix this:
dotnet <your-app>.dll
. Every dotnet build generates a native binary and a platform-independant .dll file, which contains all logic. In the default framework-dependant build, the native binary does the equivalent to running dotnet <your-app>.dll
DOTNET_ROOT
or install_location
. This can be made into a NixOS module. But I don't think this fits the existing NixOS modules - no other compiler has a module, and I don't think global installation of such tools should be encouraged (instead using per-project shell.nix
or similar)The workaround to this problem should probably be better documented in the nixpkgs manual.
Configure your system to set [...]
DOTNET_ROOT
[...] using per-projectshell.nix
or similar
Something like this?
pkgs.mkShell {
packages = [ pkgs.dotnet-sdk ]; # including dotnet-runtime here means the CLI is its copy and it doesn't see the SDK...
shellHook = ''export DOTNET_ROOT="${pkgs.dotnet-runtime}"'';
}
Can't the dotnet-runtime
package include a hook for this in /nix-support
?
Configure your system to set [...]
DOTNET_ROOT
[...] using per-projectshell.nix
or similarSomething like this?
pkgs.mkShell { packages = [ pkgs.dotnet-sdk ]; # including dotnet-runtime here means the CLI is its copy and it doesn't see the SDK... shellHook = ''export DOTNET_ROOT="${pkgs.dotnet-runtime}"''; }
Can't the
dotnet-runtime
package include a hook for this in/nix-support
?
Yup, something like this.
Adding it to a setup hook seems like a good idea that might make dev shells easier to work with. Dunno if it will affect packages installed with nix-env
or nixosConfiguration
, and if it will break any packages in nixpkgs. You can still make a PR and we'll test it out.
Describe the bug
When trying to execute dotnet generated binaries, the dotnet linker fails to find the root of the dotnet installation (DOTNET_ROOT).
Steps To Reproduce
Create the following files: Test.csproj
Program.cs
Execute
dotnet build
to compile the "project".Executing
dotnet run
works fine but./bin/Debug/net5.0/Test
crashes with the following error:Setting the
DOTNET_ROOT
environment variable to the path given bywhereis dotnet
fixes the issue.Additional context
I tested this on
dotnet-sdk_5
anddotnet-sdk_6
packages and both have the same issue.Notify maintainers
Hello, @kuznero :wave: