Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script for building/debugging services

0 views
Skip to first unread message

arthernan

unread,
May 9, 2006, 5:33:16 PM5/9/06
to
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("OutputPath").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

arthernan

unread,
May 11, 2006, 12:23:42 PM5/11/06
to
Has anybody had bad experiences debugging services?

I would love to hear an opinion to my post.

Arturo

David Levine

unread,
May 12, 2006, 4:37:27 AM5/12/06
to
Why not run the service as a normal executable when you want to debug it?
You can pass it a command line argument (e.g. "exe") that tells it to run as
an executable - when there is no argument it runs itself as a service.

"arthernan" <arth...@hotmail.com> wrote in message
news:1147210396....@e56g2000cwe.googlegroups.com...

0 new messages