Tuesday, October 22, 2019

Simple build script that works in Windows and Linux


Have two development environments:

MacOS, Visual Studio Professional for Mac, .NET Core 3.0

Windows 10, Visual Studio Professional for Windows, .NET Core 3.0

Need to write a script that will be working on Windows (.bat file) and MacOS (bash). 

For example sake, scripting languages or msbuild conditions should not be used.


Never thought that it's possible, definitely not an option for complex scenarios, but for basic commands go following (assuming that script build_webpack.cmd).

echo off

NODE=`which node`
cd "$(dirname "$0")/.."
$NODE ./node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js $@

goto $@

SET mypath=%~dp0
CD "%mypath:~0,-1%\\.."
node node_modules\\webpack\\bin\\webpack.js --config webpack.config.vendor.js %*

Now, if we need to invoke this script during project build, add the following line:

    <Exec Command="ClientApp/scripts/build_webpack.cmd --env.dev" />

No comments:

Post a Comment