Not Steve Not Steve - 5 months ago 21
Vb.net Question

How to Build a Visual Studio 2015 vb solution from command line in Windows 10

this might be a really simple question (the content covered in the following question is new to me), but how do I build and run a Visual Studio solution (written in visual basic, not sure if that matters), from the Command Prompt window in Windows 10? I've tried searching the internet, but for so many answers none of them seem to work. I've tried devenv and /build and either get a 'devenv is not recognized as an internal or external command, operable program or batch file.' error or 'The filename, directory name, or volume label syntax is incorrect' error. Let me know how I can clarify this question. Thanks!

Answer

You need to use msbuild in order to build your project or solution.

Steps:

  1. Locate Msbuild.exe (For Visual studio 2015, default locaiton is: C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe)
  2. Open a command line, then execute:

.

%Msbuild% %VBProj% /p:Configuration=Release

You will have to replaces %Msbuild% by the full path of your msbuild.exe and %vbproj% by the full path of the vbproj or SLN file you want to build.

As for the last argument, it is used to specify that you want to build the Release version.

Here is an example according to my environment

C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\MyUser\Documents\Visual Studio 2015\Projects\WpfApplication2\WpfApplication2.sln" /p:Configuration=Release

In this example, I specified the path of my Visual studio 2015 along with the Solution I wanted to build (WpfApplication2) and specified I wanted the release build.

For a complete list of all the switches you can use, see the official documentation.