Home All Groups Group Topic Archive Search About

Script for building/debugging services

Author
19 Jul 2006 10:41 PM
Be_Reasonable
I have found services debugging to be a big pain. One reason is because

the play button in VS is worthless for this kind of application.

So I wrote this scripts that will execute for an app whose name ends on

Service, it will lookup the debug directory, Stop the service copy the
executables and restart the service. Now there is a lot of room for
improvement. But I thought I'd share and maybe someone out there will
improve on it. It also executes when the app has just been built, so
you only need to attach to the process instead of hitting the arrow.


Or maybe I am missing something; and there is no need for this at all.


To make this work you need to open the Macro editor on the menu it is:
"Tools/Macros/Macro IDE ...". There you can edit the MyMacros template.



Public Module EnvironmentEvents


#Region "Automatically generated code, do not modify"


    Private Sub BuildEvents_OnBuildDone(ByVal Scope As
EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles
BuildEvents.OnBuildDone
        Debug.main()
    End Sub


End Module


Public Module Debug
    Private fullexepath As String = "C:\Program Files\My company\My
app"
    Sub main()


        Dim _project As EnvDTE.Project
        _project = DTE.Solution.Projects.Item(1)


        If
_project.Properties.Item("Title").Value.ToString.EndsWith("Service")
Then


            Dim _process As Diagnostics.Process
            _process =
Diagnostics.Process.Start("C:\Windows\system32\cmd.exe", "/c ""net stop

TNAEventService""")
            _process.WaitForExit()


            Dim OutputPath As String
            OutputPath =
_project.Properties.Item("LocalPath").Value.ToString()
            OutputPath +=
_project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPa­th").Value



            For Each OutputPath In Directory.GetFiles(OutputPath)
                Dim fi As FileInfo = New FileInfo(OutputPath)
                Dim vFileStream As FileStream
                If File.Exists(fullexepath + "\" + fi.Name) Then
                    If Not Directory.Exists(fullexepath + "\old") Then
                        Directory.CreateDirectory(fullexepath + "\old")

                    End If
                    File.Move(fullexepath + "\" + fi.Name, fullexepath
+ "\old\" + fi.Name + "." + Now.ToString("yyyymmdd hhmm"))
                End If
                File.Copy(OutputPath, fullexepath + "\" + fi.Name)
            Next


            _process =
Diagnostics.Process.Start("C:\Windows\system32\cmd.exe", "/c ""net
start TNAEventService""")
            _process.WaitForExit()
        End If
    End Sub


End Module

AddThis Social Bookmark Button