`The command "dotnet paket restore" excited with code -532462766` on a fresh SAFE template
Hey guys, i never encountered this error before, but we wanted to setup a SAFE project for a new colleague and we got an error The command "dotnet paket restore" excited with code -532462766. We tested this also for a fresh SAFE stack and still the issue persists. I have no idea why this issue happens. We "solved" it by removing paket and using simple dotnet dependencies but this is obviously no real solution.
This is not my machine, but i will try to answer asap if you want more information on this. But i do not expect you to solve this obscure issue. Just wanted to let you know.
We also tried running dotnet watch run src/Server/Server.fsproj without fake with the same result and tried building the projects which worked just fine.
The machine uses:
- Win 11
- .net8.0, node 20 and npm 9
I've definitely seen this error code before. Last time it was to do with missing paket.references from the Shared directory causing Paket to use the wrong version of FSharp - this is now fixed as of 8 months ago.
Maybe these will help diagnose the issue:
- What version of the SAFE template is being used?
- What is the output of
dotnet --list-sdks? - What is the output of
dotnet build -v:d? (from thesrc/Serverdirectory)
Hello! Thanks for the quick response!
What version of the SAFE template is being used?
The newest version v5.0.6
What is the output of dotnet --list-sdks?
What is the output of dotnet build -v:d? (from the src/Server directory)
Duplicate of #612, thanks for your report @Freymaurer! the other issue has a workaround in the discussion
@baronfel ok. I've found some more information on this.
TLDR: If you dotnet watch build from the folder of the project, and you're using Paket, and a version of .NET 8 post 8.0.206, things go wrong. If you dotnet watch build from outside of the folder of the fsproj e.g. dotnet watch build src/server, then it works.
I suspect it's something that's changed since 8.0.206 that has somehow broken Paket. Here are some steps to reproduce:
- Install a version of .NET after 8.0.206 (I'm using 8.0.304).
dotnet new SAFE(I'm using 5.0.7).dotnet watch build src/server- works ✅cd src/serverdotnet watch build- pops ❌dotnet build- works ✅- Change
global.jsonto pin to8.0.206. dotnet watch build- works ✅- Revert change to
global.json. - Clear out everything in
Server.fsto just e.g
module Server
[<EntryPoint>]
let main _ = 0
- In
Server.fsproj, remove the reference to Shared and the Import ofPaket.Restore.targets. dotnet watch build- works ✅
I don't always get a stack trace but when I do, it's this:
dotnet watch � Started
Determining projects to restore...
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neut
ral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, Objec
tHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
at System.StartupHookProvider.ProcessStartupHooks()
C:\Users\IsaacAbraham\code\safeFoo\.paket\Paket.Restore.targets(171,3): error MSB3073: The command "dotnet paket restore" exited with
code -532462766. [C:\Users\IsaacAbraham\code\safeFoo\src\Server\Server.fsproj]
Also tagging @forki as it could relate to Paket.
Update 1
I've just observed that the "workaround" of calling it from a different folder does not work for dotnet watch run. It only works for dotnet watch build.
Hello there - just went to update my Mortgage app and hit exactly this! Great timing haha
FYI my temp workaround was to just add --no-restore to the dotnet watch run command
ooooh that's interesting
I was even thinking to add that to the template anyway because it's rarely needed anyway as part of watch run.
experiencing the same error on mac os/x
.paket/Paket.Restore.targets(171,3): error MSB3073: The command "dotnet paket restore" exited with code 134. [src/Shared/Shared.fsproj]
and the @isaacabraham workaround above of pinning the .net sdk in global.json to 8.0.204 works.
I've rerun the failing test thread above and both .NET SDK 8.0.400 and 9.0.100-rc.1 work like a charm - I'd highly suggest moving to those feature bands. As it is, this is a regression only on the 8.0.3xx branch from what I can see.
I'm on 401 and still seeing it. I've also determined that the issue ONLY occurs with the Sdk.Web SDK, not the "regular" one.
I came across this error when trying to upgrade .NET6 and .NET7 Safe stack apps to .NET8. With the help of an old Senior Dev., these are the steps that I have been taking to successfully upgrade to .NET8:
- Change
net6.0(ornet7.0) tonet8.0in all .fsproj files, paket.dependencies, and paket.lock - Change sdk version in global.json to
8.0.303(or whatever newest version you have downloaded) - Replace
"server", dotnet "watch run" serverPathwith"server", dotnet "watch run --no-restore" serverPathin the Run target in Build.fs - Remove all version pins in paket.dependencies
- Update all tools individually with
dotnet tool update {tool} - If the
Sharedfolder doesn't have a paket.references file, add one. (You may need todotnet paket addFSharp.Core and FsToolkit.Errorhandling to this paket.references file depending on the build errors you get) dotnet restorefrom both the Server and Shared foldersdotnet paket installfrom rootdotnet paket updatefrom rootdotnet run Clean- Delete bin and obj folders
dotnet run- Fix any build/compilation errors that may have popped up because of the updated dependencies
These are the steps that have worked for me at least. Yours might look slightly different.
This worked for me https://github.com/dotnet/sdk/issues/43468#issuecomment-2437600057
this issue is resolved by #634