-
Notifications
You must be signed in to change notification settings - Fork 3
/
generateWixToolsetFragment.sh
96 lines (81 loc) · 2.85 KB
/
generateWixToolsetFragment.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/bash
BASEDIR=$(dirname $0)
. "$BASEDIR/_variables.sh"
targetDir="$BASEDIR/data/wix-dotnet"
mkdir -p "$targetDir"
for runtime in ${runtimes[*]}; do
case $runtime in
runtime-aspnetcore)
runtimetype="aspnet"
runtimename="ASP.NET Core"
runtimeid="ASP_NET"
;;
runtime-desktop)
runtimetype="desktop"
runtimename="Desktop Runtime"
runtimeid="DesktopRuntime"
;;
runtime)
runtimetype="core"
runtimename="Runtime"
runtimeid="Runtime"
;;
esac
sourcefilename="$BASEDIR/data/data/dotnet-$runtime.json"
echo "Parse JSON-Data $sourcefilename ..."
items=$(cat "$sourcefilename" | jq -c -r '.[]')
for item in ${items[@]}; do
echo "Parse $item ..."
platform=$((echo $item) | jq -r '.platform')
version=$((echo $item) | jq -r '.version')
os=$((echo $item) | jq -r '.os')
link=$((echo $item) | jq -r '.link')
hash=$((echo $item) | jq -r '.hash')
bytes=$((echo $item) | jq -r '.bytes')
if [[ $os == *"macos"* ]]; then
echo "MacOS is not supported, entry will be skiped"
continue
fi
major=$((echo $version) | grep -Eo '^[0-9]+')
major_minor=$((echo $version) | grep -Eo '^[0-9]+.[0-9]+')
version_encoded=$((echo $version) | sed 's#[.]#_#g')
# echo $major
# echo $major_minor
# echo $version_encoded
template=$(
cat << HEREDOC
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:netfx="http://wixtoolset.org/schemas/v4/wxs/netfx"
xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Fragment>
<netfx:DotNetCoreSearch
RuntimeType="${runtimetype}"
Platform="${platform}"
MajorVersion="${major}"
Variable="DOT_NET_VER" />
<PackageGroup Id="DotNet_${runtimeid}_v${version_encoded}_${platform}">
<ExePackage Id="Netfx${major}0"
DisplayName="Microsoft .NET ${major_minor} ${runtimename}"
Description="Microsoft .NET ${major_minor} (${version}) ${runtimename} for ${os} ${platform}"
PerMachine="yes" Permanent="yes" Vital="yes" InstallArguments="/norestart /quiet"
DetectCondition="DOT_NET_VER >= v${version}"
bal:PrereqPackage="yes">
<ExePackagePayload
Name="${runtime}-${version}-${os}-${platform}.exe"
DownloadUrl="${link}"
Hash="${hash}"
Size="${bytes}" />
<ExitCode Value="0" Behavior="success" />
<ExitCode Behavior="scheduleReboot" />
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
HEREDOC
)
targetfile="$targetDir/DotNet_${runtimeid}_v${version}_${platform}.wxs"
echo "$template" > "$targetfile"
echo "$targetfile written sucessfully."
done
echo "... done"
done