Skip to content

Commit ed57712

Browse files
tincannTomFinley
authored andcommitted
Fixes build error when path contains space on Linux (#247)
Spaces in build scripts now properly quoted.
1 parent 0233d71 commit ed57712

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
1010
done
1111
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
1212

13-
$DIR/run.sh build "$@"
13+
"$DIR/run.sh" build "$@"

init-tools.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ __DOTNET_PATH=$__TOOLRUNTIME_DIR/dotnetcli
88
__DOTNET_CMD=$__DOTNET_PATH/dotnet
99
if [ -z "$__BUILDTOOLS_SOURCE" ]; then __BUILDTOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json; fi
1010
export __BUILDTOOLS_USE_CSPROJ=true
11-
__BUILD_TOOLS_PACKAGE_VERSION=$(cat $__scriptpath/BuildToolsVersion.txt | sed 's/\r$//') # remove CR if mounted repo on Windows drive
12-
__DOTNET_TOOLS_VERSION=$(cat $__scriptpath/DotnetCLIVersion.txt | sed 's/\r$//') # remove CR if mounted repo on Windows drive
13-
__ILASM_VERSION=$(cat $__scriptpath/tools-local/ILAsmVersion.txt | sed 's/\r$//') # remove CR if mounted repo on Windows drive
11+
__BUILD_TOOLS_PACKAGE_VERSION=$(cat "$__scriptpath/BuildToolsVersion.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
12+
__DOTNET_TOOLS_VERSION=$(cat "$__scriptpath/DotnetCLIVersion.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
13+
__ILASM_VERSION=$(cat "$__scriptpath/tools-local/ILAsmVersion.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
1414
__BUILD_TOOLS_PATH=$__PACKAGES_DIR/microsoft.dotnet.buildtools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
1515
__INIT_TOOLS_RESTORE_PROJECT=$__scriptpath/init-tools.msbuild
1616
__BUILD_TOOLS_SEMAPHORE=$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/init-tools.complete
1717

18-
if [ -e $__BUILD_TOOLS_SEMAPHORE ]; then
18+
if [ -e "$__BUILD_TOOLS_SEMAPHORE" ]; then
1919
echo "Tools are already initialized"
2020
return #return instead of exit because this script is inlined in other scripts which we don't want to exit
2121
fi
2222

23-
if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi
23+
if [ -e "$__TOOLRUNTIME_DIR" ]; then rm -rf -- "$__TOOLRUNTIME_DIR"; fi
2424

2525
if [ -d "$DotNetBuildToolsDir" ]; then
2626
echo "Using tools from '$DotNetBuildToolsDir'."
@@ -36,7 +36,7 @@ if [ -d "$DotNetBuildToolsDir" ]; then
3636
return #return instead of exit because this script is inlined in other scripts which we don't want to exit
3737
fi
3838

39-
echo "Running: $__scriptpath/init-tools.sh" > $__init_tools_log
39+
echo "Running: $__scriptpath/init-tools.sh" > "$__init_tools_log"
4040

4141
display_error_message()
4242
{
@@ -65,7 +65,7 @@ execute_with_retry() {
6565
return 0
6666
}
6767

68-
if [ ! -e $__DOTNET_PATH ]; then
68+
if [ ! -e "$__DOTNET_PATH" ]; then
6969
if [ -z "$__DOTNET_PKG" ]; then
7070
if [ "$(uname -m | grep "i[3456]86")" = "i686" ]; then
7171
echo "Warning: build not supported on 32 bit Unix"
@@ -138,7 +138,7 @@ if [ ! -e $__DOTNET_PATH ]; then
138138
cd $__scriptpath
139139
fi
140140

141-
if [ ! -e $__BUILD_TOOLS_PATH ]; then
141+
if [ ! -e "$__BUILD_TOOLS_PATH" ]; then
142142
echo "Restoring BuildTools version $__BUILD_TOOLS_PACKAGE_VERSION..."
143143
echo "Running: $__DOTNET_CMD restore \"$__INIT_TOOLS_RESTORE_PROJECT\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION" >> $__init_tools_log
144144
$__DOTNET_CMD restore "$__INIT_TOOLS_RESTORE_PROJECT" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION >> $__init_tools_log

run.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
88
export DOTNET_MULTILEVEL_LOOKUP=0
99

1010
# Source the init-tools.sh script rather than execute in order to preserve ulimit values in child-processes. https://github.com/dotnet/corefx/issues/19152
11-
. $__scriptpath/init-tools.sh
11+
. "$__scriptpath/init-tools.sh"
1212

1313
__toolRuntime=$__scriptpath/Tools
1414
__dotnet=$__toolRuntime/dotnetcli/dotnet
1515

16-
cd $__scriptpath
17-
$__dotnet $__toolRuntime/run.exe $__scriptpath/config.json "$@"
16+
cd "$__scriptpath"
17+
"$__dotnet" "$__toolRuntime/run.exe" "$__scriptpath/config.json" "$@"
1818
exit $?

src/Native/build.proj

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<BuildArgs>--configuration $(Configuration) --arch $(TargetArchitecture) $(StripArgs)</BuildArgs>
3030
</PropertyGroup>
3131

32-
<Message Text="$(MSBuildProjectDirectory)\build.sh $(BuildArgs)" Importance="High"/>
33-
<Exec Command="$(MSBuildProjectDirectory)\build.sh $(BuildArgs)" />
32+
<Message Text="$(MSBuildProjectDirectory)/build.sh $(BuildArgs)" Importance="High"/>
33+
<Exec Command="&quot;$(MSBuildProjectDirectory)/build.sh&quot; $(BuildArgs)" />
3434

3535
</Target>
3636

0 commit comments

Comments
 (0)