0

How can I build a Project programattically in VB.NET ?

2
  • Do you mean you want to automate your build? Commented Jan 29, 2009 at 20:48
  • I basically have an Add-In project that inspects variables in a loaded project, writes them to the database, then compiles (builds) the loaded project. Commented Jan 29, 2009 at 20:49

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1
System.Diagnostics.Process.Start("msbuild.exe");

Comments

0

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

Comments

0

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.