Reputation: 947
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 directoryPuTTY
, login to target linux machine, restart the app using dotnet myapp.dll
Could I automate these steps when publishing from Visual Studio?
Upvotes: 8
Views: 6236
Reputation: 917
Try dotnet-publish-ssh.
It works like dotnet publish
, but allows you to copy your 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
Upvotes: 4