From 6c0f6d1f7a94f24a68e5eb00563266c22cb2224b Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Sun, 4 Dec 2016 09:34:19 +0100 Subject: [PATCH] Fixes #142 - Deploy the automatic build on Appveyor (#144) * First configuration stub * Get rid of the old winsw_cert.pfx references, adjust docs * Fix the corrupted log4net reference, we use 2.0.3 * Generate stub SNK file * Signing: Try full SDK path to generate SNKs * Fix the path * Signing: Sign all assemblies being packed into WinSW * Tests: Try enabling tests * Tests and artifacts: Use absolute paths * Artifact path must be relative * The test DLL is the NUnit one * nunit-console does not require loggers * NUnit: Try picking all DLLs in the output folder * NUnit console: No wildcards * Tests: Fix the test project to make it properly working with the new project structure * Docs: Clarify the specifics of external extension usage * Add AppVeyor badge to README.md --- .gitignore | 1 - README.md | 4 +- appveyor.yml | 39 +++++++++++++++++++ doc/extensions/extensions.md | 2 + sign.sh | 2 +- src/Core/ServiceWrapper/winsw.csproj | 1 - src/Core/WinSWCore/WinSWCore.csproj | 5 +-- .../RunawayProcessKiller.csproj | 6 ++- .../SharedDirectoryMapper.csproj | 4 ++ .../Extensions/ExtensionTestBase.cs | 23 +++++++++++ .../Extensions/RunawayProcessKillerTest.cs | 11 +++--- ...erTest.cs => SharedDirectoryMapperTest.cs} | 8 ++-- src/Test/winswTests/NunitTest.nunit | 10 +++-- src/Test/winswTests/packages.config | 3 +- src/Test/winswTests/winswTests.csproj | 6 ++- winsw.csproj | 4 -- 16 files changed, 102 insertions(+), 27 deletions(-) create mode 100644 appveyor.yml create mode 100644 src/Test/winswTests/Extensions/ExtensionTestBase.cs rename src/Test/winswTests/Extensions/{WinSWExtensionManagerTest.cs => SharedDirectoryMapperTest.cs} (94%) diff --git a/.gitignore b/.gitignore index 41c0c8a..295b03b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ obj *.suo /UpgradeLog.htm /winsw.csproj.user -/winsw_cert.pfx *.user /src/packages/NUnit.2.6.4 /src/packages/ILMerge.MSBuild.Tasks.1.0.0.3 diff --git a/README.md b/README.md index e4be36e..86f457d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ winsw: Windows service wrapper in less restrictive license ========================= +[![Build status](https://ci.appveyor.com/api/projects/status/i94752yal9iy77in?svg=true)](https://ci.appveyor.com/project/oleg-nenashev/winsw) + WinSW is an executable binary, which can be used to wrap and manage a custom process as a Windows service. Once you download the installation package, you can rename `winsw.exe` to any name, e.g. `myService.exe`. @@ -65,6 +67,6 @@ New versions with fixes may be released on-demand. ### Build Environment * IDE: [Visual Studio Community 2013](http://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx) (free for open-source projects) -* winsw_cert.pfx should be available in the project's root +* `winsw-key.snk` should be available in the project's root in order to build the executable * You can generate the certificate in "Project Settings/Signing" * The certificate is in .gitignore list. Please do not add it to the repository diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..d3a2de5 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,39 @@ + +version: 2.0.0.{build} + +# Do not build on tags (GitHub and BitBucket) +skip_tags: true + +# Project configuration +image: Visual Studio 2013 +platform: Any CPU +configuration: Release + +# Automatically register private account and/or project AppVeyor NuGet feeds. +nuget: + account_feed: true + project_feed: true + disable_publish_on_pr: true # disable publishing of .nupkg artifacts to + +before_build: + # Check SDKs + - ECHO "Installed SDKs:" + - ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\"" + # Generates a temporary SNK. Not for real signing + - cmd: "\"C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin/sn.exe\" -k winsw_key.snk" + +build: + parallel: true + project: src\winsw.sln + +test_script: +# Runner for NUnit2 +- ps: nunit-console 'C:/projects/winsw/src/Test/winswTests/bin/Release/winswTests.dll' 'C:/projects/winsw/src/Test/winswTests/bin/Release/SharedDirectoryMapper.dll' 'C:/projects/winsw/src/Test/winswTests/bin/Release/RunawayProcessKiller.dll' + +artifacts: + - path: 'src/Core/ServiceWrapper/bin/Release/winsw.exe' + name: WinSW + + + + \ No newline at end of file diff --git a/doc/extensions/extensions.md b/doc/extensions/extensions.md index 335e6d6..dc65c34 100644 --- a/doc/extensions/extensions.md +++ b/doc/extensions/extensions.md @@ -28,5 +28,7 @@ Generic extension creation guideline: WinSW engine will automatically locate your extension using the class name in the [XML Configuration File](../xmlConfigFile.md). See configuration samples provided for the extensions in the core. +For extensions from external DLLs, the `className` field should also specify the assembly name. +It can be done via fully qualified class name or just by the `${CLASS_NAME}, ${ASSEMBLY_NAME}` declaration. Please note that in the current versions of WinSW `2.x` the binary compatibility of extension APIs *is not guaranteed*. diff --git a/sign.sh b/sign.sh index 03deddd..8124c08 100755 --- a/sign.sh +++ b/sign.sh @@ -2,7 +2,7 @@ export "PATH=$PATH:/cygdrive/c/Program Files/Windows Kits/8.1/bin/x86" for f in Release Debug; do - signtool sign /f winsw_cert.pfx /t http://timestamp.verisign.com/scripts/timestamp.dll bin/$f/winsw.exe + signtool sign /f winsw-key.snk /t http://timestamp.verisign.com/scripts/timestamp.dll bin/$f/winsw.exe signtool verify /v /pa bin/$f/winsw.exe done echo success diff --git a/src/Core/ServiceWrapper/winsw.csproj b/src/Core/ServiceWrapper/winsw.csproj index ad303bd..cc5852c 100644 --- a/src/Core/ServiceWrapper/winsw.csproj +++ b/src/Core/ServiceWrapper/winsw.csproj @@ -90,7 +90,6 @@ - Designer diff --git a/src/Core/WinSWCore/WinSWCore.csproj b/src/Core/WinSWCore/WinSWCore.csproj index 48f925d..bac7cc4 100644 --- a/src/Core/WinSWCore/WinSWCore.csproj +++ b/src/Core/WinSWCore/WinSWCore.csproj @@ -33,9 +33,7 @@ true - - - ..\..\..\winsw_cert.pfx + $(SolutionDir)..\winsw_key.snk @@ -71,7 +69,6 @@ - diff --git a/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj b/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj index e24e615..0e4d8f7 100644 --- a/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj +++ b/src/Plugins/RunawayProcessKiller/RunawayProcessKiller.csproj @@ -31,9 +31,13 @@ prompt 4 + + true + $(SolutionDir)..\winsw_key.snk + - ..\..\packages\log4net.2.0.5\lib\net20-full\log4net.dll + ..\..\packages\log4net.2.0.3\lib\net20-full\log4net.dll diff --git a/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj b/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj index 6552879..0b0632c 100644 --- a/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj +++ b/src/Plugins/SharedDirectoryMapper/SharedDirectoryMapper.csproj @@ -29,6 +29,10 @@ prompt 4 + + true + $(SolutionDir)..\winsw_key.snk + diff --git a/src/Test/winswTests/Extensions/ExtensionTestBase.cs b/src/Test/winswTests/Extensions/ExtensionTestBase.cs new file mode 100644 index 0000000..c7e8541 --- /dev/null +++ b/src/Test/winswTests/Extensions/ExtensionTestBase.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace winswTests.Extensions +{ + /// + /// Base class for testing of WinSW Extensions. + /// + public class ExtensionTestBase + { + /// + /// Defines the name of the extension to be passed in the configuration. + /// This name should point to assembly in tests, because we do not merge extension DLLs for testing purposes. + /// + /// Type of the extension + /// String for Type locator, which includes class and assembly names + protected static String getExtensionClassNameWithAssembly(Type type) + { + return type.ToString() + ", " + type.Assembly; + } + } +} diff --git a/src/Test/winswTests/Extensions/RunawayProcessKillerTest.cs b/src/Test/winswTests/Extensions/RunawayProcessKillerTest.cs index e979bfa..7d5cafa 100644 --- a/src/Test/winswTests/Extensions/RunawayProcessKillerTest.cs +++ b/src/Test/winswTests/Extensions/RunawayProcessKillerTest.cs @@ -5,18 +5,19 @@ using winsw.Plugins.SharedDirectoryMapper; using winswTests.util; using winsw.Plugins.RunawayProcessKiller; -namespace winswTests.extensions +namespace winswTests.Extensions { [TestFixture] - class RunawayProcessKillerExtensionTest + class RunawayProcessKillerExtensionTest : ExtensionTestBase { ServiceDescriptor _testServiceDescriptor; readonly TestLogger _logger = new TestLogger(); + string testExtension = getExtensionClassNameWithAssembly(typeof(RunawayProcessKillerExtension)); + [SetUp] public void SetUp() { - string testExtension = typeof (RunawayProcessKillerExtension).ToString(); string seedXml = "" + " " + " SERVICE_NAME " @@ -26,7 +27,7 @@ namespace winswTests.extensions + " -Xrs -jar \\\"%BASE%\\slave.jar\\\" -jnlpUrl ... " + " rotate " + " " - + " " + + " " + " foo/bar/pid.txt" + " 5000 " + " true" @@ -44,7 +45,7 @@ namespace winswTests.extensions Assert.AreEqual(1, manager.Extensions.Count, "One extension should be loaded"); // Check the file is correct - var extension = manager.Extensions[typeof(RunawayProcessKillerExtension).ToString()] as RunawayProcessKillerExtension; + var extension = manager.Extensions["killRunawayProcess"] as RunawayProcessKillerExtension; Assert.IsNotNull(extension, "RunawayProcessKillerExtension should be loaded"); Assert.AreEqual("foo/bar/pid.txt", extension.Pidfile, "Loaded PID file path is not equal to the expected one"); Assert.AreEqual(5000, extension.StopTimeout.TotalMilliseconds, "Loaded Stop Timeout is not equal to the expected one"); diff --git a/src/Test/winswTests/Extensions/WinSWExtensionManagerTest.cs b/src/Test/winswTests/Extensions/SharedDirectoryMapperTest.cs similarity index 94% rename from src/Test/winswTests/Extensions/WinSWExtensionManagerTest.cs rename to src/Test/winswTests/Extensions/SharedDirectoryMapperTest.cs index 5ccd638..f6f5d82 100644 --- a/src/Test/winswTests/Extensions/WinSWExtensionManagerTest.cs +++ b/src/Test/winswTests/Extensions/SharedDirectoryMapperTest.cs @@ -4,18 +4,20 @@ using winsw.Extensions; using winsw.Plugins.SharedDirectoryMapper; using winswTests.util; -namespace winswTests.extensions +namespace winswTests.Extensions { [TestFixture] - class WinSWExtensionManagerTest + class SharedDirectoryMapperTest : ExtensionTestBase { ServiceDescriptor _testServiceDescriptor; readonly TestLogger _logger = new TestLogger(); + string testExtension = getExtensionClassNameWithAssembly(typeof(SharedDirectoryMapper)); + [SetUp] public void SetUp() { - string testExtension = typeof (SharedDirectoryMapper).ToString(); + string seedXml = "" + " " + " SERVICE_NAME " diff --git a/src/Test/winswTests/NunitTest.nunit b/src/Test/winswTests/NunitTest.nunit index 3eaf587..6bf5283 100644 --- a/src/Test/winswTests/NunitTest.nunit +++ b/src/Test/winswTests/NunitTest.nunit @@ -1,7 +1,9 @@ - + - + - - \ No newline at end of file + + + + diff --git a/src/Test/winswTests/packages.config b/src/Test/winswTests/packages.config index cba033f..1638760 100644 --- a/src/Test/winswTests/packages.config +++ b/src/Test/winswTests/packages.config @@ -1,5 +1,6 @@  - + + \ No newline at end of file diff --git a/src/Test/winswTests/winswTests.csproj b/src/Test/winswTests/winswTests.csproj index 18e0aaf..caab84e 100644 --- a/src/Test/winswTests/winswTests.csproj +++ b/src/Test/winswTests/winswTests.csproj @@ -46,14 +46,18 @@ False ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + ..\..\packages\log4net.2.0.3\lib\net20-full\log4net.dll + + - + diff --git a/winsw.csproj b/winsw.csproj index dc9456c..fc6a167 100644 --- a/winsw.csproj +++ b/winsw.csproj @@ -16,7 +16,6 @@ false false - winsw_cert.pfx @@ -93,9 +92,6 @@ Designer - - - False