Skip to main content

Posts

Showing posts with the label Windows

...

....

C# - Creating MSBuild Tasks [Beginner]

At some point with any decently complex project, you are going to need to start customizing your build process. Visual Studio makes this possible, and not too terribly painful, by giving developers the ability to write custom MSBuild project files. But eventually, you are going to hit the limit of what the MSBuild XML syntax can do for you - but when you reach that point, there is something else waiting - custom tasks! MSBuild gives you the ability to write custom build tasks in C# (or any .NET language), and use those tasks inside of MSBuild project files. We are going to be taking a look today at how to create these tasks and how to use them. So first, we need to create a task. To do this, you need a new Visual Studio project - any type will do, but it is easiest to go with a class library: Once you have a new blank project, we need to add a few references in order to get the classes we need to create a task. To do this, right click on "References" in Solut

C# - Creating a Simple Windows Service [Beginner]

We all know what a WindowsService is - a long running executable that's designed to work without user interaction. They can be configured to start when the system boots and they can be run without any users logged into the system. This tutorial is going to provide step-by-step instructions on how to build a Windows Service using C# and .NET. The first thing you're going to want to do is create a new Console Application in Visual Studio. I like to start building services as console applications so they can easily be tested and debugged before converting them to services. In order to build services, we depend on some .NET objects location in the System.ServiceProcess and System.Configuration.Install assemblies. Go ahead and add those references to your project. When you created the project, Visual Studio should have created a file called Program.cs , which looks something like this: using System ; using System . Collections . Generic ; using Sy