Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@AllenSanborn has a great powershell version, but some folks have a requirement to use only batch scripts for builds.</p> <p>This is an applied version of what @bono8106 answered.</p> <p>msbuildpath.bat</p> <pre><code>@echo off reg.exe query "HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath &gt; nul 2&gt;&amp;1 if ERRORLEVEL 1 goto MissingMSBuildRegistry for /f "skip=2 tokens=2,*" %%A in ('reg.exe query "HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath') do SET "MSBUILDDIR=%%B" IF NOT EXIST "%MSBUILDDIR%" goto MissingMSBuildToolsPath IF NOT EXIST "%MSBUILDDIR%msbuild.exe" goto MissingMSBuildExe exit /b 0 goto:eof ::ERRORS ::--------------------- :MissingMSBuildRegistry echo Cannot obtain path to MSBuild tools from registry goto:eof :MissingMSBuildToolsPath echo The MSBuild tools path from the registry '%MSBUILDDIR%' does not exist goto:eof :MissingMSBuildExe echo The MSBuild executable could not be found at '%MSBUILDDIR%' goto:eof </code></pre> <p>build.bat</p> <pre><code>@echo off call msbuildpath.bat "%MSBUILDDIR%msbuild.exe" foo.csproj /p:Configuration=Release </code></pre> <p>For Visual Studio 2017 / MSBuild 15, Aziz Atif (the guy who wrote <a href="https://elmah.github.io/" rel="nofollow noreferrer">Elmah</a>) wrote a batch script</p> <pre><code>build.cmd Release Foo.csproj </code></pre> <p><a href="https://github.com/linqpadless/LinqPadless/blob/master/build.cmd" rel="nofollow noreferrer">https://github.com/linqpadless/LinqPadless/blob/master/build.cmd</a></p> <pre><code>@echo off setlocal if "%PROCESSOR_ARCHITECTURE%"=="x86" set PROGRAMS=%ProgramFiles% if defined ProgramFiles(x86) set PROGRAMS=%ProgramFiles(x86)% for %%e in (Community Professional Enterprise) do ( if exist "%PROGRAMS%\Microsoft Visual Studio\2017\%%e\MSBuild\15.0\Bin\MSBuild.exe" ( set "MSBUILD=%PROGRAMS%\Microsoft Visual Studio\2017\%%e\MSBuild\15.0\Bin\MSBuild.exe" ) ) if exist "%MSBUILD%" goto :restore set MSBUILD= for %%i in (MSBuild.exe) do set MSBUILD=%%~dpnx$PATH:i if not defined MSBUILD goto :nomsbuild set MSBUILD_VERSION_MAJOR= set MSBUILD_VERSION_MINOR= for /f "delims=. tokens=1,2,3,4" %%m in ('msbuild /version /nologo') do ( set MSBUILD_VERSION_MAJOR=%%m set MSBUILD_VERSION_MINOR=%%n ) if not defined MSBUILD_VERSION_MAJOR goto :nomsbuild if not defined MSBUILD_VERSION_MINOR goto :nomsbuild if %MSBUILD_VERSION_MAJOR% lss 15 goto :nomsbuild if %MSBUILD_VERSION_MINOR% lss 1 goto :nomsbuild :restore for %%i in (NuGet.exe) do set nuget=%%~dpnx$PATH:i if "%nuget%"=="" ( echo WARNING! NuGet executable not found in PATH so build may fail! echo For more on NuGet, see https://github.com/nuget/home ) pushd "%~dp0" nuget restore ^ &amp;&amp; call :build Debug %* ^ &amp;&amp; call :build Release %* popd goto :EOF :build setlocal "%MSBUILD%" /p:Configuration=%1 /v:m %2 %3 %4 %5 %6 %7 %8 %9 goto :EOF :nomsbuild echo Microsoft Build version 15.1 (or later) does not appear to be echo installed on this machine, which is required to build the solution. exit /b 1 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload