Skip to main content
Email Password   helpLost your password?

Sample Image - builditemincontextmenu.jpg

Introduction

This little article can give you a hint on how you can build your solution files quickly without running 6 Visual Studio applications that enlarge your scratch file till your computer is slow like my grandma.

First of all run %ProgramFiles%\Microsoft Visual Studio .NET\Common7\Tools\vsvars32.bat, if devenv.exe (Visual Studio IDE) could not be found from command line.

Command line switches of devenv.exe

To see this list, type devenv /? on command prompt

Console Application BuilderHelper

This little console application is able to check the return value from devenv.exe and we can display the build log if there went something wrong.

The basic method looks like this:

System.Diagnostics.ProcessStartInfo is filled with needed information.

public int Build(string solutionFile, string solutionConfig)
{
    // get temp logfile path

    string logFileName = System.IO.Path.GetTempFileName();
    // populate process environment

    System.Diagnostics.ProcessStartInfo psi = 
        new System.Diagnostics.ProcessStartInfo();
    psi.FileName =@"devenv.exe";
    psi.ErrorDialog = true;
    psi.Arguments =  "\"" +solutionFile +"\"" +  
         @" /rebuild "+ solutionConfig 
         + " /out " + logFileName;

Now we start the process and wait for exit.

// start process

System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
// instruct process to wait for exit

p.WaitForExit();
// get return code

int exitCode = p.ExitCode;
// free process resources

p.Close();

If devenv.exe did not return zero, we display the build log to the user.

// if there was a build error, display build log to console

if (exitCode != 0)
{
    System.IO.TextReader reader =  System.IO.File.OpenText(logFileName);
    errorLog = reader.ReadToEnd();
    reader.Close();
    //

    System.Console.WriteLine(errorLog);
    System.Console.WriteLine("Hit enter to abort...");
    System.Console.Read();
}
// delete temp logfile

System.IO.File.Delete(logFileName);

Last but not least, we return the code.

// return process exit code

    return exitCode;
}

Build Batch

Extend context menu with build item

File Extension Dialog

Have phun with it...

Revision History

16.12.2002

14.12.2002

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
QuestionDoes anybody know how to update web reference in a solution within command line? Pin
gusenica
3:30 25 Apr '08  
GeneralMy Version Pin
eraserhead
9:21 16 Oct '03  
GeneralDoes anyone know how to display the build log whilst command line builds are in progress? Pin
[DAve]
1:08 1 May '03  
GeneralRe: Does anyone know how to display the build log whilst command line builds are in progress? Pin
normanr
5:37 16 Jul '04  
GeneralRe: Does anyone know how to display the build log whilst command line builds are in progress? Pin
[DAve]
5:55 16 Jul '04  
GeneralRe: Does anyone know how to display the build log whilst command line builds are in progress? Pin
M_A_MaDeRo
6:44 25 Jul '05  
Generalproblem with devenv.exe (vs.net) Pin
nagash1
18:01 7 Mar '03  
GeneralRe: problem with devenv.exe (vs.net) Pin
Jerry Maguire
3:49 8 Mar '03  
GeneralRe: problem with devenv.exe (vs.net) Pin
Jerry Maguire
6:06 12 Mar '03  
GeneralRunning from IIS Pin
Nikolay Simeonov
10:03 16 Dec '02  
GeneralRe: Running from IIS Pin
Jerry Maguire
12:50 16 Dec '02  
GeneralRe: Running from IIS Pin
Nikolay Simeonov
13:01 16 Dec '02  
GeneralRe: Running from IIS Pin
Jerry Maguire
13:16 16 Dec '02  
GeneralProject Path containing SPACEs Pin
CoolDude
3:13 16 Dec '02  
GeneralRe: Project Path containing SPACEs Pin
Jerry Maguire
4:55 16 Dec '02  
GeneralREG File Pin
Ryan Farley
11:07 10 Dec '02  
GeneralRe: REG File Pin
Jerry Maguire
13:04 11 Dec '02  
GeneralGerman Screenshots, Pin
Jerry Maguire
13:14 9 Dec '02  
GeneralRe: German Screenshots, Pin
Daniel Turini
22:12 9 Dec '02  
GeneralRe: German Screenshots, Pin
Heath Stewart
2:52 10 Dec '02  
GeneralRe: German Screenshots, Pin
Jerry Maguire
3:22 10 Dec '02  
GeneralRe: German Screenshots, Pin
Anonymous
4:04 10 Dec '02  
GeneralRe: German Screenshots, Pin
Uwe Keim
7:34 10 Dec '02  
GeneralRe: German Screenshots, Pin
Anonymous
7:36 10 Dec '02  
GeneralRe: German Screenshots, Pin
Uwe Keim
8:00 10 Dec '02  


Last Updated 13 Dec 2002 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009