Coder Social home page Coder Social logo

msbuild.ssh's Introduction

MSBuild.SSH

Ever wanted to automatically deploy to a SFTP server or execute SSH command as part of your build to trigger an automatic update script, but couldn't cos vanilla MSBuild doesn't support that. Cry no more as this little lib got you covered!

Version NuGet download count

How to use

Just add latest MSBuild.SSH to your csproj or pubxml and rock on!

<PackageReference Include="MSBuild.SSH" Version="1.0.0.0" PrivateAssets="all" />

Available tasks

UploadFileTask

This task uploads specified file(s) to the target directory on the server. The files are taken as is, no nesting or directory structure is considered, uploads flat to the UploadDirectory.

<UploadFileTask
    Host="$(DEPLOY_SERVER)"
    Login="$(SECRET_USER_NAME)"
    Password="$(SECRET_PASSWORD)"
    Files="$(publishUrl)\$(MSBuildProjectName).zip"
    UploadDirectory="DeployTargetFolder"
    />

SSHCommandTask

This task executes bash command on the connected server. Series of commands can can provided directly in the Command parameter, or prepared in an *.sh file on the server and invoked as shown in the example bellow

<SSHCommandTask
    Host="$(DEPLOY_SERVER)"
    Login="$(SECRET_USER_NAME)"
    Password="$(SECRET_PASSWORD)"
    Command="./Update.sh"
    />

Security

As the name suggest, SSH (Secure Shell) is by default designed to be secure by encryption. To make sure you're connecting to the correct server, not an impostor, all tasks can be optionally supplied with list of FingerprintWhitelist. Any connection to a server outside of this list will be immediately rejected.

<SSHCommandTask
    Host="$(DEPLOY_SERVER)"
    Login="$(SECRET_USER_NAME)"
    Password="$(SECRET_PASSWORD)"

    <!-- 12:f8:7e:78:61:b4:bf:e2:de:24:15:96:4e:d4:72:53 -->
    FingerprintWhitelist="$(DEPLOY_SERVER_FINGERPRINT)"

    Command="echo pong"
    />

Debugging

All tasks automatically log excecution progress to MSBuild output. By default, only important progress info and errors are printed, but additional details be be obtained by increasing logging verbosity

https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference#switches https://stackoverflow.com/questions/1211841/how-can-i-make-visual-studios-build-be-very-verbose

On the contrary, should you not enjoy default logging of the tasks, LogExecution="False" can be used in all tasks. In this case the logs will be limited only to errors.

Contribution

As usual, contributions are welcome. Leave a PR and I'll surely merge it. Please follow coding style, test properly before submit, and explain what the new feature brings in, ideally the docs form.

msbuild.ssh's People

Contributors

inflexcze avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.