Why does the dotnet watch publish command not work after update?

59 views Asked by At

When I run dotnet watch publish it appears to be ignoring the publish command and trying to do run instead.

This is the error:

PS D:\Development\ProjectOne> dotnet watch publish --project Client/ --configuration Release
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...

I tried running with and without the publish command and same result also tried with different configurations but no dice.

1

There are 1 answers

0
Case 303 On

Add a global.json file to the directory where commands are being executed, specifying the desired .NET SDK version.

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

references: dotnet watch, dotnet publish, dotnet run, Select the .NET version to use, global.json overview


I ran this command with the verbose option.

dotnet watch --verbose --project test_project.csproj publish --configuration Release

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

A known issue where dotnet watch prefixes the input command with run.

Found several reports of this issue on Github: dotnet watch broken in 8.0.100, dotnet-watch support for publish subprocess