citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.45k stars 2.05k forks source link

[FxDK] C# Resource won't auto-restart #2419

Open case303 opened 5 months ago

case303 commented 5 months ago

What happened?

Saving files in either the Client or Server projects doesn't restart the resource in FxDK. Noticed code changes weren't taking affect in FxDK Game view. No indication in either Client or Server consoles that a resource was restarted.

Expected result

resource should restart automatically

Reproduction steps

  1. Open Cfx.re Development Kit (FiveM)
  2. Create a New Resource (C#)

Server console:

citizen-server-fxdk     . Done loading resources
citizen-server-fxdk     Starting 1 resources
resources:test_project_05   Warning: could not find client_script `Client/bin/Release/**/publish/*.net.dll` (defined in fxmanifest.lua:12)
resources:test_project_05   Warning: could not find server_script `Server/bin/Release/**/publish/*.net.dll` (defined in fxmanifest.lua:13)
resources:test_project_05   Warning: could not find file `Client/bin/Release/**/publish/*.dll` (defined in fxmanifest.lua:10)

Importancy

Unknown

Area(s)

FxDK

Specific version(s)

FiveM (b2699), 7545, FxDK (1.63.2-cfx), Windows

Additional information

As a sanity check I created a fresh C# project to see how it behaved.

Discovered the Watch commands output window while troubleshooting this. Wanted to confirm this output is expected:

dotnet watch 🚀 Started
Unable to run your project.
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.
A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'.
The current OutputType is 'Library'.
dotnet watch ❌ Exited with error code 1
dotnet watch ⏳ Waiting for a file to change before restarting dotnet...

Why won't the resource restart automatically?

Let me know if you need any additional info.

case303 commented 5 months ago

Added verbose to the fxdk_watchcommand arguments for more info in Watch commands output_ fxdk_watch_command 'dotnet' {'watch', '--verbose', ...

case303 commented 5 months ago

checked out: dotnet watch, dotnet publish, & dotnet run

included --verbose running this dotnet CLI command directly from the Command Prompt, from the solution root. dotnet watch --verbose --project Server/test_project_05.Server.csproj publish --configuration Release

dotnet watch 🚀 Started
Running dotnet with the following arguments: 'run publish --configuration Release'
Unable to run your project.
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.
A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'.
The current OutputType is 'Library'.

noticed: Running dotnet with the following arguments: 'run publish --configuration Release'

removed the run command: and it executes like a charm! dotnet publish --configuration Release
instead of dotnet run publish --configuration Release

found several reports of this in Github: dotnet watch broken in 8.0.100 dotnet-watch support for publish subprocess

discovered that I have 8.0.2 installed. dotnet --info


checked out: Select the .NET version to use, global.json overview

added a global.json file to the solution's root directory, specifying the desired .NET SDK vrsion.

{
  "sdk": {
    "version": "7.0.0",
    "rollForward": "minor",
    "allowPrerelease": false
  }
}

I've had success testing with version 5 & 7, haven't tried with 6. This works with Visual Studio 2022 17.6.4. fxmanifest.lua unharmed.