I have a VB6 EXE that I use to build VS.NET 2003 projects. It works fine
when building a .NET Class Library, but it doesn't return when it kicks off a
build of a Setup & Deployment project.
To reproduce, using VS.NET 2003, just create 2 projects - a C# Class Library
and a Setup & Deployment project. Then edit the code in the Form_Load of the
following VB6 code to point to the projects you created. Notice the S&D
project builds, but devenv.exe never exits so the VB6 app doesn't finish.
Tim
Option Explicit
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Public Function ExecCmd(strCmdLine As String)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
Dim strapp As String
strapp = "cmd.exe"
' Start the shelled application:
Dim ret As Long
ret& = CreateProcessA(0&, strCmdLine, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, ret&)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ExecCmd = ret&
End Function
Private Sub Form_Load()
ExecCmd """C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\devenv"" ""X:\AAA\ClassLibrary1\ClassLibrary1.sln"" /nologo
/rebuild ""Release"" /out ""X:\AAA\ClassLibrary1\BuildLog.txt"""
ExecCmd """C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\devenv"" ""X:\AAA\Setup1\Setup1.sln"" /nologo /rebuild
""Release"" /out ""X:\AAA\Setup1\BuildLog.txt"""
End Sub
"Gary Chang[MSFT]" - 05 May 2006 09:28 GMT
Hi Tim,
Thank you posting!
Before we dig into this issue, would you please provide us some more
detailed information?
1. Is there any relationship between the .NET class library project and the
setup project? According to your sample code, they appear to be stand-alone
solution/project respectively.
2. If you only build that setup solution with your VB6 application, is it
OK?
3. If you build that setup solution via the command line, is there any
difference from using that VB6 application?
Thanks for your understanding!
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Tim Werth - 05 May 2006 14:59 GMT
Gary,
Sorry I didn't include this info earlier.
1. No relation between the class lib and the setup project. Just create a
class lib project and a setup project. Actually, you don't even have to
create the class lib project because it has nothing to do with this. The
class lib project really is just so you can see devenv exit after building it.
2. The setup solution always builds (whether by itself or after the class
lib solution), but devenv.exe never exits after the setup solution is built.
3. Building the setup solution from the command line using the exact same
syntax works as expected, i.e. devenv.exe exits after the build of the setup
project. It is interesting to note that from the command line, one can use
Task Manager to see devenv.com and devenv.exe run and then exit. The VB6
code I provided doesn't specify an extension on devenv so I would expect
devenv.com to be started, but it doesn't. Instead, just devenv.exe runs. If
you modify the VB6 code to explicitly specify devenv.com, you can see it and
devenv.exe run in Task Manager but the end result is the same (devenv.exe
doesn't exit after building the setup project).
Tim
"Gary Chang[MSFT]" - 08 May 2006 10:28 GMT
Hi Tim,
Thanks for the detailed response!
Based on my debugging, it appears the VS2003 process could end well if you
don't use the WaitForSingleObject when it is building a setup project. This
behavior is really odd, there may be have a deadlock during that scenario.
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.