Skip to content

Commit d09ff6c

Browse files
committed
Enable Windows builds on Linux and Mac
1 parent 1dc0d57 commit d09ff6c

File tree

6 files changed

+149
-158
lines changed

6 files changed

+149
-158
lines changed

CHANGELIST.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- Retrieve serial from Cleanrip
2929
- Fix build from rushed code
3030
- Remove `-disc2` from Cleanrip serial
31+
- Enable Windows builds on Linux and Mac
3132

3233
### 3.0.3 (2023-12-04)
3334

MPF.UI.Core/MPF.UI.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetFrameworks>net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
66
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
77
<CheckEolTargetFramework>false</CheckEolTargetFramework>
8+
<EnableWindowsTargeting>true</EnableWindowsTargeting>
89
<ImportFrameworkWinFXTargets Condition="$(TargetFramework.StartsWith(`net3`))">true</ImportFrameworkWinFXTargets>
910
<LangVersion>latest</LangVersion>
1011
<Nullable>enable</Nullable>

MPF/MPF.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<OutputType>WinExe</OutputType>
88
<ApplicationIcon>Images\Icon.ico</ApplicationIcon>
99
<CheckEolTargetFramework>false</CheckEolTargetFramework>
10+
<EnableWindowsTargeting>true</EnableWindowsTargeting>
1011
<ImportFrameworkWinFXTargets Condition="$(TargetFramework.StartsWith(`net3`))">true</ImportFrameworkWinFXTargets>
1112
<LangVersion>latest</LangVersion>
1213
<Nullable>enable</Nullable>

publish-nix.sh

Lines changed: 142 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,83 +10,160 @@
1010
# If any of these are not satisfied, the operation may fail
1111
# in an unpredictable way and result in an incomplete output.
1212

13-
# TODO: Re-enable MPF building after figuring out how to build Windows desktop applications on Linux
14-
# This may require an additional package to be installed?
13+
# Optional parameters
14+
USE_ALL=false
15+
INCLUDE_PROGRAMS=false # TODO: Figure out how to exclude folders with `zip`
16+
NO_BUILD=false
17+
NO_ARCHIVE=false
18+
while getopts "upba" OPTION
19+
do
20+
case $OPTION in
21+
u)
22+
USE_ALL=true
23+
;;
24+
p)
25+
INCLUDE_PROGRAMS=true
26+
;;
27+
b)
28+
NO_BUILD=true
29+
;;
30+
a)
31+
NO_ARCHIVE=true
32+
;;
33+
*)
34+
echo "Invalid option provided"
35+
exit 1
36+
;;
37+
esac
38+
done
1539

1640
# Set the current directory as a variable
1741
BUILD_FOLDER=$PWD
1842

1943
# Set the current commit hash
2044
COMMIT=`git log --pretty=%H -1`
2145

22-
# Restore Nuget packages for all builds
23-
echo "Restoring Nuget packages"
24-
dotnet restore
46+
# Create the build matrix arrays
47+
UI_FRAMEWORKS=("net6.0-windows" "net8.0-windows")
48+
UI_RUNTIMES=("win-x64")
49+
CHECK_FRAMEWORKS=("net6.0" "net8.0")
50+
CHECK_RUNTIMES=("win-x64" "linux-x64" "osx-x64")
2551

26-
# .NET 6.0 Debug
27-
echo "Building .NET 6.0 debug"
28-
#dotnet publish MPF/MPF.csproj -f net6.0-windows -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
29-
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
30-
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r linux-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
31-
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r osx-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
52+
# Use expanded lists, if requested
53+
if [ $USE_ALL = true ]
54+
then
55+
UI_FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0-windows" "net6.0-windows" "net7.0-windows" "net8.0-windows")
56+
UI_RUNTIMES=("win-x86" "win-x64")
57+
CHECK_FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
58+
CHECK_RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64")
59+
fi
3260

33-
# .NET 6.0 Release
34-
echo "Building .NET 6.0 release"
35-
#dotnet publish MPF/MPF.csproj -f net6.0-windows -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
36-
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
37-
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
38-
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
61+
# Create the filter arrays
62+
SINGLE_FILE_CAPABLE=("net5.0" "net5.0-windows" "net6.0" "net6.0-windows" "net7.0" "net7.0-windows" "net8.0" "net8.0-windows")
63+
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
64+
VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64")
3965

40-
# .NET 8.0 Debug
41-
echo "Building .NET 8.0 debug"
42-
#dotnet publish MPF/MPF.csproj -f net8.0-windows -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
43-
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
44-
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
45-
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
66+
# Only build if requested
67+
if [ $NO_BUILD = false ]
68+
then
69+
# Restore Nuget packages for all builds
70+
echo "Restoring Nuget packages"
71+
dotnet restore
4672

