Skip to content

Instantly share code, notes, and snippets.

@slimflem
Created September 1, 2013 21:02
Show Gist options
  • Select an option

  • Save slimflem/6407306 to your computer and use it in GitHub Desktop.

Select an option

Save slimflem/6407306 to your computer and use it in GitHub Desktop.
This csproj file snippet shows PropertyGroup elements allowing to build a Console application as a Windows Service for Release Configuration and a standard Console application when in Debug. notice Debug is Exe (Console) and Release is WinExe (Windows Service).
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<OutputType>Exe</OutputType>
<StartupObject>TheProgram.ServiceHost.Program</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<OutputType>WinExe</OutputType>
<StartupObject>TheProgram.ServiceHost.WindowsServiceHost</StartupObject>
</PropertyGroup>
@slimflem

slimflem commented Sep 1, 2013

Copy link
Copy Markdown
Author

WindowsServiceHost is the ServiceBase class. You will also need an Installer class in your project as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment