Click here to Skip to main content
15,891,828 members
Articles / Desktop Programming / Windows Forms

Deployer

Rate me:
Please Sign up or sign in to vote.
4.43/5 (17 votes)
30 Mar 2012Apache14 min read 82.2K   543   91  
Automate deployment of Windows Services, ClickOnce, and other .NET applications.
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceProcess;
using System.Windows.Forms;

using Deployer.Logic;
using System.Threading;

namespace Deployer
{
    static class Program
    {
        private static Controller _ctrl;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            _fileSystemMutex = new Mutex(false, "DeployerMutexxx");

            _ctrl = new Controller();
            _ctrl.NoticeEvent += new Controller.NoticeDelegate(_ctrl_NoticeEvent);

#if DEBUG
            Application.Run(new MainForm());
#else
            ServiceBase.Run(new DeployerService());
#endif
        }

        private static Mutex _fileSystemMutex;
        static void _ctrl_NoticeEvent(string message)
        {
            try
            {
                _fileSystemMutex.WaitOne();

                string logPath = string.Format("{0}\\{1}.txt", Properties.Settings.Default.LogPath, DateTime.Now.ToString("yyyy-MM-dd"));

                using (StreamWriter sw = new StreamWriter(logPath, true))
                    sw.WriteLine("{0} - {1}", DateTime.Now, message);
            }
            finally
            {
                _fileSystemMutex.ReleaseMutex();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Chief Technology Officer
United States United States
If you liked this article, consider reading other articles by me. For republishing article on other websites, please contact me by leaving a comment.

Comments and Discussions