The project flag doesn't search the provided path for a CSPROJ file #93

Open
opened 2026-01-29 16:29:22 +00:00 by claunia · 7 comments
Owner

Originally created by @AnthonyMastrean on GitHub (Dec 9, 2020).

The dotnet publish and dotnet run commands use a project flag or project positional argument that is able to search the path provided for a CSPROJ file.

$ dotnet run -p src/Example
$ dotnet publish -c Release -o out src/Example

But, the dotnet tarball command does not perform consistent searching. It fails and the CSPROJ file needs to be spelled out.

$ dotnet tarball -c Release -o out src/Example/
dotnet tarball (0.1.189+6ef34e121b)
Could not find the project file 'src/Example'.
Originally created by @AnthonyMastrean on GitHub (Dec 9, 2020). The `dotnet publish` and `dotnet run` commands use a `project` flag or project positional argument that is able to search the path provided for a CSPROJ file. ``` $ dotnet run -p src/Example ``` ``` $ dotnet publish -c Release -o out src/Example ``` But, the `dotnet tarball` command does not perform consistent searching. It fails and the CSPROJ file needs to be spelled out. ``` $ dotnet tarball -c Release -o out src/Example/ dotnet tarball (0.1.189+6ef34e121b) Could not find the project file 'src/Example'. ```
claunia added the enhancementup-for-grabs labels 2026-01-29 16:29:22 +00:00
Author
Owner

@qmfrederik commented on GitHub (Dec 9, 2020):

Thanks for the feedback. Sounds reasonable, I'd be willing to accept a PR which implements this :).

@qmfrederik commented on GitHub (Dec 9, 2020): Thanks for the feedback. Sounds reasonable, I'd be willing to accept a PR which implements this :).
Author
Owner

@AnthonyMastrean commented on GitHub (Dec 11, 2020):

Sure! I assume you'd want the same fix for all of the subcommands that support the project flag, right? Looks like the dotnet CLI commands either do this manually or forward the argument to msbuild.

Compare this

https://github.com/dotnet/sdk/search?q=FindSingleProjectInDirectory

to this

https://github.com/dotnet/sdk/search?q=SlnOrProjectArgument

@AnthonyMastrean commented on GitHub (Dec 11, 2020): Sure! I assume you'd want the same fix for _all_ of the subcommands that support the `project` flag, right? Looks like the dotnet CLI commands either do this manually or forward the argument to msbuild. Compare this https://github.com/dotnet/sdk/search?q=FindSingleProjectInDirectory to this https://github.com/dotnet/sdk/search?q=SlnOrProjectArgument
Author
Owner

@qmfrederik commented on GitHub (Dec 11, 2020):

Yeah, the FindSingleProjectInDirectory logic seems solid to me: b91b88aec2/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs (L288-L314)

The code which handles the command-line arguments is located in dotnet-rpm/PackagingRunner.cs, but is shared by all projects.

@qmfrederik commented on GitHub (Dec 11, 2020): Yeah, the `FindSingleProjectInDirectory` logic seems solid to me: https://github.com/dotnet/sdk/blob/b91b88aec2684e3d2988df8d838d3aa3c6240a35/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs#L288-L314 The code which handles the command-line arguments is located in `dotnet-rpm/PackagingRunner.cs`, but is shared by all projects.
Author
Owner

@AnthonyMastrean commented on GitHub (Dec 11, 2020):

Wait a minute... it looks like you already have this behavior coded?

https://github.com/qmfrederik/dotnet-packaging/blob/master/dotnet-rpm/PackagingRunner.cs#L240-L270

@AnthonyMastrean commented on GitHub (Dec 11, 2020): Wait a minute... it looks like you already have this behavior coded? https://github.com/qmfrederik/dotnet-packaging/blob/master/dotnet-rpm/PackagingRunner.cs#L240-L270
Author
Owner

@qmfrederik commented on GitHub (Dec 11, 2020):

Ah, look at that ;-). Not sure why it's not working for you, then?

@qmfrederik commented on GitHub (Dec 11, 2020): Ah, look at that ;-). Not sure why it's not working for you, then?
Author
Owner

@qmfrederik commented on GitHub (Dec 11, 2020):

Yeah, that logic doesn't work if you pass a directory instead of a full path to a project. Still happy to accept PRs, tough ;-)

@qmfrederik commented on GitHub (Dec 11, 2020): Yeah, that logic doesn't work if you pass a directory instead of a full path to a project. Still happy to accept PRs, tough ;-)
Author
Owner

@AnthonyMastrean commented on GitHub (Dec 11, 2020):

Yep, there it is... there's a File check, first. Well, that shouldn't be too hard to fix!

https://github.com/qmfrederik/dotnet-packaging/blob/master/dotnet-rpm/PackagingRunner.cs#L251-L255

@AnthonyMastrean commented on GitHub (Dec 11, 2020): Yep, there it is... there's a File check, first. Well, that shouldn't be too hard to fix! https://github.com/qmfrederik/dotnet-packaging/blob/master/dotnet-rpm/PackagingRunner.cs#L251-L255
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dotnet-packaging#93