dotnet sln add

Published on Friday, August 17, 2018

It's been a while since I'd created a number dotnet projects and supporting solution using the command line so I had to refer to the documentation to keep me right. As I had just created a number of projects adding each one to the solution is a little tedious so when I'd spotted I could use globbing patterns I thought this would save time and a few key presses.

However, when I ran dotnet sln Foo.sln add **/*.csproj I was presented with the error Could not find project or directory **/*.csproj. It turns out that globbing is not actually supported by the CLI but actually a shell feature and PowerShell wasn't expanding the glob. Luckly as dotnet is cross platform and I have Windows Subsystem for Linux installed with all the dotnet goodness I could switch to bash, ensure globbing was enabled using shopt -s globstar, and then run dotnet sln Foo.sln add **/*.csproj to add all my new projects, job done...