.net core 终止以前的部署';NET内核的进程

.net core 终止以前的部署';NET内核的进程,.net-core,octopus-deploy,.net Core,Octopus Deploy,我正在尝试使用Octopus Deploy为我的.Net核心控制台应用程序设置部署。我最初的想法是在发布新版本之前按名称杀死旧版本的进程,但问题是所有的.Net核心进程都被称为“dotnet”。。。有没有办法以dll的名称终止.Net核心进程?使用PowerShell: $process = Get-Process | where {$_.Name -eq 'dotnet' -and $_.modules.ModuleName -eq 'test.dll'} if ($process) {

我正在尝试使用Octopus Deploy为我的.Net核心控制台应用程序设置部署。我最初的想法是在发布新版本之前按名称杀死旧版本的进程,但问题是所有的.Net核心进程都被称为“dotnet”。。。有没有办法以dll的名称终止.Net核心进程?

使用
PowerShell

$process = Get-Process | where {$_.Name -eq 'dotnet' -and $_.modules.ModuleName -eq 'test.dll'}
if ($process) {
    $process | Stop-Process -Force
}