I am building a .net core app in Visual Studio 2017. I would like to automate my the publishing process to a linux machine.
This is my current process:
WinSCP
, login to target linux machinesolution\\myapp\\bin\\Release\\netcoreapp2.2\\publish\\
WinSCP
target directory PuTTY
, login to target linux machine, restart the app using dotnet myapp.dll
Could I automate these steps when publishing from Visual Studio?
Try dotnet-publish-ssh .
It works like dotnet publish, but allows you to copy you app over SSH to your target linux machine.
Here is my config:
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
To restart the app you may try powershell with Posh-SSH module:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.