dotnet

Attempting to build dotnet apps fails at dotnet restore step. Tried with two brand-new projects, minimal APIs in F# and C#, nothing fancy. Previously building and deploying single-project repos was a breeze - would love to not have to manually add a dockerfile. Targeting the .NET 8 runtime - project created with dotnet new web, spun it up locally to make sure it worked, pushed to github and tried to deploy. Projects: 9687eb42-691c-430b-962b-9129b1705d22 0301d141-a811-4b07-9474-a46be8801627
Dockerfile:19
-------------------
17 | # install phase
18 | COPY . /app/.
19 | >>> RUN dotnet restore
20 |
21 | # build phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c dotnet restore" did not complete successfully: exit code: 1

Error: Docker build failed
Dockerfile:19
-------------------
17 | # install phase
18 | COPY . /app/.
19 | >>> RUN dotnet restore
20 |
21 | # build phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c dotnet restore" did not complete successfully: exit code: 1

Error: Docker build failed
Solution:
it doesn't look like the f sharp provider supports specifying a SDK version, you would have to write a simple dockerfile for that
Jump to solution
19 Replies
Percy
Percy4mo ago
Project ID: 9687eb42-691c-430b-962b-9129b1705d22,0301d141-a811-4b07-9474-a46be8801627
memarino92
memarino92OP4mo ago
Whoops forgot to update title to something better
Brody
Brody4mo ago
please include the actual error
memarino92
memarino92OP4mo ago
The error from the build output is included below the project IDs
Brody
Brody4mo ago
that is just a log saying there was an error
memarino92
memarino92OP4mo ago
Where would I find the error?
Brody
Brody4mo ago
further up in the logs
memarino92
memarino92OP4mo ago
Ah this is it, couldn't read the whole thing until I copied it out of the log viewer
#10 1.249 Determining projects to restore...
#10 1.258 /nix/store/0f43yfx91hg74bcp66qkbp97zv3ln27i-dotnet-sdk-6.0.413/sdk/6.0.413/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [/app/my-first-giraffe.fsproj]
#10 ERROR: process "/bin/bash -ol pipefail -c dotnet restore" did not complete successfully: exit code: 1

#10 1.249 Determining projects to restore...
#10 1.258 /nix/store/0f43yfx91hg74bcp66qkbp97zv3ln27i-dotnet-sdk-6.0.413/sdk/6.0.413/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [/app/my-first-giraffe.fsproj]
#10 ERROR: process "/bin/bash -ol pipefail -c dotnet restore" did not complete successfully: exit code: 1

The builder doesn't have the correct sdk installed
Brody
Brody4mo ago
may I ask why you thought the portion of the build logs you included was the error? perhaps the scroll bar didn't show?
memarino92
memarino92OP4mo ago
Been a while since I had to parse through these - saw something that said ERROR pointing to the step that failed
Brody
Brody4mo ago
try setting NIXPACKS_CSHARP_SDK_VERSION https://nixpacks.com/docs/providers/csharp
memarino92
memarino92OP4mo ago
Nice, thanks! Worked great for the C# project, no effect on the F#, which isn't that surprising since the F# nixpacks docs page doesn't mention it wonder if the global.json method would work
Solution
Brody
Brody4mo ago
it doesn't look like the f sharp provider supports specifying a SDK version, you would have to write a simple dockerfile for that
memarino92
memarino92OP4mo ago
Bummer, - but thanks for the help! Just a heads up, it appears that the C# provider, even with the NIXPACKS_CSHARP_SDK_VERSION version set, is using a preview version of dotnet 8 - which hit GA last November.
Brody
Brody4mo ago
may I ask why that's a bummer? you get far more control over how your app is built with a dockerfile
memarino92
memarino92OP4mo ago
I'm into Railway for the no-fuss deployment, and usually everything "just works". Haven't touched a dockerfile in a couple years since I switched jobs and love just being able to git-push and it does its thing. I know it's trivial to set up, but it's really just the fact that I have to do it at all
Brody
Brody4mo ago
I see, thank you
memarino92
memarino92OP4mo ago
Of course, and thanks again! Do I mark this as solved or is that a you thing?
Brody
Brody4mo ago
that one because it's going to be the answer to not using a preview version
Want results from more Discord servers?
Add your server