diff --git a/Directory.Build.targets b/Directory.Build.targets
deleted file mode 100644
index 3d3afd7..0000000
--- a/Directory.Build.targets
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- VNEXT
-
-
-
diff --git a/WinSW.nuspec b/WinSW.nuspec
index 5e939cb..58f8450 100644
--- a/WinSW.nuspec
+++ b/WinSW.nuspec
@@ -25,11 +25,7 @@ More info about the wrapper is available in the projects GitHub repository.
-
-
-
-
-
-
+
+
diff --git a/eng/build.yml b/eng/build.yml
index 0eb31e0..b99c202 100644
--- a/eng/build.yml
+++ b/eng/build.yml
@@ -46,16 +46,6 @@ jobs:
versionEnvVar: BuildVersion
- script: dotnet test -c $(BuildConfiguration) --no-build src\Test\winswTests\winswTests.csproj
displayName: Test
- - task: PublishBuildArtifacts@1
- displayName: Publish .NET 2.0
- inputs:
- PathtoPublish: artifacts\WinSW.NET2.exe
- ArtifactName: WinSW.NET2.exe_$(BuildConfiguration)
- - task: PublishBuildArtifacts@1
- displayName: Publish .NET 4.0
- inputs:
- PathtoPublish: artifacts\WinSW.NET4.exe
- ArtifactName: WinSW.NET4.exe_$(BuildConfiguration)
- task: PublishBuildArtifacts@1
displayName: Publish .NET 4.6.1
inputs:
diff --git a/src/Core/ServiceWrapper/Program.cs b/src/Core/ServiceWrapper/Program.cs
index 1dee4a8..7505561 100644
--- a/src/Core/ServiceWrapper/Program.cs
+++ b/src/Core/ServiceWrapper/Program.cs
@@ -649,10 +649,8 @@ namespace winsw
FileName = current.MainModule.FileName,
#if NETCOREAPP
Arguments = "/elevated " + string.Join(' ', args),
-#elif !NET20
- Arguments = "/elevated " + string.Join(" ", args),
#else
- Arguments = "/elevated " + string.Join(" ", args.ToArray()),
+ Arguments = "/elevated " + string.Join(" ", args),
#endif
WindowStyle = ProcessWindowStyle.Hidden,
};
diff --git a/src/Core/ServiceWrapper/WrapperService.cs b/src/Core/ServiceWrapper/WrapperService.cs
index 041458c..04a9d27 100644
--- a/src/Core/ServiceWrapper/WrapperService.cs
+++ b/src/Core/ServiceWrapper/WrapperService.cs
@@ -6,9 +6,7 @@ using System.Reflection;
using System.ServiceProcess;
using System.Text;
using System.Text.RegularExpressions;
-#if VNEXT
using System.Threading.Tasks;
-#endif
using log4net;
using winsw.Extensions;
using winsw.Logging;
@@ -190,7 +188,6 @@ namespace winsw
HandleFileCopies();
// handle downloads
-#if VNEXT
List downloads = _descriptor.Downloads;
Task[] tasks = new Task[downloads.Count];
for (int i = 0; i < downloads.Count; i++)
@@ -229,32 +226,6 @@ namespace winsw
throw new AggregateException(exceptions);
}
-#else
- foreach (Download download in _descriptor.Downloads)
- {
- string downloadMessage = $"Downloading: {download.From} to {download.To}. failOnError={download.FailOnError.ToString()}";
- LogEvent(downloadMessage);
- Log.Info(downloadMessage);
- try
- {
- download.Perform();
- }
- catch (Exception e)
- {
- string errorMessage = $"Failed to download {download.From} to {download.To}";
- LogEvent($"{errorMessage}. {e.Message}");
- Log.Error(errorMessage, e);
-
- // TODO: move this code into the download logic
- if (download.FailOnError)
- {
- throw new IOException(errorMessage, e);
- }
-
- // Else just keep going
- }
- }
-#endif
string? startArguments = _descriptor.StartArguments;
diff --git a/src/Core/ServiceWrapper/winsw.csproj b/src/Core/ServiceWrapper/winsw.csproj
index 5d69f90..4ef09e6 100644
--- a/src/Core/ServiceWrapper/winsw.csproj
+++ b/src/Core/ServiceWrapper/winsw.csproj
@@ -2,7 +2,7 @@
Exe
- net20;net40;net461;netcoreapp3.1
+ net461;netcoreapp3.1
latest
enable
true
@@ -61,19 +61,7 @@
-
- v2
- NET2
-
-
-
- v4
- NET4
-
-
-
- v4.5
NET461
@@ -86,13 +74,9 @@
"$(ArtifactsDir)WinSW.$(IdentifierSuffix).exe"
-
- $(InputAssemblies) "$(OutDir)ICSharpCode.SharpZipLib.dll"
-
-
$(NuGetPackageRoot)ilmerge\$(ILMergeVersion)\tools\net452\ILMerge.exe
- /targetplatform:$(TargetPlatform) /out:$(OutputAssembly) $(InputAssemblies)
+ /targetplatform:v4.5 /out:$(OutputAssembly) $(InputAssemblies)
"$(ILMerge)" $(ILMergeArgs)
diff --git a/src/Core/WinSWCore/Download.cs b/src/Core/WinSWCore/Download.cs
index f0d2c22..9673a2c 100755
--- a/src/Core/WinSWCore/Download.cs
+++ b/src/Core/WinSWCore/Download.cs
@@ -1,13 +1,8 @@
using System;
using System.IO;
using System.Net;
-#if !VNEXT
-using System.Reflection;
-#endif
using System.Text;
-#if VNEXT
using System.Threading.Tasks;
-#endif
using System.Xml;
using log4net;
using winsw.Util;
@@ -40,33 +35,13 @@ namespace winsw
public string ShortId => $"(download from {From})";
+#if NET461
static Download()
{
-#if NET461
// If your app runs on .NET Framework 4.7 or later versions, but targets an earlier version
AppContext.SetSwitch("Switch.System.Net.DontEnableSystemDefaultTlsVersions", false);
-#elif !VNEXT
- // If your app runs on .NET Framework 4.6, but targets an earlier version
- Type.GetType("System.AppContext")?.InvokeMember("SetSwitch", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, new object[] { "Switch.System.Net.DontEnableSchUseStrongCrypto", false });
-
- const SecurityProtocolType Tls12 = (SecurityProtocolType)0x00000C00;
- const SecurityProtocolType Tls11 = (SecurityProtocolType)0x00000300;
-
- // Windows 7 and Windows Server 2008 R2
- if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
- {
- try
- {
- ServicePointManager.SecurityProtocol |= Tls11 | Tls12;
- Logger.Info("TLS 1.1/1.2 enabled");
- }
- catch (NotSupportedException)
- {
- Logger.Info("TLS 1.1/1.2 disabled");
- }
- }
-#endif
}
+#endif
// internal
public Download(
@@ -144,11 +119,7 @@ namespace winsw
///
/// Download failure. FailOnError flag should be processed outside.
///
-#if VNEXT
public async Task PerformAsync()
-#else
- public void Perform()
-#endif
{
WebRequest request = WebRequest.Create(From);
if (!string.IsNullOrEmpty(Proxy))
@@ -195,11 +166,7 @@ namespace winsw
string tmpFilePath = To + ".tmp";
try
{
-#if VNEXT
using (WebResponse response = await request.GetResponseAsync())
-#else
- using (WebResponse response = request.GetResponse())
-#endif
using (Stream responseStream = response.GetResponseStream())
using (FileStream tmpStream = new FileStream(tmpFilePath, FileMode.Create))
{
@@ -208,13 +175,7 @@ namespace winsw
lastModified = ((HttpWebResponse)response).LastModified;
}
-#if VNEXT
await responseStream.CopyToAsync(tmpStream);
-#elif NET20
- CopyStream(responseStream, tmpStream);
-#else
- responseStream.CopyTo(tmpStream);
-#endif
}
FileHelper.MoveOrReplaceFile(To + ".tmp", To);
@@ -236,18 +197,6 @@ namespace winsw
}
}
}
-
-#if NET20
- private static void CopyStream(Stream source, Stream destination)
- {
- byte[] buffer = new byte[8192];
- int read;
- while ((read = source.Read(buffer, 0, buffer.Length)) != 0)
- {
- destination.Write(buffer, 0, read);
- }
- }
-#endif
}
public class CustomProxyInformation
diff --git a/src/Core/WinSWCore/LogAppenders.cs b/src/Core/WinSWCore/LogAppenders.cs
index 855c4a1..fa8e764 100644
--- a/src/Core/WinSWCore/LogAppenders.cs
+++ b/src/Core/WinSWCore/LogAppenders.cs
@@ -1,13 +1,8 @@
using System;
using System.Diagnostics;
-#if VNEXT
using System.IO.Compression;
-#endif
using System.IO;
using System.Threading;
-#if !VNEXT
-using ICSharpCode.SharpZipLib.Zip;
-#endif
using winsw.Util;
namespace winsw
@@ -481,7 +476,6 @@ namespace winsw
}
}
-#if VNEXT
private void ZipOneFile(string sourceFilePath, string entryName, string zipFilePath)
{
ZipArchive? zipArchive = null;
@@ -503,33 +497,6 @@ namespace winsw
zipArchive?.Dispose();
}
}
-#else
- private void ZipOneFile(string sourceFilePath, string entryName, string zipFilePath)
- {
- ZipFile? zipFile = null;
- try
- {
- zipFile = new ZipFile(File.Open(zipFilePath, FileMode.OpenOrCreate));
- zipFile.BeginUpdate();
-
- if (zipFile.FindEntry(entryName, false) < 0)
- {
- zipFile.Add(sourceFilePath, entryName);
- }
-
- zipFile.CommitUpdate();
- }
- catch (Exception e)
- {
- EventLogger.LogEvent($"Failed to Zip the File {sourceFilePath}. Error {e.Message}");
- zipFile?.AbortUpdate();
- }
- finally
- {
- zipFile?.Close();
- }
- }
-#endif
private double SetupRollTimer(TimeSpan autoRollAtTime)
{
diff --git a/src/Core/WinSWCore/Util/XmlHelper.cs b/src/Core/WinSWCore/Util/XmlHelper.cs
index f28a2f0..e593a36 100644
--- a/src/Core/WinSWCore/Util/XmlHelper.cs
+++ b/src/Core/WinSWCore/Util/XmlHelper.cs
@@ -94,26 +94,15 @@ namespace winsw.Util
string rawValue = node.GetAttribute(attributeName);
string substitutedValue = Environment.ExpandEnvironmentVariables(rawValue);
-#if NET20
try
{
- var value = Enum.Parse(typeof(TAttributeType), substitutedValue, true);
- return (TAttributeType)value;
+ return (TAttributeType)Enum.Parse(typeof(TAttributeType), substitutedValue, true);
}
catch (ArgumentException ex)
{
throw new InvalidDataException("Cannot parse <" + attributeName + "> Enum value from string '" + substitutedValue +
"'. Enum type: " + typeof(TAttributeType), ex);
}
-#else
- if (!Enum.TryParse(substitutedValue, true, out TAttributeType result))
- {
- throw new InvalidDataException("Cannot parse <" + attributeName + "> Enum value from string '" + substitutedValue +
- "'. Enum type: " + typeof(TAttributeType));
- }
-
- return result;
-#endif
}
}
}
diff --git a/src/Core/WinSWCore/WinSWCore.csproj b/src/Core/WinSWCore/WinSWCore.csproj
index 284f8ea..68c25e3 100644
--- a/src/Core/WinSWCore/WinSWCore.csproj
+++ b/src/Core/WinSWCore/WinSWCore.csproj
@@ -1,7 +1,7 @@
- net20;net40;net461;netcoreapp3.1
+ net461;netcoreapp3.1
latest
enable
true
@@ -38,8 +38,4 @@
-
-
-
-
diff --git a/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj b/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj
index 45f5d2d..8fc496a 100644
--- a/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj
+++ b/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj
@@ -1,7 +1,7 @@
- net20;net40;net461;netcoreapp3.1
+ net461;netcoreapp3.1
latest
enable
true
diff --git a/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj b/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj
index b401e4b..353cc07 100644
--- a/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj
+++ b/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj
@@ -1,7 +1,7 @@
- net20;net40;net461;netcoreapp3.1
+ net461;netcoreapp3.1
latest
enable
diff --git a/src/Test/winswTests/DownloadTests.cs b/src/Test/winswTests/DownloadTests.cs
index d5bf118..5c0215a 100644
--- a/src/Test/winswTests/DownloadTests.cs
+++ b/src/Test/winswTests/DownloadTests.cs
@@ -1,5 +1,4 @@
-#if VNEXT
-using System;
+using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
@@ -228,4 +227,3 @@ namespace winswTests
}
}
}
-#endif
diff --git a/src/Test/winswTests/Util/AsyncAssert.cs b/src/Test/winswTests/Util/AsyncAssert.cs
index 0c2ffa9..28da198 100644
--- a/src/Test/winswTests/Util/AsyncAssert.cs
+++ b/src/Test/winswTests/Util/AsyncAssert.cs
@@ -1,5 +1,4 @@
-#if VNEXT
-using System;
+using System;
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework.Constraints;
@@ -26,4 +25,3 @@ namespace winswTests.Util
}
}
}
-#endif
diff --git a/src/Test/winswTests/Util/DateTimeExtensions.cs b/src/Test/winswTests/Util/DateTimeExtensions.cs
index 07c18ed..dada47b 100644
--- a/src/Test/winswTests/Util/DateTimeExtensions.cs
+++ b/src/Test/winswTests/Util/DateTimeExtensions.cs
@@ -1,5 +1,4 @@
-#if VNEXT
-using System;
+using System;
namespace winswTests.Util
{
@@ -9,4 +8,3 @@ namespace winswTests.Util
dateTime.AddTicks(-(dateTime.Ticks % TimeSpan.TicksPerSecond));
}
}
-#endif
diff --git a/src/Test/winswTests/winswTests.csproj b/src/Test/winswTests/winswTests.csproj
index 6460b4d..dc14e60 100644
--- a/src/Test/winswTests/winswTests.csproj
+++ b/src/Test/winswTests/winswTests.csproj
@@ -1,7 +1,7 @@
- net40;net461;netcoreapp3.1
+ net461;netcoreapp3.1
latest
winswTests