Following examples from here I'm trying to execute
dotnet sln AllProjects.sln add **/*.csproj
But I get this error:
Could not find project or directory
**/*.csproj
.
Looks like wildcards are not working. What am I doing wrong?
Following examples from here I'm trying to execute
dotnet sln AllProjects.sln add **/*.csproj
But I get this error:
Could not find project or directory
**/*.csproj
.
Looks like wildcards are not working. What am I doing wrong?
I've missed this statement:
Globbing patterns are supported on Unix/Linux based terminals
My Windows PowerShell solution looks like this:
$projects = Get-ChildItem -Recurse | Where-Object { $_.Name -match '^.+\.(csproj|vbproj)$' }
$uniqueProjects = $projects | Group-Object -Property Name | Where Count -EQ 1 | select -ExpandProperty Group | % { $_.FullName }
Invoke-Expression -Command "dotnet new sln -n AllProjects"
$uniqueProjects | % { Invoke-Expression -Command "dotnet sln AllProjects.sln add ""$_""" }
For Windows, open PowerShell and run this command to add all projects to the solution file:
dotnet sln add (ls -r **/*.csproj)
I've missed this statement:
Globbing patterns are supported on Unix/Linux based terminals
My Windows PowerShell solution looks like this:
$projects = Get-ChildItem -Recurse | Where-Object { $_.Name -match '^.+\.(csproj|vbproj)$' }
$uniqueProjects = $projects | Group-Object -Property Name | Where Count -EQ 1 | select -ExpandProperty Group | % { $_.FullName }
Invoke-Expression -Command "dotnet new sln -n AllProjects"
$uniqueProjects | % { Invoke-Expression -Command "dotnet sln AllProjects.sln add ""$_""" }
On Windows you could also use the following command to recursively add all the projects in sub-directories to a pre-existing solution file:
FOR /R %i IN (*.csproj) DO dotnet sln add "%i"
Alternatively, if you need to (re)create solution files often then you could create a batch file with the following content, and then just run it whenever you need to:
dotnet new sln
FOR /R %%i IN (*.csproj) DO dotnet sln add "%%i"
Please note that you need the extra % when trying to do this inside the batch file.
I tried ls -r on git bash
dotnet sln add (ls -r **/*.csproj)
but it gives me
$ dotnet sln add (ls -r **\*.csproj)
bash: syntax error near unexpected token `('
And then i tried
dotnet sln add **/*.csproj
it worked for me on git bash(windows)
For linux
find . -name "*.csproj" -print0 | xargs -0 dotnet sln add
find . -name "*.csproj" ! -name "exclude-this.csproj" -print0 | xargs -0 dotnet sln add
© 2022 - 2024 — McMap. All rights reserved.