How to execute 'msbuild' command from a batch file

batch-file, console, visual-studio, visual-studio-2010

Solution

You're not in the right directory, you need to cd to the directory that msbuild is in. Try this:

set pathMSBuild="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\"
@echo off
cls
cd %pathMSBuild%
msbuild.exe "C:\myPath\..\MyFolderSolution\lucre.sln" /p:configuration=debug
pause

Or you could add the msbuild directory to your path, and skip the lines with set and cd.

Problem

I would like to create a batch file to make the builds from my VS project in on click. All the days I do the following steps: - Opens a cmd console as administrador - Go to the path of my project/solution (using the CD.., CD commands) Write the following command to make the build: msbuild mySolution.sln /p:configuration=debug As commented before, I'd like to make all this process in one simply click. So, I'm trying to create a .bat file to do it. This is the code of my batch file: ``` set location="C:\myPath\..\MyFolderSolution" set pathMSBuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" @echo off cls call %pathMSBuild% cd %location% msbuild.exe "lucre.sln" /p:configuration=debug pause ``` However, when I try to execute the batch file I get the following error: 'msbuild' is not recognized as an internal or external command, operable program or batch file. Any clue or help to know if it is possible and if so, how to do it will be very appreciate Regards!

Original source

Related problems