Pre-Build Script Path windows builders

Hi,

Is the “Pre-Build Script Path” option supported on windows builders? If yes can we just use standard sh scripts or do we need to use powershell?

I would like to use the following script on a windows runner:

#!/bin/bash
echo "[npmAuth.\"https://npm.pkg.github.com/@...\"]" >> %USERPROFILE%\.upmconfig.toml
echo "token = \"$NPM_TOKEN\"" >> %USERPROFILE%\.upmconfig.toml
echo "alwaysAuth = true" >> %USERPROFILE%\.upmconfig.toml

Would I use “%USERPROFILE%” for the user folder or do I have to use a different env variable / style?

Thanks for any hints and help.

echo "[npmAuth.\"https://url/\"]\ntoken = \"...c=\"\nalwaysAuth = true" > $HOME/.upmconfig.toml
It used to work this way. Unfortunately I don’t think this work anymore with Windows Builder.

The %USERPROFILE% does not seem to be the correct variable to use. The pre build script return this :

BUILD_PATH/p/Scripts/pre_build.sh: line 1: %USERPROFILE%/.upmconfig.toml: No such file or directory

With the help from Unity Support, I was able to write a script that works on both Windows Builders and Mac OS Builders.

token=yourtokenhere
path=$USERPROFILE/.upmconfig.toml

unameOut="$(uname -s)"
case "${unameOut}" in
    Darwin*)    path=$HOME/.upmconfig.toml;;
esac

echo ${path}

echo "[npmAuth.\"https://yoururlhere/\"]" > ${path}
echo "token =\"${token}\"" >> ${path}
echo "alwaysAuth = true" >> ${path}

The unameOut cases can be :

  • CYGWIN, for Windows
  • Darwin, for Mac OS
  • Linux, for Linux
1 Like