47-
# .NET 8.0 Release
48-
echo "Building .NET 8.0 release"
49-
#dotnet publish MPF/MPF.csproj -f net8.0-windows -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
50-
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
51-
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
52-
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
73+
# Build UI
74+
for FRAMEWORK in "${UI_FRAMEWORKS[@]}"
75+
do
76+
for RUNTIME in "${UI_RUNTIMES[@]}"
77+
do
78+
# Only .NET 5 and above can publish to a single file
79+
if [[ $(echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK) ]]
80+
then
81+
dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
82+
dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
83+
else
84+
dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
85+
dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
86+
fi
87+
done
88+
done
5389

54-
# Create MPF Debug archives
55-
#cd $BUILD_FOLDER/MPF/bin/Debug/net6.0-windows/win-x64/publish/
56-
#zip -r $BUILD_FOLDER/MPF_net6.0_win-x64_debug.zip .
57-
#cd $BUILD_FOLDER/MPF/bin/Debug/net8.0-windows/win-x64/publish/
58-
#zip -r $BUILD_FOLDER/MPF_net8.0_win-x64_debug.zip .
90+
# Build Check
91+
for FRAMEWORK in "${CHECK_FRAMEWORKS[@]}"
92+
do
93+
for RUNTIME in "${CHECK_RUNTIMES[@]}"
94+
do
95+
# If we have an invalid combination of framework and runtime
96+
if [[ ! $(echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ]]
97+
then
98+
if [[ $(echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME) ]]
99+
then
100+
continue
101+
fi
102+
fi
59103

60-
# Create MPF Release archives
61-
#cd $BUILD_FOLDER/MPF/bin/Release/net6.0-windows/win-x64/publish/
62-
#zip -r $BUILD_FOLDER/MPF_net6.0_win-x64_release.zip .
63-
#cd $BUILD_FOLDER/MPF/bin/Release/net8.0-windows/win-x64/publish/
64-
#zip -r $BUILD_FOLDER/MPF_net8.0_win-x64_release.zip .
104+
# Only .NET 5 and above can publish to a single file
105+
if [[ $(echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK) ]]
106+
then
107+
dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
108+
dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
109+
else
110+
dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
111+
dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
112+
fi
113+
done
114+
done
115+
fi
65116

66-
# Create MPF.Check Debug archives
67-
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net6.0/win-x64/publish/
68-
zip -r $BUILD_FOLDER/MPF.Check_net6.0_win-x64_debug.zip .
69-
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net6.0/linux-x64/publish/
70-
zip -r $BUILD_FOLDER/MPF.Check_net6.0_linux-x64_debug.zip .
71-
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net6.0/osx-x64/publish/
72-
zip -r $BUILD_FOLDER/MPF.Check_net6.0_osx-x64_debug.zip .
73-
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net8.0/win-x64/publish/
74-
zip -r $BUILD_FOLDER/MPF.Check_net8.0_win-x64_debug.zip .
75-
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net8.0/linux-x64/publish/
76-
zip -r $BUILD_FOLDER/MPF.Check_net8.0_linux-x64_debug.zip .
77-
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net8.0/osx-x64/publish/
78-
zip -r $BUILD_FOLDER/MPF.Check_net8.0_osx-x64_debug.zip .
117+
# Only create archives if requested
118+
if [ $NO_ARCHIVE = false ]
119+
then
120+
# Create UI archives
121+
for FRAMEWORK in "${UI_FRAMEWORKS[@]}"
122+
do
123+
echo "Framework: $FRAMEWORK"
124+
for RUNTIME in "${UI_RUNTIMES[@]}"
125+
do
126+
echo "Runtime: $RUNTIME"
127+
cd $BUILD_FOLDER/MPF/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/
128+
echo "PWD: $PWD"
129+
if [ $INCLUDE_PROGRAMS = true ]
130+
then
131+
zip -r $BUILD_FOLDER/MPF_${FRAMEWORK}_${RUNTIME}_debug.zip .
132+
else
133+
zip -r $BUILD_FOLDER/MPF_${FRAMEWORK}_${RUNTIME}_debug.zip . -x 'Programs/\*'
134+
fi
135+
cd $BUILD_FOLDER/MPF/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/
136+
echo "PWD: $PWD"
137+
if [ $INCLUDE_PROGRAMS = true ]
138+
then
139+
zip -r $BUILD_FOLDER/MPF_${FRAMEWORK}_${RUNTIME}_release.zip .
140+
else
141+
zip -r $BUILD_FOLDER/MPF_${FRAMEWORK}_${RUNTIME}_release.zip . -x 'Programs/\*'
142+
fi
143+
done
144+
done
79145

80-
# Create MPF.Check Release archives
81-
cd $BUILD_FOLDER/MPF.Check/bin/Release/net6.0/win-x64/publish/
82-
zip -r $BUILD_FOLDER/MPF.Check_net6.0_win-x64_release.zip .
83-
cd $BUILD_FOLDER/MPF.Check/bin/Release/net6.0/linux-x64/publish/
84-
zip -r $BUILD_FOLDER/MPF.Check_net6.0_linux-x64_release.zip .
85-
cd $BUILD_FOLDER/MPF.Check/bin/Release/net6.0/osx-x64/publish/
86-
zip -r $BUILD_FOLDER/MPF.Check_net6.0_osx-x64_release.zip .
87-
cd $BUILD_FOLDER/MPF.Check/bin/Release/net8.0/win-x64/publish/
88-
zip -r $BUILD_FOLDER/MPF.Check_net8.0_win-x64_release.zip .
89-
cd $BUILD_FOLDER/MPF.Check/bin/Release/net8.0/linux-x64/publish/
90-
zip -r $BUILD_FOLDER/MPF.Check_net8.0_linux-x64_release.zip .
91-
cd $BUILD_FOLDER/MPF.Check/bin/Release/net8.0/osx-x64/publish/
92-
zip -r $BUILD_FOLDER/MPF.Check_net8.0_osx-x64_release.zip .
146+
# Create Check archives
147+
for FRAMEWORK in "${CHECK_FRAMEWORKS[@]}"
148+
do
149+
for RUNTIME in "${CHECK_RUNTIMES[@]}"
150+
do
151+
# If we have an invalid combination of framework and runtime
152+
if [[ ! $(echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ]]
153+
then
154+
if [[ $(echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME) ]]
155+
then
156+
continue
157+
fi
158+
fi
159+
160+
cd $BUILD_FOLDER/MPF.Check/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/
161+
zip -r $BUILD_FOLDER/MPF.Check_${FRAMEWORK}_${RUNTIME}_debug.zip .
162+
cd $BUILD_FOLDER/MPF.Check/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/
163+
zip -r $BUILD_FOLDER/MPF.Check_${FRAMEWORK}_${RUNTIME}_release.zip .
164+
done
165+
done
166+
167+
# Reset the directory
168+
cd $BUILD_FOLDER
169+
fi

publish-win.bat

Lines changed: 0 additions & 89 deletions
This file was deleted.

publish-win.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if (!$NO_ARCHIVE.IsPresent)
113113
{
114114
foreach ($RUNTIME in $UI_RUNTIMES)
115115
{
116-
Set-Location -Path $BUILD_FOLDER\MPF\bin\Debug\$FRAMEWORK\$RUNTIME\publish\
116+
Set-Location -Path $BUILD_FOLDER\MPF\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\
117117
if ($INCLUDE_PROGRAMS.IsPresent)
118118
{
119119
7z a -tzip $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_debug.zip *
@@ -122,7 +122,7 @@ if (!$NO_ARCHIVE.IsPresent)
122122
{
123123
7z a -tzip -x!Programs\* $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_debug.zip *
124124
}
125-
Set-Location -Path $BUILD_FOLDER\MPF\bin\Release\$FRAMEWORK\$RUNTIME\publish\
125+
Set-Location -Path $BUILD_FOLDER\MPF\bin\Release\${FRAMEWORK}\${RUNTIME}\publish\
126126
if ($INCLUDE_PROGRAMS.IsPresent)
127127
{
128128
7z a -tzip $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_release.zip *
@@ -145,9 +145,9 @@ if (!$NO_ARCHIVE.IsPresent)
145145
continue
146146
}
147147

148-
Set-Location -Path $BUILD_FOLDER\MPF.Check\bin\Debug\$FRAMEWORK\$RUNTIME\publish\
148+
Set-Location -Path $BUILD_FOLDER\MPF.Check\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\
149149
7z a -tzip $BUILD_FOLDER\MPF.Check_${FRAMEWORK}_${RUNTIME}_debug.zip *
150-
Set-Location -Path $BUILD_FOLDER\MPF.Check\bin\Release\$FRAMEWORK\${RUNTIME}\publish\
150+
Set-Location -Path $BUILD_FOLDER\MPF.Check\bin\Release\${FRAMEWORK}\${RUNTIME}\publish\
151151
7z a -tzip $BUILD_FOLDER\MPF.Check_${FRAMEWORK}_${RUNTIME}_release.zip *
152152
}
153153
}

0 commit comments

Comments
 (0)