Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Commit 8d2ea6c

Browse files
authored
Merge pull request #11 from unosquare/Issue10-UpgradeToNETCore2.1
Issue10 upgrade to net core2.1. Closes #10
2 parents 3b84c3a + a00e1c6 commit 8d2ea6c

File tree

4 files changed

+45
-30
lines changed

4 files changed

+45
-30
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ notifications:
33
slack: unolabs:cbusXPH6pBwZ35rVDzi4k4ve
44
solution: Unosquare.Labs.SshDeploy.sln
55
mono: none
6-
dotnet: 2.0.0
6+
dotnet: 2.1.300
77
matrix:
88
include:
99
- os: linux

README.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,42 @@
77

88
:star: *Please star this project if you find it useful!*
99

10-
A `dotnet` CLI extension that enables quick deployments over SSH. This program was specifically designed to streamline .NET application development for the Raspberry Pi running Raspbian.
10+
A `dotnet` CLI command that enables quick deployments over SSH. This program was specifically designed to streamline .NET application development for the Raspberry Pi running Raspbian.
1111

1212
**If you came here looking for our old version of SSHDeploy please click [here](https://www.nuget.org/packages/SSHDeploy/), otherwise you are in the right place**
1313

1414
The following commands are currently available:
15-
* `dotnet sshdeploy monitor` - Watches changes on a single file, if this event is raised then it proceeds to send the specified source path files over SSH
16-
* `dotnet sshdeploy push` - Single-use command that transfers files over SSH
15+
* `dotnet-sshdeploy monitor` - Watches changes on a single file, if this event is raised then it proceeds to send the specified source path files over SSH
16+
* `dotnet-sshdeploy push` - Single-use command that transfers files over SSH
1717

1818
## Installation
19-
As of now, CLI does not allow command line installation so you'll need to modify your csproj manually.
19+
We are using the brand new implementation of the global tool in .NET Core Apps 2.1+. Now you can easily download the package by running the next command
20+
21+
```console
22+
dotnet tool install -g dotnet-sshdeploy
23+
```
24+
25+
### Custom installation
26+
If you download the project and want to test installing your own version of the project you need to pack and then install the nuget
27+
28+
```console
29+
// In the root of your project run
30+
dotnet pack
31+
32+
// Run the following command where you nupkg was created
33+
dotnet tool install -g dotnet-sshdeploy --add-source ./
34+
35+
```
36+
2037

21-
```xml
22-
<ItemGroup>
23-
<DotNetCliToolReference Include="dotnet-sshdeploy" Version="0.1.6-r1" />
24-
</ItemGroup>
25-
```
26-
2738
## Usage
2839
**There are two ways of passing arguments: the old school way using the cli and our approach using the csproj file.**
40+
2941
### Using the csproj file
42+
3043
#### Push
3144
1. Edit your csproj file and add:
45+
3246
```xml
3347
<PropertyGroup>
3448
<SshDeployHost>192.168.2.194</SshDeployHost>
@@ -40,17 +54,20 @@ As of now, CLI does not allow command line installation so you'll need to modify
4054
</PropertyGroup>
4155
```
4256
2. We need a post build event as well:
57+
4358
```xml
4459
<Target Condition="$(BuildingInsideSshDeploy) ==''" Name="PostBuild" AfterTargets="PostBuildEvent">
4560
<Exec Command="cd $(ProjectDir)" />
46-
<Exec Command="dotnet sshdeploy push" />
61+
<Exec Command="dotnet-sshdeploy push" />
4762
</Target>
4863
```
4964
*Voilà! sshdeploy finds the necessary arguments provided using proper xml tags and deploys after a successful build*
5065

5166
* **Be sure you are using ' */* ' with *RemoteTargetPath* otherwise it will not work.**
5267
* **You MUST use the property** `BuildingInsideSshDeploy` **to make sure this event will not be executed within sshdeploy's build method to avoid an infinite loop**
5368
* **If no RuntimeIdentifier is provided a [Framework-dependent deployment](https://docs.microsoft.com/en-us/dotnet/core/deploying/) will be created otherwise a [Self-contained deployment](https://docs.microsoft.com/en-us/dotnet/core/deploying/) will**
69+
* **The command neds to be excute in the same folder as the csproj**
70+
5471
#### Monitor
5572
1. Go to your Visual Studio Solution (the one you intend to continuously deploy to the Raspberry Pi).
5673
2. Right-click on the project and click on the menu item "Properties"
@@ -67,7 +84,7 @@ As of now, CLI does not allow command line installation so you'll need to modify
6784
```
6885
5. Execute
6986
```
70-
dotnet sshdeploy monitor
87+
dotnet-sshdeploy monitor
7188
```
7289

7390
**FYI: Arguments passed using the csproj file will not override the ones provided using the cli**
@@ -100,13 +117,13 @@ cd C:\projects\Unosquare.Labs.RasPiConsole\Unosquare.Labs.RasPiConsole\
100117
```
101118
2. Execute this command with some arguments. Here's a simple example:
102119
```
103-
dotnet sshdeploy push -f netcoreapp2.0 -t "/home/pi/libfprint-cs" -h 192.168.2.194
120+
dotnet-sshdeploy push -f netcoreapp2.0 -t "/home/pi/libfprint-cs" -h 192.168.2.194
104121
```
105122
* In the command shown above :
106123
* `-f` refers to the source framework
107124
* `-t` refers to the target path
108125
* `-h` refers to the host (IP address of the Raspberry Pi)
109-
* For a detailed list of all the arguments available please see [below](#push-mode) or execute `dotnet sshdeploy push`
126+
* For a detailed list of all the arguments available please see [below](#push-mode) or execute `dotnet-sshdeploy push`
110127

111128
#### Monitor
112129

@@ -118,10 +135,10 @@ The following steps outline a continuous deployment of a Visual Studio solution
118135
*This simply writes the date and time to the `sshdeploy.ready` file. Whenever this file CHANGES, the deployment tool will perform a deployment.
119136
4. Open a Command Prompt (Start, Run, cmd, [Enter Key])
120137
5. Navigate to your project folder where the csproj file resides
121-
* Example:`cd "C:\projects\Unosquare.Labs.RasPiConsole\Unosquare.Labs.RasPiConsole\"`
138+
* Example: `cd "C:\projects\Unosquare.Labs.RasPiConsole\Unosquare.Labs.RasPiConsole\"`
122139
6. Run this tool with some arguments. Here is an example so you can get started quickly.
123140
```
124-
dotnet sshdeploy monitor -s "C:\projects\Unosquare.Labs.RasPiConsole\Unosquare.Labs.RasPiConsole\bin\Debug" -t "/home/pi/target" -h 192.168.2.194 -u pi -w raspberry
141+
dotnet-sshdeploy monitor -s "C:\projects\Unosquare.Labs.RasPiConsole\Unosquare.Labs.RasPiConsole\bin\Debug" -t "/home/pi/target" -h 192.168.2.194 -u pi -w raspberry
125142
```
126143
* In the above command,
127144
* `-s` refers to the source path of the files to transfer.
@@ -131,7 +148,7 @@ The following steps outline a continuous deployment of a Visual Studio solution
131148
* `-w` refers to the password.
132149
* Note that there are many more arguments you can use. Simply issue
133150
```
134-
dotnet sshdeploy monitor
151+
dotnet-sshdeploy monitor
135152
```
136153
This will get you all the options you can use.
137154

@@ -169,7 +186,7 @@ Ground Control to Major Tom: Have a nice trip in space!
169186
* *In order to make this tool much more useful, we need to take advantage of the pre and post commands. The idea is to find the process and kill it if it is currently running on the pre-command, and run the process once the deployment has been completed using the post-command argument. The hope is that this will make the deploy, run, and debug cycle, much less tedious for a .NET developer using a Raspberry Pi.*
170187

171188
* Here's a good example of using pre and post commands to acocmplish the above:
172-
```dotnet sshdeploy monitor -s "C:\projects\libfprint-cs\trunk\Unosquare.Labs.LibFprint.Tests\bin\Debug" -t "/home/pi/libfprint-cs" -h 192.168.2.194 --pre "pgrep -f 'Unosquare.Labs.LibFprint.Tests.exe' | xargs -r kill" --post "mono /home/pi/libfprint-cs/Unosquare.Labs.LibFprint.Tests.exe" --clean False```
189+
```dotnet-sshdeploy monitor -s "C:\projects\libfprint-cs\trunk\Unosquare.Labs.LibFprint.Tests\bin\Debug" -t "/home/pi/libfprint-cs" -h 192.168.2.194 --pre "pgrep -f 'Unosquare.Labs.LibFprint.Tests.exe' | xargs -r kill" --post "mono /home/pi/libfprint-cs/Unosquare.Labs.LibFprint.Tests.exe" --clean False```
173190
## References
174191
### Monitor Mode
175192

Unosquare.Labs.SshDeploy/DeploymentManager.Monitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private static void RunSshClientCommand(SshClient sshClient, CliExecuteOptionsBa
232232
" Executing SSH client command.".WriteLine(ConsoleColor.Green);
233233
var result = sshClient.RunCommand(commandText);
234234
$" SSH TX: {commandText}".WriteLine(ConsoleColor.DarkYellow);
235-
$" SSH RX: [{result.ExitStatus}] {result.Result}".WriteLine(ConsoleColor.DarkYellow);
235+
$" SSH RX: [{result.ExitStatus}] {result.Result} {result.Error}".WriteLine(ConsoleColor.DarkYellow);
236236
}
237237

238238
private static void RunCommand(SshClient sshClient, string type, string command)
@@ -243,7 +243,7 @@ private static void RunCommand(SshClient sshClient, string type, string command)
243243

244244
var result = sshClient.RunCommand(command);
245245
$" SSH TX: {command}".WriteLine(ConsoleColor.DarkYellow);
246-
$" SSH RX: [{result.ExitStatus}] {result.Result}".WriteLine(ConsoleColor.DarkYellow);
246+
$" SSH RX: [{result.ExitStatus}] {result.Result} {result.Error}".WriteLine(ConsoleColor.DarkYellow);
247247
}
248248

249249
/// <summary>

Unosquare.Labs.SshDeploy/Unosquare.Labs.SshDeploy.csproj

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
<IsPackable>true</IsPackable>
7+
<PackAsTool>true</PackAsTool>
68
<AssemblyName>dotnet-sshdeploy</AssemblyName>
79
<PackageId>dotnet-sshdeploy</PackageId>
8-
<Version>0.2.0</Version>
9-
<PackageVersion>0.2.0</PackageVersion>
10+
<Version>0.3.0</Version>
11+
<PackageVersion>0.3.0</PackageVersion>
1012
<Authors>Unosquare</Authors>
1113
<Description>A command-line tool that enables quick deployments over SSH. This is program was specifically designed to streamline .NET application development for the Raspberry Pi running Raspbian.</Description>
1214

1315
<CodeAnalysisRuleSet>..\StyleCop.Analyzers.ruleset</CodeAnalysisRuleSet>
14-
15-
<PackageType>DotnetCliTool</PackageType>
16-
<PackageTags>dotnet cli tool</PackageTags>
17-
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1816
</PropertyGroup>
1917

2018
<ItemGroup>
2119
<PackageReference Include="SSH.NET" Version="2016.1.0" />
2220
<PackageReference Include="System.IO.FileSystem.Watcher" Version="4.3.0" />
23-
<PackageReference Include="Unosquare.Swan" Version="0.28.0" />
21+
<PackageReference Include="Unosquare.Swan" Version="0.30.0" />
2422
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
2523
<PrivateAssets>All</PrivateAssets>
2624
</PackageReference>

0 commit comments

Comments
 (0)