C# 在visual studio中将.net核心应用程序部署到linux?
我正在Visual Studio 2017中构建.net核心应用程序。我想将我的发布过程自动化到linux机器上 这是我当前的流程:C# 在visual studio中将.net核心应用程序部署到linux?,c#,linux,visual-studio,publish,C#,Linux,Visual Studio,Publish,我正在Visual Studio 2017中构建.net核心应用程序。我想将我的发布过程自动化到linux机器上 这是我当前的流程: 在Visual Studio中,单击“发布”选项卡,选择“发布” 打开WinSCP,登录到目标linux计算机 打开文件夹solution\myapp\bin\Release\netcoreapp2.2\publish\ CTRL+A在发布文件夹中选择全部,CTRL+C复制所有文件,然后CTRL+V粘贴到WinSCP目标目录中 打开PuTTY,登录到目标linux
WinSCP
,登录到目标linux计算机solution\myapp\bin\Release\netcoreapp2.2\publish\
WinSCP
目标目录中PuTTY
,登录到目标linux计算机,使用dotnet myapp.dll重新启动应用程序
dotnet publish-ssh --ssh-host <host> --ssh-user <user> --ssh-password <pass> --ssh-path /var/<myapp> --configuration Release --framework netcoreapp3.1 --runtime linux-x64 --self-contained false /p:PublishSingleFile=true
dotnet publish ssh--ssh主机--ssh用户--ssh密码--ssh路径/var/--configuration Release--framework netcoreapp3.1--runtime linux-x64--self-contained false/p:PublishSingleFile=true
要重新启动应用程序,您可以尝试powershell和Posh SSH模块:
Import-Module Posh-SSH
$serverAddress = "host addr"
$user = "user"
$pass = ConvertTo-SecureString "pass" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ($user, $pass)
$launchFolder = "/var/<myapp>"
$sshSession = New-SSHSession -ComputerName $serverAddress -Credential $creds -ErrorAction Stop
Invoke-SSHCommand -SSHSession $sshSession -Command "<your restart command>"
Remove-SSHSession -SSHSession $sshSession
导入模块Posh SSH
$serverAddress=“主机地址”
$user=“用户”
$pass=转换为SecureString“pass”-AsPlainText-Force
$creds=新对象System.Management.Automation.PSCredential($user,$pass)
$launchFolder=“/var/”
$sshSession=新sshSession-ComputerName$serverAddress-Credential$creds-ErrorAction Stop
调用SSHCommand-SSHSession$SSHSession-Command“”
删除SSHSession-SSHSession$SSHSession