Reputation: 1006
I have a main directory containing all of my various .NET core solutions in subdirectories under it. Is there a way for me to publish all of these projects at once instead of opening and publishing each separately in Visual Studio?
Upvotes: 2
Views: 3470
Reputation: 1006
You can do this with the dotnet command line interface.
To do this, open a PowerShell terminal and cd into the root directory containing the various projects you want to publish. From there, run the following:
$paths = Get-ChildItem -include *.csproj -Recurse
foreach($pathobject in $paths)
{
cd $pathobject.directory.fullName
dotnet publish
}
Doing this will publish every project into its default publish location, e.g. MyProjectFolder/bin/debug/netcoreapp3.1/publish.
To publish each project to a specified subdirectory, you can use the -o flag on the publish command. E.g. in the above, substitute dotnet publish -o bin\Debug\myCustomPublishFolder
for dotnet publish
Upvotes: 1