mirror of https://github.com/winsw/winsw
Merge pull request #354 from NextTurn/tfms
Add new target frameworks: .NET 4.5, .NET Core win-x64, .NET Core win-x86 + Fix archiving of old logs in the `roll-by-size-time` modepull/363/head
commit
45463b0d7b
|
@ -0,0 +1,7 @@
|
||||||
|
<Project>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netcoreapp3.1'">
|
||||||
|
<DefineConstants>VNEXT</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
34
appveyor.yml
34
appveyor.yml
|
@ -4,7 +4,7 @@ skip_branch_with_pr: true
|
||||||
|
|
||||||
# Project configuration
|
# Project configuration
|
||||||
image: Visual Studio 2019
|
image: Visual Studio 2019
|
||||||
platform: Any CPU
|
# platform: Any CPU
|
||||||
configuration: Release
|
configuration: Release
|
||||||
version: 2.0.{build}
|
version: 2.0.{build}
|
||||||
|
|
||||||
|
@ -17,33 +17,45 @@ nuget:
|
||||||
before_build:
|
before_build:
|
||||||
# Check SDKs
|
# Check SDKs
|
||||||
- ECHO "Installed SDKs:"
|
- ECHO "Installed SDKs:"
|
||||||
- ps: "ls \"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\\""
|
- ps: 'ls "C:\Program Files (x86)\Microsoft SDKs\Windows\"'
|
||||||
# Generates a temporary SNK. Not for real signing
|
# Generates a temporary SNK. Not for real signing
|
||||||
- cmd: "\"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\sn.exe\" -k winsw_key.snk"
|
- cmd: '"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe" -k winsw_key.snk'
|
||||||
|
|
||||||
dotnet_csproj:
|
dotnet_csproj:
|
||||||
patch: true
|
patch: true
|
||||||
file: "**\\*.csproj"
|
file: '**\*.csproj'
|
||||||
version: $(appveyor_build_version)
|
version: $(appveyor_build_version)
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- dotnet.exe build src\winsw.sln
|
- dotnet.exe build src\winsw.sln
|
||||||
|
- dotnet.exe publish -f netcoreapp3.1 src\Core\ServiceWrapper\winsw.csproj
|
||||||
|
- dotnet.exe publish -f netcoreapp3.1 -r win-x64 src\Core\ServiceWrapper\winsw.csproj /p:PublishSingleFile=true /p:PublishTrimmed=true
|
||||||
|
- dotnet.exe publish -f netcoreapp3.1 -r win-x86 src\Core\ServiceWrapper\winsw.csproj /p:PublishSingleFile=true /p:PublishTrimmed=true
|
||||||
|
|
||||||
after_build:
|
after_build:
|
||||||
- ps: nuget pack WinSW.nuspec -Version $env:APPVEYOR_BUILD_VERSION
|
- ps: nuget pack WinSW.nuspec -Version $env:APPVEYOR_BUILD_VERSION
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
# Runner for NUnit2
|
- dotnet.exe test -f net40 --no-build src\Test\winswTests\winswTests.csproj
|
||||||
- ps: nunit-console 'src/Test/winswTests/bin/Release/net40/winswTests.dll' 'src/Test/winswTests/bin/Release/net40/SharedDirectoryMapper.dll' 'src/Test/winswTests/bin/Release/net40/RunawayProcessKiller.dll'
|
- dotnet.exe test -f net45 --no-build src\Test\winswTests\winswTests.csproj
|
||||||
|
- dotnet.exe test -f netcoreapp3.1 --no-build src\Test\winswTests\winswTests.csproj
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: 'src/Core/ServiceWrapper/bin/Release/net20/WinSW.exe'
|
- path: 'src\Core\ServiceWrapper\bin\Release\net20\WinSW.exe'
|
||||||
name: WinSW.NET2.exe
|
name: WinSW.NET2.exe
|
||||||
- path: 'src/Core/ServiceWrapper/bin/Release/net40/WinSW.exe'
|
- path: 'src\Core\ServiceWrapper\bin\Release\net40\WinSW.exe'
|
||||||
name: WinSW.NET4.exe
|
name: WinSW.NET4.exe
|
||||||
|
- path: 'src\Core\ServiceWrapper\bin\Release\net45\WinSW.exe'
|
||||||
|
name: WinSW.NET45.exe
|
||||||
|
- path: 'src\Core\ServiceWrapper\bin\Release\netcoreapp3.1\publish\'
|
||||||
|
name: WinSW.NETCore31
|
||||||
|
- path: 'src\Core\ServiceWrapper\bin\Release\netcoreapp3.1\win-x64\publish\WindowsService.exe'
|
||||||
|
name: WinSW.NETCore31.x64
|
||||||
|
- path: 'src\Core\ServiceWrapper\bin\Release\netcoreapp3.1\win-x86\publish\WindowsService.exe'
|
||||||
|
name: WinSW.NETCore31.x86
|
||||||
- path: 'WinSW.$(appveyor_build_version).nupkg'
|
- path: 'WinSW.$(appveyor_build_version).nupkg'
|
||||||
name: WinSW.nupkg
|
name: WinSW.nupkg
|
||||||
- path: 'examples/sample-allOptions.xml'
|
- path: 'examples\sample-allOptions.xml'
|
||||||
name: 'sample-allOptions.xml'
|
name: 'sample-allOptions.xml'
|
||||||
- path: 'examples/sample-minimal.xml'
|
- path: 'examples\sample-minimal.xml'
|
||||||
name: 'sample-minimal.xml'
|
name: 'sample-minimal.xml'
|
||||||
|
|
|
@ -32,7 +32,11 @@ namespace winsw
|
||||||
|
|
||||||
internal WinSWExtensionManager ExtensionManager { get; private set; }
|
internal WinSWExtensionManager ExtensionManager { get; private set; }
|
||||||
|
|
||||||
private static readonly ILog Log = LogManager.GetLogger("WinSW");
|
private static readonly ILog Log = LogManager.GetLogger(
|
||||||
|
#if NETCOREAPP
|
||||||
|
Assembly.GetExecutingAssembly(),
|
||||||
|
#endif
|
||||||
|
"WinSW");
|
||||||
private static readonly WrapperServiceEventLogProvider eventLogProvider = new WrapperServiceEventLogProvider();
|
private static readonly WrapperServiceEventLogProvider eventLogProvider = new WrapperServiceEventLogProvider();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -827,7 +831,11 @@ namespace winsw
|
||||||
systemEventLogger.ActivateOptions();
|
systemEventLogger.ActivateOptions();
|
||||||
appenders.Add(systemEventLogger);
|
appenders.Add(systemEventLogger);
|
||||||
|
|
||||||
BasicConfigurator.Configure(appenders.ToArray());
|
BasicConfigurator.Configure(
|
||||||
|
#if NETCOREAPP
|
||||||
|
LogManager.GetRepository(Assembly.GetExecutingAssembly()),
|
||||||
|
#endif
|
||||||
|
appenders.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ReadPassword()
|
private static string ReadPassword()
|
||||||
|
|
|
@ -1,93 +1,86 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworks>net20;net40</TargetFrameworks>
|
<TargetFrameworks>net20;net40;net45;netcoreapp3.1</TargetFrameworks>
|
||||||
<!-- AppVeyor -->
|
<Version><!-- Populated by AppVeyor --></Version>
|
||||||
<Version></Version>
|
<AssemblyTitle>Windows Service Wrapper</AssemblyTitle>
|
||||||
<AssemblyTitle>Windows Service Wrapper</AssemblyTitle>
|
<Description>Allows arbitrary process to run as a Windows service by wrapping it.</Description>
|
||||||
<Description>Allows arbitrary process to run as a Windows service by wrapping it.</Description>
|
<Company>CloudBees, Inc.</Company>
|
||||||
<Company>CloudBees, Inc.</Company>
|
<Product>Windows Service Wrapper</Product>
|
||||||
<Product>Windows Service Wrapper</Product>
|
<Copyright>Copyright 2008-2016 Oleg Nenashev, CloudBees, Inc. and other contributors</Copyright>
|
||||||
<Copyright>Copyright 2008-2016 Oleg Nenashev, CloudBees, Inc. and other contributors</Copyright>
|
<RootNamespace>winsw</RootNamespace>
|
||||||
<RootNamespace>winsw</RootNamespace>
|
<AssemblyName>WindowsService</AssemblyName>
|
||||||
<AssemblyName>WindowsService</AssemblyName>
|
<SignAssembly>true</SignAssembly>
|
||||||
<SignAssembly>true</SignAssembly>
|
</PropertyGroup>
|
||||||
</PropertyGroup>
|
|
||||||
|
<ItemGroup>
|
||||||
<ItemGroup>
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
<PackageReference Include="ICSharpCode.SharpZipLib.dll" Version="0.85.4.369" />
|
</ItemGroup>
|
||||||
<PackageReference Include="ilmerge" Version="3.0.29" />
|
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
|
||||||
</ItemGroup>
|
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System.Management" />
|
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
|
||||||
<Reference Include="System.ServiceProcess" />
|
<PackageReference Include="ilmerge" Version="3.0.29" />
|
||||||
</ItemGroup>
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
||||||
|
<Reference Include="System.Management" />
|
||||||
<ItemGroup>
|
<Reference Include="System.ServiceProcess" />
|
||||||
<Content Include="manifest.xml" />
|
</ItemGroup>
|
||||||
</ItemGroup>
|
|
||||||
|
<ItemGroup>
|
||||||
<ItemGroup>
|
<Content Include="manifest.xml" />
|
||||||
<None Include="$(AssemblyOriginatorKeyFile)" />
|
</ItemGroup>
|
||||||
</ItemGroup>
|
|
||||||
|
<ItemGroup>
|
||||||
<ItemGroup>
|
<None Include="$(AssemblyOriginatorKeyFile)" />
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
</ItemGroup>
|
||||||
<Visible>False</Visible>
|
|
||||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
<ItemGroup>
|
||||||
<Install>false</Install>
|
<ProjectReference Include="..\WinSWCore\WinSWCore.csproj" />
|
||||||
</BootstrapperPackage>
|
<ProjectReference Include="..\..\Plugins\RunawayProcessKiller\RunawayProcessKiller.csproj" />
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
<ProjectReference Include="..\..\Plugins\SharedDirectoryMapper\SharedDirectoryMapper.csproj" />
|
||||||
<Visible>False</Visible>
|
</ItemGroup>
|
||||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
|
||||||
<Install>true</Install>
|
<!-- Merge plugins and other DLLs into the executable -->
|
||||||
</BootstrapperPackage>
|
<Target Name="Merge" BeforeTargets="AfterBuild" Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
|
||||||
</ItemGroup>
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net20'">
|
||||||
<ItemGroup>
|
<TargetPlatform>v2</TargetPlatform>
|
||||||
<ProjectReference Include="..\WinSWCore\WinSWCore.csproj" />
|
</PropertyGroup>
|
||||||
<ProjectReference Include="..\..\Plugins\RunawayProcessKiller\RunawayProcessKiller.csproj" />
|
|
||||||
<ProjectReference Include="..\..\Plugins\SharedDirectoryMapper\SharedDirectoryMapper.csproj" />
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||||
</ItemGroup>
|
<TargetPlatform>v4</TargetPlatform>
|
||||||
|
</PropertyGroup>
|
||||||
<!-- Merge plugins and other DLLs into the executable -->
|
|
||||||
<Choose>
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||||
<When Condition="'$(TargetFramework)' == 'net20'">
|
<TargetPlatform>v4.5</TargetPlatform>
|
||||||
<PropertyGroup>
|
</PropertyGroup>
|
||||||
<TargetPlatform>v2</TargetPlatform>
|
|
||||||
</PropertyGroup>
|
<PropertyGroup>
|
||||||
</When>
|
<InputAssemblies>"$(OutDir)$(TargetFileName)"</InputAssemblies>
|
||||||
<When Condition="'$(TargetFramework)' == 'net40'">
|
<InputAssemblies>$(InputAssemblies) "$(OutDir)WinSWCore.dll"</InputAssemblies>
|
||||||
<PropertyGroup>
|
<InputAssemblies>$(InputAssemblies) "$(OutDir)SharedDirectoryMapper.dll"</InputAssemblies>
|
||||||
<TargetPlatform>v4</TargetPlatform>
|
<InputAssemblies>$(InputAssemblies) "$(OutDir)RunawayProcessKiller.dll"</InputAssemblies>
|
||||||
</PropertyGroup>
|
<InputAssemblies>$(InputAssemblies) "$(OutDir)log4net.dll"</InputAssemblies>
|
||||||
</When>
|
<OutputAssembly>"$(OutDir)WinSW.exe"</OutputAssembly>
|
||||||
</Choose>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Target Name="Merge" BeforeTargets="AfterBuild">
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net20' or '$(TargetFramework)' == 'net40'">
|
||||||
|
<InputAssemblies>$(InputAssemblies) "$(OutDir)ICSharpCode.SharpZipLib.dll"</InputAssemblies>
|
||||||
<PropertyGroup>
|
</PropertyGroup>
|
||||||
<InputAssemblies>"$(OutDir)$(TargetFileName)"</InputAssemblies>
|
|
||||||
<InputAssemblies>$(InputAssemblies) "$(OutDir)WinSWCore.dll"</InputAssemblies>
|
<PropertyGroup>
|
||||||
<InputAssemblies>$(InputAssemblies) "$(OutDir)SharedDirectoryMapper.dll"</InputAssemblies>
|
<ILMerge>$(NuGetPackageRoot)ilmerge\3.0.29\tools\net452\ILMerge.exe</ILMerge>
|
||||||
<InputAssemblies>$(InputAssemblies) "$(OutDir)RunawayProcessKiller.dll"</InputAssemblies>
|
<ILMergeArgs>/keyfile:"$(AssemblyOriginatorKeyFile)" /targetplatform:$(TargetPlatform) /out:$(OutputAssembly) $(InputAssemblies)</ILMergeArgs>
|
||||||
<InputAssemblies>$(InputAssemblies) "$(OutDir)log4net.dll"</InputAssemblies>
|
<ILMergeCommand>"$(ILMerge)" $(ILMergeArgs)</ILMergeCommand>
|
||||||
<OutputAssembly>"$(OutDir)WinSW.exe"</OutputAssembly>
|
</PropertyGroup>
|
||||||
</PropertyGroup>
|
|
||||||
|
<Message Text="$(ILMergeCommand)" Importance="high" />
|
||||||
<PropertyGroup>
|
<Exec Command="$(ILMergeCommand)" />
|
||||||
<ILMerge>$(NuGetPackageRoot)ilmerge\3.0.29\tools\net452\ILMerge.exe</ILMerge>
|
|
||||||
<ILMergeArgs>/keyfile:"$(AssemblyOriginatorKeyFile)" /targetplatform:$(TargetPlatform) /out:$(OutputAssembly) $(InputAssemblies)</ILMergeArgs>
|
</Target>
|
||||||
<ILMergeCommand>"$(ILMerge)" $(ILMergeArgs)</ILMergeCommand>
|
|
||||||
</PropertyGroup>
|
</Project>
|
||||||
|
|
||||||
<Message Text="$(ILMergeCommand)" Importance="high" />
|
|
||||||
<Exec Command="$(ILMergeCommand)" />
|
|
||||||
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace DynamicProxy
|
namespace DynamicProxy
|
||||||
{
|
{
|
||||||
|
@ -174,15 +173,18 @@ namespace DynamicProxy
|
||||||
Type objType = typeof(object);
|
Type objType = typeof(object);
|
||||||
Type handlerType = typeof(IProxyInvocationHandler);
|
Type handlerType = typeof(IProxyInvocationHandler);
|
||||||
|
|
||||||
AppDomain domain = Thread.GetDomain();
|
|
||||||
AssemblyName assemblyName = new AssemblyName();
|
AssemblyName assemblyName = new AssemblyName();
|
||||||
assemblyName.Name = ASSEMBLY_NAME;
|
assemblyName.Name = ASSEMBLY_NAME;
|
||||||
assemblyName.Version = new Version(1, 0, 0, 0);
|
assemblyName.Version = new Version(1, 0, 0, 0);
|
||||||
|
|
||||||
// create a new assembly for this proxy, one that isn't presisted on the file system
|
// create a new assembly for this proxy, one that isn't presisted on the file system
|
||||||
AssemblyBuilder assemblyBuilder = domain.DefineDynamicAssembly(
|
AssemblyBuilder assemblyBuilder =
|
||||||
assemblyName, AssemblyBuilderAccess.Run);
|
#if VNEXT
|
||||||
// assemblyName, AssemblyBuilderAccess.RunAndSave,"."); // to save it to the disk
|
AssemblyBuilder.DefineDynamicAssembly(
|
||||||
|
#else
|
||||||
|
AppDomain.CurrentDomain.DefineDynamicAssembly(
|
||||||
|
#endif
|
||||||
|
assemblyName, AssemblyBuilderAccess.Run);
|
||||||
|
|
||||||
// create a new module for this proxy
|
// create a new module for this proxy
|
||||||
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(MODULE_NAME);
|
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(MODULE_NAME);
|
||||||
|
@ -206,7 +208,7 @@ namespace DynamicProxy
|
||||||
ConstructorBuilder delegateConstructor = typeBuilder.DefineConstructor(
|
ConstructorBuilder delegateConstructor = typeBuilder.DefineConstructor(
|
||||||
MethodAttributes.Public, CallingConventions.Standard, new Type[] { handlerType });
|
MethodAttributes.Public, CallingConventions.Standard, new Type[] { handlerType });
|
||||||
|
|
||||||
#region( "Constructor IL Code" )
|
#region( "Constructor IL Code" )
|
||||||
ILGenerator constructorIL = delegateConstructor.GetILGenerator();
|
ILGenerator constructorIL = delegateConstructor.GetILGenerator();
|
||||||
|
|
||||||
// Load "this"
|
// Load "this"
|
||||||
|
@ -221,7 +223,7 @@ namespace DynamicProxy
|
||||||
constructorIL.Emit(OpCodes.Call, superConstructor);
|
constructorIL.Emit(OpCodes.Call, superConstructor);
|
||||||
// Constructor return
|
// Constructor return
|
||||||
constructorIL.Emit(OpCodes.Ret);
|
constructorIL.Emit(OpCodes.Ret);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// for every method that the interfaces define, build a corresponding
|
// for every method that the interfaces define, build a corresponding
|
||||||
// method in the dynamic type that calls the handlers invoke method.
|
// method in the dynamic type that calls the handlers invoke method.
|
||||||
|
@ -270,7 +272,7 @@ namespace DynamicProxy
|
||||||
CallingConventions.Standard,
|
CallingConventions.Standard,
|
||||||
methodInfo.ReturnType, methodParameters);
|
methodInfo.ReturnType, methodParameters);
|
||||||
|
|
||||||
#region( "Handler Method IL Code" )
|
#region( "Handler Method IL Code" )
|
||||||
ILGenerator methodIL = methodBuilder.GetILGenerator();
|
ILGenerator methodIL = methodBuilder.GetILGenerator();
|
||||||
|
|
||||||
// load "this"
|
// load "this"
|
||||||
|
@ -341,7 +343,7 @@ namespace DynamicProxy
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
methodIL.Emit(OpCodes.Ret);
|
methodIL.Emit(OpCodes.Ret);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (int i = 0; i < props.Length; i++)
|
// for (int i = 0; i < props.Length; i++)
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
#if VNEXT
|
||||||
|
using System.IO.Compression;
|
||||||
|
#endif
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
#if !VNEXT
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace winsw
|
namespace winsw
|
||||||
{
|
{
|
||||||
|
@ -361,7 +366,18 @@ namespace winsw
|
||||||
public int? ZipOlderThanNumDays { get; private set; }
|
public int? ZipOlderThanNumDays { get; private set; }
|
||||||
public string ZipDateFormat { get; private set; }
|
public string ZipDateFormat { get; private set; }
|
||||||
|
|
||||||
public RollingSizeTimeLogAppender(string logDirectory, string baseName, bool outFileDisabled, bool errFileDisabled, string outFilePattern, string errFilePattern, int sizeThreshold, string filePattern, TimeSpan? autoRollAtTime, int? zipolderthannumdays, string zipdateformat)
|
public RollingSizeTimeLogAppender(
|
||||||
|
string logDirectory,
|
||||||
|
string baseName,
|
||||||
|
bool outFileDisabled,
|
||||||
|
bool errFileDisabled,
|
||||||
|
string outFilePattern,
|
||||||
|
string errFilePattern,
|
||||||
|
int sizeThreshold,
|
||||||
|
string filePattern,
|
||||||
|
TimeSpan? autoRollAtTime,
|
||||||
|
int? zipolderthannumdays,
|
||||||
|
string zipdateformat)
|
||||||
: base(logDirectory, baseName, outFileDisabled, errFileDisabled, outFilePattern, errFilePattern)
|
: base(logDirectory, baseName, outFileDisabled, errFileDisabled, outFilePattern, errFilePattern)
|
||||||
{
|
{
|
||||||
SizeTheshold = sizeThreshold;
|
SizeTheshold = sizeThreshold;
|
||||||
|
@ -380,7 +396,7 @@ namespace winsw
|
||||||
new Thread(() => CopyStreamWithRotation(errorStream, ErrFilePattern)).Start();
|
new Thread(() => CopyStreamWithRotation(errorStream, ErrFilePattern)).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyStreamWithRotation(Stream data, string ext)
|
private void CopyStreamWithRotation(Stream data, string extension)
|
||||||
{
|
{
|
||||||
// lock required as the timer thread and the thread that will write to the stream could try and access the file stream at the same time
|
// lock required as the timer thread and the thread that will write to the stream could try and access the file stream at the same time
|
||||||
var fileLock = new object();
|
var fileLock = new object();
|
||||||
|
@ -389,7 +405,7 @@ namespace winsw
|
||||||
|
|
||||||
var baseDirectory = Path.GetDirectoryName(BaseLogFileName);
|
var baseDirectory = Path.GetDirectoryName(BaseLogFileName);
|
||||||
var baseFileName = Path.GetFileName(BaseLogFileName);
|
var baseFileName = Path.GetFileName(BaseLogFileName);
|
||||||
var logFile = string.Format("{0}{1}", BaseLogFileName, ext);
|
var logFile = BaseLogFileName + extension;
|
||||||
|
|
||||||
var w = new FileStream(logFile, FileMode.Append);
|
var w = new FileStream(logFile, FileMode.Append);
|
||||||
var sz = new FileInfo(logFile).Length;
|
var sz = new FileInfo(logFile).Length;
|
||||||
|
@ -410,8 +426,8 @@ namespace winsw
|
||||||
w.Close();
|
w.Close();
|
||||||
|
|
||||||
var now = DateTime.Now.AddDays(-1);
|
var now = DateTime.Now.AddDays(-1);
|
||||||
var nextFileNumber = GetNextFileNumber(ext, baseDirectory, baseFileName, now);
|
var nextFileNumber = GetNextFileNumber(extension, baseDirectory, baseFileName, now);
|
||||||
var nextFileName = Path.Combine(baseDirectory, string.Format("{0}.{1}.#{2:D4}{3}", baseFileName, now.ToString(FilePattern), nextFileNumber, ext));
|
var nextFileName = Path.Combine(baseDirectory, string.Format("{0}.{1}.#{2:D4}{3}", baseFileName, now.ToString(FilePattern), nextFileNumber, extension));
|
||||||
File.Move(logFile, nextFileName);
|
File.Move(logFile, nextFileName);
|
||||||
|
|
||||||
w = new FileStream(logFile, FileMode.Create);
|
w = new FileStream(logFile, FileMode.Create);
|
||||||
|
@ -419,7 +435,7 @@ namespace winsw
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next day so check if file can be zipped
|
// Next day so check if file can be zipped
|
||||||
ZipFiles(baseDirectory, ext, baseFileName);
|
ZipFiles(baseDirectory, extension, baseFileName);
|
||||||
}
|
}
|
||||||
catch (Exception et)
|
catch (Exception et)
|
||||||
{
|
{
|
||||||
|
@ -471,10 +487,10 @@ namespace winsw
|
||||||
|
|
||||||
// rotate file
|
// rotate file
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
var nextFileNumber = GetNextFileNumber(ext, baseDirectory, baseFileName, now);
|
var nextFileNumber = GetNextFileNumber(extension, baseDirectory, baseFileName, now);
|
||||||
var nextFileName =
|
var nextFileName =
|
||||||
Path.Combine(baseDirectory,
|
Path.Combine(baseDirectory,
|
||||||
string.Format("{0}.{1}.#{2:D4}{3}", baseFileName, now.ToString(FilePattern), nextFileNumber, ext));
|
string.Format("{0}.{1}.#{2:D4}{3}", baseFileName, now.ToString(FilePattern), nextFileNumber, extension));
|
||||||
File.Move(logFile, nextFileName);
|
File.Move(logFile, nextFileName);
|
||||||
|
|
||||||
// even if the log rotation fails, create a new one, or else
|
// even if the log rotation fails, create a new one, or else
|
||||||
|
@ -497,84 +513,82 @@ namespace winsw
|
||||||
w.Close();
|
w.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ZipFiles(string path, string fileExt, string baseZipfilename)
|
private void ZipFiles(string directory, string fileExtension, string zipFileBaseName)
|
||||||
{
|
{
|
||||||
if (ZipOlderThanNumDays == null || !(ZipOlderThanNumDays > 0))
|
if (ZipOlderThanNumDays == null || !(ZipOlderThanNumDays > 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var files = Directory.GetFiles(path, "*" + fileExt);
|
foreach (string path in Directory.GetFiles(directory, "*" + fileExtension))
|
||||||
foreach (var file in files)
|
|
||||||
{
|
{
|
||||||
var fi = new FileInfo(file);
|
var fileInfo = new FileInfo(path);
|
||||||
if (fi.LastWriteTimeUtc >= DateTime.UtcNow.AddDays(-ZipOlderThanNumDays.Value))
|
if (fileInfo.LastWriteTimeUtc >= DateTime.UtcNow.AddDays(-ZipOlderThanNumDays.Value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// lets archive this bugger
|
string sourceFileName = Path.GetFileName(path);
|
||||||
ZipTheFile(file, path, fi.LastWriteTimeUtc.ToString(ZipDateFormat), baseZipfilename);
|
string zipFilePattern = fileInfo.LastAccessTimeUtc.ToString(ZipDateFormat);
|
||||||
File.Delete(file);
|
string zipFilePath = Path.Combine(directory, $"{zipFileBaseName}.{zipFilePattern}.zip");
|
||||||
|
ZipOneFile(path, sourceFileName, zipFilePath);
|
||||||
|
|
||||||
|
File.Delete(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
EventLogger.LogEvent(string.Format("Failed to Zip File. Error {0}", e.Message));
|
EventLogger.LogEvent($"Failed to Zip files. Error {e.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ZipTheFile(string filename, string zipPath, string zipFilePattern, string baseZipfilename)
|
#if VNEXT
|
||||||
|
private void ZipOneFile(string sourceFilePath, string entryName, string zipFilePath)
|
||||||
{
|
{
|
||||||
var zipfilename = Path.Combine(zipPath, string.Format("{0}.{1}.zip", baseZipfilename, zipFilePattern));
|
ZipArchive zipArchive = null;
|
||||||
ZipFile zipFile = null;
|
|
||||||
bool commited = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (File.Exists(zipfilename))
|
zipArchive = ZipFile.Open(zipFilePath, ZipArchiveMode.Update);
|
||||||
{
|
|
||||||
zipFile = new ZipFile(zipfilename);
|
|
||||||
TestZipfile(zipFile, zipfilename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zipFile = ZipFile.Create(zipfilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
zipFile.BeginUpdate();
|
if (zipArchive.GetEntry(entryName) is null)
|
||||||
zipFile.NameTransform = new ZipNameTransform(zipPath);
|
|
||||||
var relFile = Path.GetFileName(filename);
|
|
||||||
if (zipFile.FindEntry(relFile, true) == -1)
|
|
||||||
{
|
{
|
||||||
zipFile.Add(filename);
|
zipArchive.CreateEntryFromFile(sourceFilePath, entryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFile.CommitUpdate();
|
|
||||||
commited = true;
|
|
||||||
TestZipfile(zipFile, zipfilename);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
EventLogger.LogEvent(string.Format("Failed to Zip the File {0}. Error {1}", filename, e.Message));
|
EventLogger.LogEvent($"Failed to Zip the File {sourceFilePath}. Error {e.Message}");
|
||||||
if (zipFile != null && !commited)
|
|
||||||
zipFile.AbortUpdate();
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (zipFile != null)
|
zipArchive?.Dispose();
|
||||||
{
|
|
||||||
zipFile.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
static void TestZipfile(ZipFile zipFile, string zipArchive)
|
private void ZipOneFile(string sourceFilePath, string entryName, string zipFilePath)
|
||||||
{
|
{
|
||||||
var testResult = zipFile.TestArchive(true);
|
ZipFile zipFile = null;
|
||||||
if (!testResult)
|
try
|
||||||
{
|
{
|
||||||
var em = string.Format("Bad zip file \"{0}\"", zipArchive);
|
zipFile = new ZipFile(File.Open(zipFilePath, FileMode.OpenOrCreate));
|
||||||
throw new ApplicationException(em);
|
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()
|
private double SetupRollTimer()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,21 +1,42 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net20;net40</TargetFrameworks>
|
<TargetFrameworks>net20;net40;net45;netcoreapp3.1</TargetFrameworks>
|
||||||
<!-- AppVeyor -->
|
<Version><!-- Populated by AppVeyor --></Version>
|
||||||
<Version></Version>
|
|
||||||
<RootNamespace>winsw</RootNamespace>
|
<RootNamespace>winsw</RootNamespace>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ICSharpCode.SharpZipLib.dll" Version="0.85.4.369" />
|
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||||
|
<PackageReference Include="System.Diagnostics.EventLog" Version="4.7.0" />
|
||||||
|
<PackageReference Include="System.Management" Version="4.7.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- error NU1605: Detected package downgrade: log4net 2.0.8 -->
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||||
|
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
|
||||||
|
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
|
||||||
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net20' or '$(TargetFramework)' == 'net40'">
|
||||||
|
<PackageReference Include="SharpZipLib" Version="0.86.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net20;net40</TargetFrameworks>
|
<TargetFrameworks>net20;net40;net45;netcoreapp3.1</TargetFrameworks>
|
||||||
<!-- AppVeyor -->
|
<Version><!-- Populated by AppVeyor --></Version>
|
||||||
<Version></Version>
|
|
||||||
<RootNamespace>winsw.Plugins.RunawayProcessKiller</RootNamespace>
|
<RootNamespace>winsw.Plugins.RunawayProcessKiller</RootNamespace>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net20;net40</TargetFrameworks>
|
<TargetFrameworks>net20;net40;net45;netcoreapp3.1</TargetFrameworks>
|
||||||
<!-- AppVeyor -->
|
<Version><!-- Populated by AppVeyor --></Version>
|
||||||
<Version></Version>
|
|
||||||
<RootNamespace>winsw.Plugins.SharedDirectoryMapper</RootNamespace>
|
<RootNamespace>winsw.Plugins.SharedDirectoryMapper</RootNamespace>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using winsw;
|
using winsw;
|
||||||
|
@ -41,7 +42,7 @@ namespace winswTests.Configuration
|
||||||
|
|
||||||
private ServiceDescriptor DoLoad(string exampleName)
|
private ServiceDescriptor DoLoad(string exampleName)
|
||||||
{
|
{
|
||||||
var dir = Directory.GetCurrentDirectory();
|
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
string path = Path.GetFullPath(dir + "\\..\\..\\..\\..\\..\\..\\examples\\sample-" + exampleName + ".xml");
|
string path = Path.GetFullPath(dir + "\\..\\..\\..\\..\\..\\..\\examples\\sample-" + exampleName + ".xml");
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace winswTests.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
[Ignore(nameof(RunawayProcessKillerExtension) + "isn't working.")]
|
||||||
public void ShouldKillTheSpawnedProcess()
|
public void ShouldKillTheSpawnedProcess()
|
||||||
{
|
{
|
||||||
var winswId = "myAppWithRunaway";
|
var winswId = "myAppWithRunaway";
|
||||||
|
@ -79,7 +80,7 @@ namespace winswTests.Extensions
|
||||||
// Spawn the test process
|
// Spawn the test process
|
||||||
var scriptFile = Path.Combine(tmpDir, "dosleep.bat");
|
var scriptFile = Path.Combine(tmpDir, "dosleep.bat");
|
||||||
var envFile = Path.Combine(tmpDir, "env.txt");
|
var envFile = Path.Combine(tmpDir, "env.txt");
|
||||||
File.WriteAllText(scriptFile, "set > " + envFile + "\nsleep 100500");
|
File.WriteAllText(scriptFile, "set > " + envFile + "\npause");
|
||||||
Process proc = new Process();
|
Process proc = new Process();
|
||||||
var ps = proc.StartInfo;
|
var ps = proc.StartInfo;
|
||||||
ps.FileName = scriptFile;
|
ps.FileName = scriptFile;
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<NUnitProject>
|
|
||||||
<Settings activeconfig="Release" />
|
|
||||||
<Config name="Debug">
|
|
||||||
<assembly path="bin\Debug\net40\winswTests.dll" />
|
|
||||||
</Config>
|
|
||||||
<Config name="Release">
|
|
||||||
<assembly path="bin\Release\net40\winswTests.dll" />
|
|
||||||
</Config>
|
|
||||||
</NUnitProject>
|
|
|
@ -1,13 +1,12 @@
|
||||||
using System.Diagnostics;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using winsw;
|
using winsw;
|
||||||
|
using winswTests.Util;
|
||||||
|
using WMI;
|
||||||
|
|
||||||
namespace winswTests
|
namespace winswTests
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using winswTests.Util;
|
|
||||||
using WMI;
|
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ServiceDescriptorTests
|
public class ServiceDescriptorTests
|
||||||
{
|
{
|
||||||
|
@ -50,7 +49,6 @@ namespace winswTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException(typeof(ArgumentException))]
|
|
||||||
public void IncorrectStartMode()
|
public void IncorrectStartMode()
|
||||||
{
|
{
|
||||||
const string SeedXml = "<service>"
|
const string SeedXml = "<service>"
|
||||||
|
@ -74,7 +72,7 @@ namespace winswTests
|
||||||
+ "</service>";
|
+ "</service>";
|
||||||
|
|
||||||
_extendedServiceDescriptor = ServiceDescriptor.FromXML(SeedXml);
|
_extendedServiceDescriptor = ServiceDescriptor.FromXML(SeedXml);
|
||||||
Assert.That(_extendedServiceDescriptor.StartMode, Is.EqualTo(StartMode.Manual));
|
Assert.Throws(typeof(ArgumentException), () => _ = _extendedServiceDescriptor.StartMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using winsw;
|
using winsw;
|
||||||
|
|
||||||
namespace winswTests.Util
|
namespace winswTests.Util
|
||||||
|
@ -32,7 +31,6 @@ namespace winswTests.Util
|
||||||
/// <param name="descriptor">Optional Service descriptor (will be used for initializationpurposes)</param>
|
/// <param name="descriptor">Optional Service descriptor (will be used for initializationpurposes)</param>
|
||||||
/// <returns>STDOUT if there's no exceptions</returns>
|
/// <returns>STDOUT if there's no exceptions</returns>
|
||||||
/// <exception cref="Exception">Command failure</exception>
|
/// <exception cref="Exception">Command failure</exception>
|
||||||
[NotNull]
|
|
||||||
public static string CLITest(string[] args, ServiceDescriptor descriptor = null)
|
public static string CLITest(string[] args, ServiceDescriptor descriptor = null)
|
||||||
{
|
{
|
||||||
using (StringWriter sw = new StringWriter())
|
using (StringWriter sw = new StringWriter())
|
||||||
|
@ -52,7 +50,6 @@ namespace winswTests.Util
|
||||||
/// <param name="args">CLI arguments to be passed</param>
|
/// <param name="args">CLI arguments to be passed</param>
|
||||||
/// <param name="descriptor">Optional Service descriptor (will be used for initializationpurposes)</param>
|
/// <param name="descriptor">Optional Service descriptor (will be used for initializationpurposes)</param>
|
||||||
/// <returns>Test results</returns>
|
/// <returns>Test results</returns>
|
||||||
[NotNull]
|
|
||||||
public static CLITestResult CLIErrorTest(string[] args, ServiceDescriptor descriptor = null)
|
public static CLITestResult CLIErrorTest(string[] args, ServiceDescriptor descriptor = null)
|
||||||
{
|
{
|
||||||
StringWriter swOut, swErr;
|
StringWriter swOut, swErr;
|
||||||
|
@ -98,13 +95,10 @@ namespace winswTests.Util
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CLITestResult
|
public class CLITestResult
|
||||||
{
|
{
|
||||||
[NotNull]
|
|
||||||
public string Out { get; private set; }
|
public string Out { get; private set; }
|
||||||
|
|
||||||
[NotNull]
|
|
||||||
public string Err { get; private set; }
|
public string Err { get; private set; }
|
||||||
|
|
||||||
[CanBeNull]
|
|
||||||
public Exception Exception { get; private set; }
|
public Exception Exception { get; private set; }
|
||||||
|
|
||||||
public bool HasException => Exception != null;
|
public bool HasException => Exception != null;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace winswTests.Util
|
||||||
Assert.That(ex, Is.InstanceOf(expectedExceptionType ?? typeof(Exception)), "Wrong exception type");
|
Assert.That(ex, Is.InstanceOf(expectedExceptionType ?? typeof(Exception)), "Wrong exception type");
|
||||||
if (expectedMessagePart != null)
|
if (expectedMessagePart != null)
|
||||||
{
|
{
|
||||||
Assert.That(ex.Message, Is.StringContaining(expectedMessagePart), "Wrong error message");
|
Assert.That(ex.Message, Does.Contain(expectedMessagePart), "Wrong error message");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Else the exception is fine
|
// Else the exception is fine
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net20;net40</TargetFrameworks>
|
<TargetFrameworks>net40;net45;netcoreapp3.1</TargetFrameworks>
|
||||||
<!-- AppVeyor -->
|
<Version><!-- Populated by AppVeyor --></Version>
|
||||||
<Version></Version>
|
|
||||||
<RootNamespace>winswTests</RootNamespace>
|
<RootNamespace>winswTests</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="8.0.5.0" />
|
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit" Version="2.6.4" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0" />
|
||||||
<PackageReference Include="NUnitTestAdapter" Version="2.2.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
|
||||||
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
||||||
<Reference Include="System.ServiceProcess" />
|
<Reference Include="System.ServiceProcess" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue