NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.84k stars 13.92k forks source link

buildDotnetModule doesn't support paths with spaces in them. #296467

Open TomaSajt opened 7 months ago

TomaSajt commented 7 months ago

Describe the bug

It looks like the current builder doesn't support space characters being present in paths.

I found this issue when trying to package https://github.com/Jessecar96/SteamDesktopAuthenticator (package request: https://github.com/NixOS/nixpkgs/issues/296345)

Note: It turns out the project still uses .NET Framework, so this will not be able to be packaged using .NET, however, the issue still exists nevertheless

I could fix the fetch-deps script by changing the array declarations to use lib.escapeShellArgs instead of toString

declare -a projectFiles=( ${lib.escapeShellArgs (lib.toList projectFile)} )
declare -a testProjectFiles=( ${lib.escapeShellArgs (lib.toList testProjectFile)} )

and using IFS="" when iterating through arrays

However, because the actual setup-hooks only have direct access to env-vars, they can't use this fixed-up version of the projectFile list.

Possible solution:

The escaped list could be passed down to the hooks just like nuget-source.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Try to build a dotnet package with a .csproj file which has a space in its path
  2. Get an error saying that the project file does not exist

Notify maintainers

@corngood @mdarocha @IvarWithoutBones

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.21, NixOS, 24.05 (Uakari), 24.05.20240313.4008381`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `""`
 - nixpkgs: `/nix/store/lqxyz6w393bxkgrlfwqazjh663cjpc3w-source`

Add a :+1: reaction to issues you find important.

TomaSajt commented 7 months ago

I'll make an attempt to fix this myself, but I am not 100% sure if I can do it. Edit: I gave up

eclairevoyant commented 7 months ago

Do you still have what you tried so far? I'll give it a go.

TomaSajt commented 7 months ago

Do you still have what you tried so far? I'll give it a go.

This is what I could come up with: https://github.com/TomaSajt/nixpkgs/tree/dotnet-space Perhaps the passing of the escaped list could be done in a different way. I tested this by trying to build this hello world project https://github.com/TomaSajt/dotnet-space-test/ but got some errors, and I could figure out where they came from