views:

3463

answers:

4

Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?

When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like:

vbc.exe [bunch of options] [looooong list of .vb files]

I would like to programatically call "something" that would take the .vbproj file and do whatever Visual Studio does to generate this long command line. I know i could parse the .vbproj myself and generate that command line, but I'd rather save myself all the reverse engineering and trial-and-error...

Is there a tool to do this? I'd rather be able to do it in a machine without having Visual Studio installed. However, if there's a way to call Visual Studio with some parameters to do it, then that'll be fine too.

I looked briefly at MSBuild, and it looks like it works from a .proj project file that i'd have to make especially, and that I'd need to update every time I add a file to the .vbproj file. (I did look briefly at it, so it's very likely I missed something important)

Any help will be greatly appreciated

+2  A: 

MSBuild can also take your solution file and use it to do the compile.

Rob Prouse
+9  A: 

MSBuild is the easiest way to go. For instance:

msbuild /property:Configuration=Release MyFile.vbproj
Jon Skeet
Thank you very much
Daniel Magliola
Providing an actual command line is what has pushed this comment over the edge from mediocrity into greatness.
Brandon Craig Rhodes
+1  A: 

You can use either MSBUILD or CSC. MSBuild, which as you mentioned, does use your project and solution files. CSC will compile specific files, or all files in a specific directory tree.

You should also look at automating your builds with NAnt and/or CruiseControl.net.

Also, here is an example on how to compile your code without visual studio using CSC. http://blog.slickedit.com/?p=163

AaronS
+1  A: 

Just so you know .vbproj and .csproj files are MSBuild. So everything that you've read, you can apply to those files directly.

Sayed Ibrahim Hashimi