Skip to content

Commit 208756f

Browse files
committed
Update to net 5.0
1 parent 26c63e2 commit 208756f

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

AutoSSH.csproj

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

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="SSH.NET" Version="2016.1.0" />
10-
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.5.0" />
9+
<PackageReference Include="SSH.NET" Version="2020.0.1" />
10+
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="5.0.0" />
1111
</ItemGroup>
1212

1313
</Project>

AutoSSHApp.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,22 +387,30 @@ private static long UploadFolder(HostEntry host, string pathInfo, SftpClient cli
387387
return;
388388
}
389389

390-
using var stream = File.OpenRead(file);
391390
var localDirForFile = Path.GetDirectoryName(file);
392391
var localFile = Path.GetFileName(file);
393392
var remoteDir = Path.Combine(remoteFolder, localDirForFile.Substring(localDir.Length));
394393
var remoteFile = remoteDir + "/" + localFile;
395-
if (!client.Exists(remoteDir))
394+
395+
try
396396
{
397-
client.CreateDirectory(remoteDir);
397+
using var stream = File.OpenRead(file);
398+
if (!client.Exists(remoteDir))
399+
{
400+
client.CreateDirectory(remoteDir);
401+
}
402+
long prevProgress = 0;
403+
client.UploadFile(stream, remoteFile, bytesUploaded =>
404+
{
405+
Interlocked.Add(ref AutoSSHApp.bytesUploaded, ((long)bytesUploaded - prevProgress));
406+
prevProgress = (long)bytesUploaded;
407+
});
408+
Interlocked.Add(ref uploadSize, prevProgress);
398409
}
399-
long prevProgress = 0;
400-
client.UploadFile(stream, remoteFile, bytesUploaded =>
410+
catch (Exception ex)
401411
{
402-
Interlocked.Add(ref AutoSSHApp.bytesUploaded, ((long)bytesUploaded - prevProgress));
403-
prevProgress = (long)bytesUploaded;
404-
});
405-
Interlocked.Add(ref uploadSize, prevProgress);
412+
Console.WriteLine("Error uploading file {0} to {1}: {2}", localFiles, remoteFile, ex);
413+
}
406414
});
407415
return uploadSize;
408416
}

Properties/PublishProfiles/FolderProfile.pubxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
66
<PropertyGroup>
77
<Configuration>Release</Configuration>
88
<Platform>Any CPU</Platform>
9-
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
9+
<PublishDir>bin\Release\net5.0\publish\</PublishDir>
1010
<PublishProtocol>FileSystem</PublishProtocol>
11-
<TargetFramework>netcoreapp3.1</TargetFramework>
11+
<TargetFramework>net5.0</TargetFramework>
1212
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1313
<SelfContained>true</SelfContained>
1414
<PublishSingleFile>False</PublishSingleFile>

0 commit comments

Comments
 (0)