In VS 2015, we used to be able to specify a local path in global.json like so:
{
“projects”: [ “src”, “test”, “C:\\\\path\\\\to\\\\other\\\\projects” ]
}
Alright guys, it's May and we still don't have an official solution from Microsoft. I got something working using Powershell and the new .NET core CLI. There's already commands built into dotnet.exe to add/remove solutions from a project, so here's what I came up with.
Includes.json
{
"Includes": [
"C:\\projects\\SomeProjectA\\src",
"C:\\git\\SomeProjectB\\src"
]
}
Add-Includes.ps1
echo "Beginning import of projects in Includes.json"
$JsonIncludes = (Get-Content -Raw -Path "Includes.json") | ConvertFrom-Json
$IncludePaths = $JsonIncludes.Includes;
foreach ($IncludePath in $IncludePaths) {
$ProjectFiles = Get-ChildItem ($IncludePath + "\*") `
-Include *.csproj `
-Recurse `
| % {$_.FullName }
foreach ($ProjectFile in $ProjectFiles) {
dotnet sln add $ProjectFile
}
}
Remove-Includes.ps1
echo "Beginning removal of projects in Includes.json"
$JsonIncludes = (Get-Content -Raw -Path "Includes.json") | ConvertFrom-Json
$IncludePaths = $JsonIncludes.Includes;
foreach ($IncludePath in $IncludePaths) {
$ProjectFiles = Get-ChildItem ($IncludePath + "\*") `
-Include *.csproj `
-Recurse `
| % {$_.FullName }
foreach ($ProjectFile in $ProjectFiles) {
dotnet sln remove $ProjectFile
}
}
It's a couple extra steps compared to using the old Global.json file, but it does what we need. To make it really convenient, add a solution folder and include the Includes.json so you can easily modify it from within Visual Studio.
Some notes:
Just food for thought. Here's the repo if you want to clone/download: https://github.com/rushfive/VS2017-Includes