dotnet watch build with --project option raises MSB1001
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
Running `dotnet watch --project build` causes MSBuild to receive `--project` again, immediately failing with `MSB1001: Unknown switch`. The watch process exits before it can build the requested project.
### To Reproduce
1. Run: `mkdir sampleProj; cd sampleProj`
2. Run: `dotnet new console`
3. Run: `cd -`
4. Run: `dotnet watch --project sampleProj build`
### Exceptions (if any)
```
MSBUILD : error MSB1001: Unknown switch.
Full command line: '/usr/local/share/dotnet/sdk/10.0.101/DotnetTools/dotnet-watch/10.0.101/tools/net10.0/any/../../../../../../MSBuild.dll -maxcpucount --verbosity:m -tlp:default=auto --property:NuGetInteractive=true --restoreProperty:NuGetInteractive=true --restoreProperty:EnableDefaultCompileItems=false --restoreProperty:EnableDefaultEmbeddedResourceItems=false --restoreProperty:EnableDefaultNoneItems=false --project sampleProj -consoleloggerparameters:Summary -restore -distributedlogger:Microsoft.DotNet.Cli.Commands.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/10.0.101/dotnet.dll*Microsoft.DotNet.Cli.Commands.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/10.0.101/dotnet.dll -nologo'
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 watch 🛑 Shutdown requested. Press Ctrl+C again to force exit.
```
### Further technical details
details of dotnet --info
.NET SDK:
Version: 10.0.101
Commit: fad253f51b
Workload version: 10.0.101.1
MSBuild version: 18.0.6+fad253f51
Runtime Environment:
OS Name: Mac OS X
OS Version: 26.1
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/10.0.101/
.NET workloads installed:
[wasm-tools]
Installation Source: SDK 10.0.100
Manifest Version: 10.0.101/10.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.workload.mono.toolchain.current/10.0.101/WorkloadManifest.json
Install Type: FileBased
[maui-ios]
Installation Source: SDK 10.0.100
Manifest Version: 10.0.1/10.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.sdk.maui/10.0.1/WorkloadManifest.json
Install Type: FileBased
[wasi-experimental]
Installation Source: SDK 10.0.100
Manifest Version: 10.0.101/10.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.workload.mono.toolchain.current/10.0.101/WorkloadManifest.json
Install Type: FileBased
[maui]
Installation Source: SDK 10.0.100
Manifest Version: 10.0.1/10.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.sdk.maui/10.0.1/WorkloadManifest.json
Install Type: FileBased
[wasm-experimental]
Installation Source: SDK 10.0.100
Manifest Version: 10.0.101/10.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.workload.mono.toolchain.current/10.0.101/WorkloadManifest.json
Install Type: FileBased
Configured to use workload sets when installing new manifests.
Host:
Version: 10.0.1
Architecture: arm64
Commit: fad253f51b
.NET SDKs installed:
8.0.302 [/usr/local/share/dotnet/sdk]
9.0.301 [/usr/local/share/dotnet/sdk]
9.0.302 [/usr/local/share/dotnet/sdk]
10.0.100 [/usr/local/share/dotnet/sdk]
10.0.101 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.33 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
x64 [/usr/local/share/dotnet/x64]
registered at [/etc/dotnet/install_location_x64]
Environment variables:
DOTNET_ROOT [/Users/yamachu/.dotnet]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.