@@ -27,17 +27,20 @@ let PASCALCASE_NAME = "GWallet"
2727
2828let XF_FRONTEND_LIB = sprintf " %s .Frontend.XF" PASCALCASE_ NAME
2929let GTK_FRONTEND_APP = sprintf " %s .Frontend.XF.Gtk" PASCALCASE_ NAME
30+ let MAUI_FRONTEND_APP = sprintf " %s .Frontend.Maui" PASCALCASE_ NAME
3031let CONSOLE_FRONTEND_APP = sprintf " %s .Frontend.ConsoleApp" PASCALCASE_ NAME
3132let BACKEND_LIB = sprintf " %s .Backend" PASCALCASE_ NAME
3233
3334type FrontendProject =
3435 | XF
3536 | Gtk
37+ | Maui
3638 member self.GetProjectFile (): FileInfo =
3739 let projName =
3840 match self with
3941 | Gtk -> GTK_ FRONTEND_ APP
4042 | XF -> XF_ FRONTEND_ LIB
43+ | Maui -> MAUI_ FRONTEND_ APP
4144
4245 let prjFile =
4346 let projFileName = sprintf " %s .fsproj" projName
@@ -201,6 +204,11 @@ let BuildSolutionOrProject
201204 Seq.append [ " LEGACY_FRAMEWORK" ] defineConstantsFromBuildConfig
202205 else
203206 defineConstantsFromBuildConfig
207+ let defineConstantsSoFar =
208+ if not ( file.FullName.EndsWith " maui.sln" ) then
209+ Seq.append [ " XAMARIN" ] defineConstantsSoFar
210+ else
211+ defineConstantsSoFar
204212 let allDefineConstants =
205213 match maybeConstant with
206214 | Some constant -> Seq.append [ constant] defineConstantsSoFar
@@ -249,6 +257,55 @@ let BuildSolutionOrProject
249257 Environment.Exit 1
250258 | _ -> ()
251259
260+ // TODO: we have to change this function to be the other way around (i.e. copy from Maui to XF) once we
261+ // have a finished version of Maui and we consider XF as legacy.
262+ let CopyXamlFiles () =
263+ let files = [| " WelcomePage.xaml" |]
264+ for file in files do
265+ let sourcePath = Path.Combine( " src" , " GWallet.Frontend.XF" , file)
266+ let destPath = Path.Combine( " src" , " GWallet.Frontend.Maui" , file)
267+
268+ File.Copy( sourcePath, destPath, true )
269+ let fileText = File.ReadAllText( destPath)
270+ File.WriteAllText(
271+ destPath,
272+ fileText
273+ .Replace( " http://xamarin.com/schemas/2014/forms" , " http://schemas.microsoft.com/dotnet/2021/maui" )
274+ .Replace( " GWallet.Frontend.XF" , " GWallet.Frontend.Maui" )
275+ )
276+
277+
278+
279+ let DotNetBuild
280+ ( solutionProjectFileName : string )
281+ ( binaryConfig : BinaryConfig )
282+ ( args : string )
283+ ( ignoreError : bool )
284+ =
285+ let configOption = sprintf " -c %s " ( binaryConfig.ToString())
286+ let buildArgs = ( sprintf " build %s %s %s " configOption solutionProjectFileName args)
287+ let buildProcess = Process.Execute ({ Command = " dotnet" ; Arguments = buildArgs }, Echo.All)
288+ match buildProcess.Result with
289+ | Error _ ->
290+ if not ignoreError then
291+ Console.WriteLine()
292+ Console.Error.WriteLine " dotnet build failed"
293+ #if LEGACY_ FRAMEWORK
294+ PrintNugetVersion() |> ignore
295+ #endif
296+ Environment.Exit 1
297+ else
298+ ()
299+ | _ -> ()
300+
301+ // We have to build Maui project for android twice because the first time we get
302+ // an error about Resource file not found. The second time it works.
303+ // https://github.com/fabulous-dev/FSharp.Mobile.Templates/tree/55a1f3a0fd5cc397e48677ef4ff9241b360b0e84
304+ let BuildMauiProject binaryConfig =
305+ let mauiProjectFilePath = FrontendProject.Maui.GetProjectFile() .FullName
306+ DotNetBuild mauiProjectFilePath binaryConfig " --framework net6.0-android" true
307+ DotNetBuild mauiProjectFilePath binaryConfig " --framework net6.0-android" false
308+
252309let JustBuild binaryConfig maybeConstant : FrontendApp * FileInfo =
253310 let maybeBuildTool = Map.tryFind " BuildTool" buildConfigContents
254311 let maybeLegacyBuildTool = Map.tryFind " LegacyBuildTool" buildConfigContents
@@ -312,6 +369,7 @@ let JustBuild binaryConfig maybeConstant: FrontendApp*FileInfo =
312369 // somehow, msbuild doesn't restore the frontend dependencies (e.g. Xamarin.Forms) when targetting
313370 // the {LINUX|MAC}_SOLUTION_FILE below, so we need this workaround. TODO: just finish migrating to MAUI(dotnet restore)
314371 NugetRestore solution
372+ CopyXamlFiles()
315373 MSBuildRestoreAndBuild solution
316374
317375 FrontendApp.Console
0 commit comments