好的傢伙,這是五月,我們還沒有從微軟的正式解決方案。我有一些使用Powershell和新的.NET核心CLI的工作。 dotnet.exe中已經有了一些命令來添加/刪除項目中的解決方案,所以這就是我想出的。
Includes.json
{
"Includes": [
"C:\\projects\\SomeProjectA\\src",
"C:\\git\\SomeProjectB\\src"
]
}
附加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
}
}
刪除,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
}
}
與使用舊的Global.json文件相比,這是一些額外的步驟,但它確實符合我們的需求。爲了使其非常方便,請添加一個解決方案文件夾幷包含Includes.json,以便您可以在Visual Studio中輕鬆修改它。
一些注意事項:
- 添加/刪除腳本幾乎完全一樣,唯一的區別是DOTNET SLN添加/刪除命令。這可能可以清理成一個交互式腳本。
- 您還可以更改內容,以便不必單獨添加/刪除腳本,只需閱讀Includes.json,然後通過解析.sln文件將其與目前解決方案中的項目進行比較。
只是想一想。這是回購,如果你想克隆/下載:https://github.com/rushfive/VS2017-Includes
可能重複[.net核心(csproj)global.json'項目'等效](http://stackoverflow.com/questions/42773815/net-core-的csproj-全球JSON-項目等效) – Set