Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet watch test at the solution level provides an incorrect error message #45761

Open
dhazel opened this issue Jan 7, 2025 · 3 comments
Open

Comments

@dhazel
Copy link

dhazel commented Jan 7, 2025

Issue Description

On the CLI, dotnet watch test at the solution level no longer supports the --project flag, but its error message says that it does.

Steps to Reproduce

  1. Given a solution that contains multiple projects, where one of those projects is a test project
  2. Open a command line and navigate to the root of the solution (ie: the directory containing the .sln file)
  3. Attempt to run the following command: dotnet watch test
  4. Note that the command fails and returns an error text saying the following:
Could not find a MSBuild project file in 'C:\path\to\my\solution'. Specify which project to use with the --project option.
  1. Note that the above error text is the same error text that was returned by dotnet 8 under the same circumstances
  2. Attempt to run the following command: dotnet watch test --project '.\mytestproject\mytestproject.csproj'
  3. Note that the command fails and returns an error text saying the following:
MSBUILD : error MSB1001: Unknown switch.
    Full command line: 'C:\Program Files\dotnet\sdk\9.0.101\MSBuild.dll -maxcpucount -verbosity:m -tlp:default=auto -nologo -restore --property:VsTestUseMSBuildOutput=true -target:VSTest -nologo --project '.\mytestproject\mytestproject.csproj' -property:VSTestArtifactsProcessingMode=collect -property:VSTestSessionCorrelationId=48976_6a64fb8f-6486-4ca6-932b-526532e90e49'
  Switches appended by response files:
Switch: --project

For switch syntax, type "MSBuild -help"
  1. Note that this error text is new, the command from step (6) used to work under dotnet 8, and the error text from step (7) contradicts the error text from step (4).

Expected Behavior

Error text should suggest options that the command supports, not nonexistent options

Actual Behavior

The two error messages contradict eachother

Analysis

  • This appears to be a regression
  • Does the dotnet team wish to support watching tests from the solution level, or do they wish for the user to navigate to the directory of the test project in order to watch tests? It seems simplest for the dotnet team to not have to support the --project flag.

Versions & Configurations

dotnet version: 9.0.101
msbuild version: 17.12.12.57101

@baronfel baronfel transferred this issue from dotnet/msbuild Jan 7, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels Jan 7, 2025
@dhazel dhazel changed the title dotnet watch test at the solution level no longer supports the --project flag dotnet watch test at the solution level provides an incorrect error message Jan 8, 2025
@nagilson nagilson added Area-Watch and removed untriaged Request triage from a team member labels Jan 14, 2025
@nagilson nagilson removed their assignment Jan 14, 2025
@nagilson
Copy link
Member

@tmat Have you seen this dotnet watch issue before?

@Kampfmoehre
Copy link

Kampfmoehre commented Jan 16, 2025

I got the same error when trying to build in watch mode while refactoring:

$ dotnet watch --project src/<project>/ build
MSBUILD : error MSB1001: Unknown switch.
    Full command line: '/usr/lib64/dotnet/sdk/9.0.101/MSBuild.dll -maxcpucount -verbosity:m -tlp:default=auto -nologo -restore -consoleloggerparameters:Summary --project src/<project>/'
  Switches appended by response files:
Switch: --project

For switch syntax, type "MSBuild -help"
dotnet watch ❌ Exited with error code 1
dotnet watch ⏳ Waiting for a file to change before restarting dotnet...

I also tried

$ dotnet watch build --project src/<project>/

but with the same result.

Dotnet info output:

$ dotnet --info
.NET SDK:
 Version:           9.0.101
 Commit:            f303476b53
 Workload version:  9.0.100-manifests.6bf02610
 MSBuild version:   17.12.12+f303476b5

Runtime Environment:
 OS Name:     fedora
 OS Version:  41
 OS Platform: Linux
 RID:         fedora.41-x64
 Base Path:   /usr/lib64/dotnet/sdk/9.0.101/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       f303476b53

.NET SDKs installed:
  8.0.111 [/usr/lib64/dotnet/sdk]
  9.0.101 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.11 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.11 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/usr/lib64/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Adding two additional dashes seems to work, but it uses run instead of build:

$ dotnet watch --project src/<project>/ -- build

@FlukeFan
Copy link

Is this a duplicate of #45634 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants