HMSBuild
.bat scripts with full Package Manager inside for searching and wrapping MSBuild tools. All Visual Studio and .NET Framework versions
Install / Use
/learn @3F/HMSBuildREADME
hMSBuild
Batch (.bat) scripts with full Package Manager inside for searching and wrapping MSBuild tools. All Visual Studio and .NET Framework versions.
Does NOT require powershell or dotnet-cli or even local vswhere.exe [?]. Powered by
Copyright (c) 2017-2025 Denis Kuzmin <x-3F@outlook.com> github/3F
gnt~hMSBuild | gnt*hMSBuild | Self updating: hMSBuild -GetNuTool ~hMSBuild/2.5
hMSBuild -only-path -no-vs -notamd64 -no-less-4
hMSBuild -debug ~x ~c Release
hMSBuild -GetNuTool "Conari;regXwild;Fnv1a128"
hMSBuild -GetNuTool vsSolutionBuildEvent/1.16.1:../SDK & SDK\GUI
hMSBuild -GetNuTool ~& svc.gnt
hMSBuild -cs -no-less-15 /t:Rebuild
Download all editions: Full, Minified, ...
Direct Links to the latest stable:
- (Windows) Latest stable compiled batch-script [ hMSBuild.bat ]
https://3F.github.io/hMSBuild/releases/latest/
Why hMSBuild
because you need easy access to msbuild tools and more...
Based on GetNuTool and back in those days it was part of it like a small msbuild-helper inside. But finally it was extracted into a new independent project after major changes from MS ecosystem with their products.
Today's hMSBuild provides the most flexible way to access and preparing msbuild tools in different environments. You just specify what you need ... and hMSBuild prepares it for you.
Key Features
- Single *.bat file, no less, no more.
- Manage all versions, including before install-API/2017+
- Visual Studio versions support: VS2026+, VS2022, VS2019, VS2017, VS2015, VS2013, VS2012, VS2010
- .NET Framework versions support: 4.0 (2010), 3.5, 2.0
- Lightweight and text-based, about ~8 KB + ~11 KB
- Does not require powershell or dotnet-cli or even local vswhere.exe [?]
- Support hot updating / custom vswhere at any request for the most modern environments.
- Provides some useful aliases.
- Full package manager inside .bat to Create or Distribute using basic shell scripts;
- Request to the server only if the package is not installed.
- Support packages.config (+extra: output, sha1 if used unsecured channels ~windows xp).
- Easy integration into any scripts such as pure batch-script netfx4sdk, DllExport
hMSBuild's algorithm
The basic process is to provide the most suitable instance by explicitly eliminating unnecessary ones.
2.0+
-
Versions:
- VS2026+, VS2022, ..., VS2017 ➟ VS2015, VS2013, ... ➟ .netfx
-
Instance Architecture (configure via
-notamd64key):- x64 ➟ x32
-
Extra restrictions via
-no-less-4(Windows XP+),-no-less-15(install-API/2017+) -
Priorities (configure via
-priority,-vc,cs,-stable, ... keys). Specific workload components in more priority than pre-release products. See Issue #8- Stable releases with selected workload components (C++ etc) ➟ Same via beta releases if allowed.
- Stable releases with any available components ➟ Same via beta releases if allowed.
Syntax
Keys to hMSBuild are optional. You can still command like it is official msbuild.exe (MSBuild Tools).
hMSBuild [keys to hMSBuild] [keys to msbuild.exe]
For example,
- The Clean target in current directory:
hmsbuild /t:Clean - Set property Configuration and minimal verbosity:
hmsbuild /p:Configuration=Debug /v:m- via hMSBuild it can also be like:
hmsbuild ~x ~c Debug
- via hMSBuild it can also be like:
In order to use package manager,
hMSBuild -GetNuTool keys to it ...
- Get latest packages:
hmsbuild -GetNuTool "Conari;regXwild;Fnv1a128" - Activate GUI script editor:
hMSBuild -GetNuTool vsSolutionBuildEvent/1.16.1:../SDK & SDK\GUI - Create new package:
hmsbuild -GetNuTool /t:pack /p:ngin=packages/Fnv1a128 - Use X mode in modern core:
hmsbuild -GetNuTool *DllExport([?]*install and run;+just install,~touch mode)
Key format -... or /...
MSBuild Tools supports both key format /... and -...; hMSBuild, in turn, can override some of -...; in this case you need to use /... for example,
- /version will be addressed to found MSBuild;
- -version will be addressed to hMSBuild;
"..."
Any value for specific key must be protected inside "..." if contains either whitespaces or delimiters like ; For example:
hmsbuild ~p "Any CPU"
LF / CRLF
Starting with 2.5, hMSBuild.bat edition now fully supports LF and uses this by default instead of CRLF.
It means .gitattributes control for CRLF in hMSBuild.bat is not necessary anymore in cases when core.autocrlf=input etc. See related: https://github.com/3F/hMSBuild/issues/2
However, this will not affect users who used the full edition hMSBuild.full.bat (related https://github.com/3F/hMSBuild/pull/11) which is still not protected due to incorrect shiftings in cmd processor when switching to LF.
-help
For the most up-to-date information, use hMSBuild -h
Copyright (c) 2017-2025 Denis Kuzmin <x-3F@outlook.com> github/3F
Copyright (c) hMSBuild contributors
Under the MIT License https://github.com/3F/hMSBuild
Syntax: hMSBuild [keys to hMSBuild] [keys to MSBuild.exe or GetNuTool]
Keys
~~~~
-no-vs - Disable searching from Visual Studio.
-no-netfx - Disable searching from .NET Framework.
-no-vswhere - Do not search via vswhere.
-no-less-15 - Do not include versions less than 15.0 (install-API/2017+)
-no-less-4 - Do not include versions less than 4.0 (Windows XP+)
-priority {IDs} - 15+ Non-strict components preference: C++ etc.
Separated by space "a b c" https://aka.ms/vs/workloads
-vswhere {v}
* 2.6.7 ...
* latest - To get latest remote vswhere.exe
* local - To use only local
(.bat;.exe /or from +15.2.26418.1 VS-build)
-no-cache - Do not cache vswhere for this request.
-reset-cache - To reset all cached vswhere versions before processing.
-cs - Adds to -priority C# / VB Roslyn compilers.
-vc - Adds to -priority VC++ toolset.
~c {name} - Alias to p:Configuration={name}
~p {name} - Alias to p:Platform={name}
~x - Alias to m:NUMBER_OF_PROCESSORS-1 v:m
-notamd64 - Prefer 32-bit instead of 64-bit MSBuild.exe.
-stable - It will ignore possible beta releases in last attempts.
-eng - Try to use english language for all build messages.
-GetNuTool {args} - Access to GetNuTool (built-in) https://github.com/3F/GetNuTool
hMSBuild -GetNuTool -help
hMSBuild -GetNuTool ~/p:use=documentation
-only-path - Only display fullpath to found MSBuild.
-force - Aggressive behavior for -priority, -notamd64, etc.
-vsw-as "args..." - Reassign default commands to vswhere if used.
-debug - To show additional information from hMSBuild
-version - Display version of hMSBuild.
-help - Display this help. Aliases: -? -h
Integration with scripts
batch (.bat, .cmd)
hMSBuild is a pure batch script. Therefore, you can easily combine this even inside other batch scripts. Or invoke this externally, there's nothing special:
set msbuild=hMSBuild -notamd64 ~c Release
...
%msbuild% Conari.sln /t:Rebuild
for /F "tokens=*" %%i in ('hMSBuild -only-path -notamd64') do set msbuild="%%i"
...
%msbuild% /version
hmsbuild -cs -no-less-15 ~c Debug ~x || goto fallback
More actual examples can be found in tests/ folder.
Note: for some cases, if you know what you're doing, you can also configure __p_call flag to eliminate the difference for the call-type invoking hMSBuild.bat
set __p_call=1
API
2.5+
:: initialize arguments
:inita {in:vname} {in:arguments} {out:index}
:: (1) - Input variable name.
:: &(2) - Input arguments via a variable.
:: *&(3) - Returns the reached index (maximum) via a variable.
:: !!0
:: evaluate argument
:eva {in:unevaluated} {out:evaluated} {in:option}
:: &(1) - Input via a variable. Use ` to apply " quotes inside "..." if [3]==1.
:: *&(2) - Evaluated output via a variable.
:: [3] - Option to enable support for extra quotes. Values: 1 == ` as "
:: !!0
Usage for example, DllExport.bat:
:: process arguments through hMSBuild
call :inita arg esc amax
...
set key=!arg[%idx%]!
...
:continue
set /a "idx+=1" & if

