Reputation: 1487
How can I build a Project programattically in VB.NET ?
Upvotes: 0
Views: 2480
Reputation: 34347
It depends on why you are wanting to do this, but have you considered using TFS or something similar to do this instead of rolling your own process?
Upvotes: 0
Reputation: 1749
The following code compiles a application on form load, although would it not be a better idea to have any variables that change stored in a external settings file rather re-compile the application ?
Imports System.Diagnostics.Process
Public Class Form1
Public Sub BuildProject(ByVal pProject As String)
Dim lBuildString As String = String.Format("C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe {0} /t:Rebuild /p:Configuation=Release", pProject)
Dim lReturnID = Shell(lBuildString, AppWinStyle.NormalFocus, False)
'System.Diagnostics.Process.Start(lBuildString)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
BuildProject("C:\Programming\CommunicationsService\Communications_Service\Service_Tem[\Service_Tem[.vbproj")
End Sub
End Class
Upvotes: 0
Reputation: 1622
You can launch devenv.exe, the VS IDE executable, like so:
devenv c:\myproj\myproj.vbproj /rebuild release
It runs silently and you can also specify a log file for output. You might also be able to run vbc, which is the VB compiler.
Upvotes: 1