dotnet / dotnet/sdk

File-based apps: `dotnet build --file` behaves inconsistently with `dotnet run --file`

Open
#54,808 1 comment 0 reactions 0 assignees View on GitHub
Area-run-file untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

Repro:

1) Open some directory containing a file-based app `app.cs`.
2) Use `dotnet run --file app.cs`. Observe that it runs.
3) Use `dotnet build --file app.cs`. Observe output like the following:

```sh
> dotnet build --file app.cs
Warning: 'app.cs' appears to be a file-based app but was treated as an MSBuild argument. To treat it as a file-based app, use 'dotnet build app.cs'.
MSBUILD : error MSB1001: Unknown switch.
Full command line: '...'
Switches appended by response files:
Switch: --file
```

I imagine the current behavior is already known and there are reasons for the behavior.

I just thought I would raise the ergonomic concern anyway. I would like to be able to just be able to pass `--file ` to whatever command, whether it's `dotnet run`, `build`, `restore`, or something else, to make sure a file-based app is used. The difference in support across commands is a "decoder ring".

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.