简体   繁体   English

在一个目录下发布所有 .net 核心项目

[英]Publish all .net core projects in a directory

I have a main directory containing all of my various .NET core solutions in subdirectories under it.我有一个主目录,在它的子目录中包含我所有的各种 .NET 核心解决方案。 Is there a way for me to publish all of these projects at once instead of opening and publishing each separately in Visual Studio?有没有办法让我一次发布所有这些项目,而不是在 Visual Studio 中分别打开和发布每个项目?

You can do this with the dotnet command line interface .您可以使用dotnet 命令行界面执行此操作。

To do this, open a PowerShell terminal and cd into the root directory containing the various projects you want to publish.为此,请打开 PowerShell 终端并 cd 进入包含您要发布的各种项目的根目录。 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, eg MyProjectFolder/bin/debug/netcoreapp3.1/publish.这样做会将每个项目发布到其默认发布位置,例如 MyProjectFolder/bin/debug/netcoreapp3.1/publish。

To publish each project to a specified subdirectory, you can use the -o flag on the publish command.要将每个项目发布到指定的子目录,可以在发布命令上使用 -o 标志。 Eg in the above, substitute dotnet publish -o bin\Debug\myCustomPublishFolder for dotnet publish例如在上面,用dotnet publish -o bin\Debug\myCustomPublishFolder替换 dotnet dotnet publish

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM