Skip to content

Commit

Permalink
v1.0.1 release - minor change to installer class and demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerje committed Feb 24, 2014
1 parent f88e4b7 commit 35d0a0d
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 48 deletions.
74 changes: 43 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@ Get the [NuGet package here][].

### Using the library is easy.

If you want a service installer, you must declare one like this:

```C#
public class MyInstaller : ServiceRunnerInstaller
{
protected override string ServiceName { get { return "MyServiceRunnerDemo"; } }
protected override string ServiceDescription { get { return "My Service Runner Demo description"; } }
protected override string ServiceDisplayName { get { return "My Service Runner Demo"; } }
protected override ServiceRunnerStartMode StartMode { get { return ServiceRunnerStartMode.Manual; } }
protected override ServiceRunnerAccount Account { get { return ServiceRunnerAccount.LocalSystem; } }
}
```

And then you just write your start and stop actions like this in your cosole app:
Just write your start and stop actions like this in your console app:

```C#
class Program
Expand All @@ -32,29 +19,54 @@ And then you just write your start and stop actions like this in your cosole app
runner.Run(args,
arguments =>
{
File.WriteAllLines(logFile, new string[]
{
string.Format("args count: {0}", arguments.Length)
});
Console.WriteLine("args count: {0}", arguments.Length);
File.WriteAllLines(logFile, new string[]
{
"start called"
});
Console.WriteLine("start called");
//write your start code here
// . . .
},
() =>
{
File.WriteAllLines(logFile, new string[]
{
"stop called"
});
Console.WriteLine("stop called");
//write your stop code here
// . . .
});
Console.ReadLine();
}
}
```


The ServiceRunnerInstaller class must be inherited in your own project in order for the installutil installer to properly install your application as a Windows service. You can leave the implementation empty if you want the default values (shown). If you want different values, declare a class like the code below and change the values.

```C#
/// <summary>
/// This class (name unimportant) must exist in your console app
/// for the installer to be recognized when you run installutil.exe
/// from the Windows\Microsoft.NET\Framework64\v4.0.30319 directory.
/// </summary>
public class MyInstaller : ServiceRunnerInstaller
{
protected override string ServiceName
{
get { return "ServiceRunner"; }
}

protected override string ServiceDescription
{
get { return "Service Runner description"; }
}

protected override string ServiceDisplayName
{
get { return "Service Runner"; }
}

protected override ServiceRunnerStartMode StartMode
{
get { return ServiceRunnerStartMode.Manual; }
}

protected override ServiceRunnerAccount Account
{
get { return ServiceRunnerAccount.LocalSystem; }
}
}
```


[NuGet package here]: http://www.nuget.org/packages/ServiceRunner/
4 changes: 2 additions & 2 deletions src/ServiceRunner/ServiceRunner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
13 changes: 7 additions & 6 deletions src/ServiceRunner/ServiceRunner/ServiceRunnerInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ServiceRunner
{
[RunInstaller(true)]
public abstract class ServiceRunnerInstaller : System.Configuration.Install.Installer
public class ServiceRunnerInstaller : System.Configuration.Install.Installer
{
protected ServiceRunnerInstaller()
{
Expand Down Expand Up @@ -75,11 +75,12 @@ private void InitializeComponent()

}

protected abstract string ServiceName { get; }
protected abstract string ServiceDescription { get; }
protected abstract string ServiceDisplayName { get; }
protected abstract ServiceRunnerStartMode StartMode { get; }
protected abstract ServiceRunnerAccount Account { get; }
protected virtual string ServiceName { get { return "ServiceRunner"; } }
protected virtual string ServiceDescription { get { return "Service Runner description"; } }
protected virtual string ServiceDisplayName { get { return "Service Runner"; } }
protected virtual ServiceRunnerStartMode StartMode { get { return ServiceRunnerStartMode.Manual; } }
protected virtual ServiceRunnerAccount Account { get { return ServiceRunnerAccount.LocalSystem; } }


private System.ServiceProcess.ServiceInstaller serviceInstaller1;
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
Expand Down
34 changes: 29 additions & 5 deletions src/ServiceRunner/ServiceRunnerDemo/MyInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,36 @@

namespace ServiceRunnerDemo
{
/// <summary>
/// This class (name unimportant) must exist in your console app
/// for the installer to be recognized when you run installutil.exe
/// from the Windows\Microsoft.NET\Framework64\v4.0.30319 directory.
/// </summary>
public class MyInstaller : ServiceRunnerInstaller
{
protected override string ServiceName { get { return "MyServiceRunnerDemo"; } }
protected override string ServiceDescription { get { return "My Service Runner Demo description"; } }
protected override string ServiceDisplayName { get { return "My Service Runner Demo"; } }
protected override ServiceRunnerStartMode StartMode { get { return ServiceRunnerStartMode.Manual; } }
protected override ServiceRunnerAccount Account { get { return ServiceRunnerAccount.LocalSystem; } }
protected override string ServiceName
{
get { return "ServiceRunner"; }
}

protected override string ServiceDescription
{
get { return "Service Runner description"; }
}

protected override string ServiceDisplayName
{
get { return "Service Runner"; }
}

protected override ServiceRunnerStartMode StartMode
{
get { return ServiceRunnerStartMode.Manual; }
}

protected override ServiceRunnerAccount Account
{
get { return ServiceRunnerAccount.LocalSystem; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
4 changes: 2 additions & 2 deletions src/ServiceRunner/ServiceRunnerDemo/ServiceRunnerDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MyInstaller.cs" />
<Compile Include="Program.cs">
<Compile Include="MyInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ServiceRunner</id>
<version>1.0.0</version>
<title>ServiceRunner</title>
<authors>Tyler Jensen</authors>
<owners>Tyler Jensen</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>https://github.com/duovia/ServiceRunner</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ServiceRunner is a library to make it easy to create a simple .NET Windows Service quickly, using a console application that can be debugged and later installed and run as a service with a bare minimum of code..</description>
<releaseNotes>First release.</releaseNotes>
<copyright>Copyright 2014 Duovia Inc.</copyright>
<language />
<tags>Windows Service Host</tags>
</metadata>
</package>
Binary file not shown.
4 changes: 4 additions & 0 deletions src/ServiceRunner/packages/repositories.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\ServiceRunnerDemo\packages.config" />
</repositories>

0 comments on commit 35d0a0d

Please sign in to comment.