nixpacks
nixpacks copied to clipboard
Configurable .NET Version
Feature request
Real senario: I need to deploy .NET 5, but by default Nixpacks builds with .NET 6. I can't change dotnet-sdk
to dotnet-sdk_5
right now. There's NIXPACKS_PKGS
but that's specifying additional packages.
Motivation
I want to deploy .NET 5.
Contribution
No response
What is the standard way of specifying the .NET version to use? Ideally, Nixpacks can detect this and install the correct version automatically.
What is the standard way of specifying the .NET version to use? Ideally, Nixpacks can detect this and install the correct version automatically.
Ah yes, almost forgot the correct way of doing that. I actually don't have an expert on .NET, I'm only deploying my school project for a while. Though I do have an idea: there is a .NET version specification spot in the .sln file (the .NET solution file), as well as in the .csproj file of each projects in the solution. Why it is that way is out of my knowledge, but that should be enough clue to start.
a .NET version specification spot in the .sln file (the .NET solution file), as well as in the .csproj file of each projects in the solution
This is great! We can use this info to install the correct version of .NET
You can use the SLN file, but I think the standard way to specify the build version is the global.json. Even just supporting the version
only for now would work, though I'm not sure how nix works with that?
We would absolutely take a PR for this but, as for doing it ourselves, we're working on more core features
Hey folks - wasn't sure whether to re-open this or raise a new issue, so happy to repost this elsewhere if this isn't the right place!
I've been trying to deploy a simple .NET 7 app, using the global.json
to specify a version (thanks for the PR @patrickserrano!! 🤘)
That said, I'm running into an issue where nixpacks doesn't seem to be installing any dotnet sdk at all to run, so the build is failing. Pastebin dump of the logs here
I think the issue lies here somewhere
#10 [6/9] RUN dotnet restore
#10 0.391 The command could not be loaded, possibly because:
#10 0.391 * You intended to execute a .NET application:
#10 0.391 The application 'restore' does not exist.
#10 0.391 * You intended to execute a .NET SDK command:
#10 0.391 A compatible .NET SDK was not found.
#10 0.391
#10 0.391 Requested SDK version: 7.0.0
#10 0.391 global.json file: /app/global.json
#10 0.391
#10 0.391 Installed SDKs:
#10 0.391
#10 0.391 Install the [7.0.0] .NET SDK or update [/app/global.json] to match an installed SDK.
#10 0.391
#10 0.391 Learn about SDK resolution:
#10 0.391 https://aka.ms/dotnet/sdk-not-found
#10 0.391 7.0.100 [/nix/store/v8zkpbqdkwihbd1bn19jasrs268mn4k8-dotnet-sdk-7.0.100/sdk]
As you can see, it's looking for version 7.0.0
but isn't finding any installed? Had similar results when I had the SDK set to 7.0.100
I had a look at the codebase, but I'm no 🦀🦀🦀 expert so wasn't able to figure out where the SDK installation step happens. Anyone able to help point me in the right direction?
Thanks!
@gavinroderick what version of .NET 7 are your specifying in global.json
? #813 looks like a similar issue that was solved by specifying the SDK version using the envar (docs: https://nixpacks.com/docs/providers/csharp)
NIXPACKS_CSHARP_SDK_VERSION=7.0
There's also a comment on that issue that the version is being parsed but that 7.0.200 needs to be added to /nix/store
but I'm not sure if that's the same issue you're running into.
edit: I think your log dump was cut off, looks like it's only 91 lines?
Hey @patrickserrano, I tried it using 7.0.0 and 7.0.100 and got the same result (via global.json)
I'll give it a whirl specifying via the nixpack variable you mentioned there and let you know how I get on!
Heyo - update for now, so that definitely worked to install the SDK correctly! 🥳
Got a new issue now where the publish stage is failing, might be the dotnet restore
not executing correctly?
#10 1.590 Determining projects to restore...
#10 3.905 Restored /app/tree.csproj (in 1.88 sec).
#10 DONE 4.0s
#11 [7/9] COPY . /app/.
#11 DONE 0.1s
#12 [8/9] RUN dotnet publish --no-restore -c Release -o out
#12 0.832 MSBuild version 17.4.0+18d5aef85 for .NET
#12 1.716 /nix/store/v8zkpbqdkwihbd1bn19jasrs268mn4k8-dotnet-sdk-7.0.100/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1064: Package Microsoft.EntityFrameworkCore.Analyzers, version 7.0.5 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [/app/tree.csproj]
#12 ERROR: process "/bin/bash -ol pipefail -c dotnet publish --no-restore -c Release -o out" did not complete successfully: exit code: 1
-----
> [8/9] RUN dotnet publish --no-restore -c Release -o out:
#12 0.832 MSBuild version 17.4.0+18d5aef85 for .NET
#12 1.716 /nix/store/v8zkpbqdkwihbd1bn19jasrs268mn4k8-dotnet-sdk-7.0.100/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1064: Package Microsoft.EntityFrameworkCore.Analyzers, version 7.0.5 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [/app/tree.csproj]
-----
I've been attempting to replicate it by running nixpacks locally, but the RUN stage in the Dockerfile is taking over 2000 seconds to complete 😢
➜ tree git:(main) ✗ nixpacks build . --name tree-built --env NIXPACKS_CSHARP_SDK_VERSION=7.0 --no-cache --build-cmd "dotnet publish --no-restore -c Release -o out --no-cache"
╔═══════════════════════════ Nixpacks v1.7.0 ═══════════════════════════╗
║ setup │ dotnet-sdk_7 ║
║───────────────────────────────────────────────────────────────────────║
║ install │ dotnet restore ║
║───────────────────────────────────────────────────────────────────────║
║ build │ dotnet publish --no-restore -c Release -o out --no-cache ║
║───────────────────────────────────────────────────────────────────────║
║ start │ ./out/tree ║
╚═══════════════════════════════════════════════════════════════════════╝
[+] Building 267.9s (7/13)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 895B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1681776169 0.7s
=> [internal] load build context 0.5s
=> => transferring context: 50.79MB 0.5s
=> [1/9] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1681776169@sha256:36f5490a9b305861621b83d86646ee2533c3760a0eac836685124ba6a25fea2b 0.0s
=> CACHED [2/9] WORKDIR /app/ 0.0s
=> [3/9] COPY .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix 0.0s
=> [4/9] RUN nix-env -if .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix && nix-collect-garbage -d 266.6s
=> => # checking whether printf supports POSIX/XSI format strings with positions... yes
=> => # checking for ssize_t... yes
=> => # checking whether stat handles trailing slashes on files... yes
=> => # checking for struct stat.st_atim.tv_nsec... yes
=> => # checking whether struct stat.st_atim is of type struct timespec... yes
=> => # checking for struct stat.st_birthtimespec.tv_nsec... no
Sidenote, yep that logdump got cut off - I think this one is the full set!