A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Improved build pipeline for macOS
Etienne Baudouxf2bde50754a1
diff --git a/init.sh b/init.shindex 86e0a7f72..9971a652a 100644--- a/init.sh+++ b/init.sh@@ -10,8 +10,8 @@ SCRIPT_DIR="${SCRIPT_DIR}/". "./tools/Install-DotNet.sh" "$SCRIPT_DIR"# Install .NET workloads-echo "Install .NET workloads"-dotnet workload install maccatalyst+echo "Installing .NET workloads"+sudo dotnet workload install maccatalyst# Restore NuGet solution dependenciesecho "Restoring all dependencies"diff --git a/src/build/Build.cs b/src/build/Build.csindex 55347ce47..26ad012cc 100644--- a/src/build/Build.cs+++ b/src/build/Build.cs@@ -160,31 +160,32 @@ class Build : NukeBuildforeach (DotnetParameters dotnetParameters in configs){Log.Information($"Publishing {dotnetParameters.ProjectOrSolutionPath + "-" + dotnetParameters.TargetFramework + "-" + dotnetParameters.RuntimeIdentifier}...");- DotNetBuild(s => s- .SetProjectFile(dotnetParameters.ProjectOrSolutionPath)- .SetConfiguration(Configuration)- .SetFramework(dotnetParameters.TargetFramework)- .SetRuntime(dotnetParameters.RuntimeIdentifier)- .SetSelfContained(dotnetParameters.Portable)- .SetPublishSingleFile(true)- .SetPublishReadyToRun(true)- .SetPublishTrimmed(true) /* Required for MacCatalyst*/- .SetVerbosity(DotNetVerbosity.Quiet)- .SetProcessArgumentConfigurator(_ => _.Add("/p:CreatePackage=True")) /* Will create an installable .pkg */- .SetNoRestore(true)); /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */- DotNetPublish(s => s- .SetProject(dotnetParameters.ProjectOrSolutionPath)- .SetConfiguration(Configuration)- .SetFramework(dotnetParameters.TargetFramework)- .SetRuntime(dotnetParameters.RuntimeIdentifier)- .SetSelfContained(dotnetParameters.Portable)- .SetPublishSingleFile(true)- .SetPublishReadyToRun(true)- .SetPublishTrimmed(true) /* Required for MacCatalyst*/- .SetVerbosity(DotNetVerbosity.Quiet)- .SetProcessArgumentConfigurator(_ => _.Add("/p:CreatePackage=True")) /* Will create an installable .pkg */- .SetNoRestore(true) /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */- .SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));+ DotNetBuild(s => s+ .SetProjectFile(dotnetParameters.ProjectOrSolutionPath)+ .SetConfiguration(Configuration)+ //.SetFramework(dotnetParameters.TargetFramework)+ //.SetRuntime(dotnetParameters.RuntimeIdentifier)+ //.SetSelfContained(dotnetParameters.Portable)+ .SetPublishSingleFile(false) // Not supported by MacCatalyst as it would require UseAppHost to be true, which isn't supported on Mac+ .SetPublishReadyToRun(false)+ .SetPublishTrimmed(true) /* Required for MacCatalyst*/+ .SetVerbosity(DotNetVerbosity.Quiet)+ .SetNoRestore(true) /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */+ .SetProcessArgumentConfigurator(_ => _.Add("/p:CreatePackage=True")) /* Will create an installable .pkg */+ .SetOutputDirectory(RootDirectory / "publish" / dotnetParameters.OutputPath));+ // DotNetPublish(s => s+ // .SetProject(dotnetParameters.ProjectOrSolutionPath)+ // .SetConfiguration(Configuration)+ // .SetFramework(dotnetParameters.TargetFramework)+ // //.SetRuntime(dotnetParameters.RuntimeIdentifier)+ // //.SetSelfContained(dotnetParameters.Portable)+ // .SetPublishSingleFile(false) // Not supported by MacCatalyst as it would require UseAppHost to be true, which isn't supported on Mac+ // .SetPublishReadyToRun(false)+ // .SetPublishTrimmed(true) /* Required for MacCatalyst*/+ // .SetVerbosity(DotNetVerbosity.Quiet)+ // .SetProcessArgumentConfigurator(_ => _.Add("/p:CreatePackage=True")) /* Will create an installable .pkg */+ // .SetNoRestore(true) /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */+ // .SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));}}@@ -218,7 +219,6 @@ class Build : NukeBuildproject = MacSolution.GetProject(publishProject);foreach (string targetFramework in project.GetTargetFrameworks()){- // TODO: I believe that on macOS, PublishTrimmed may be mandatory?yield return new DotnetParameters(project.Path, "osx-x64", targetFramework, portable: false);yield return new DotnetParameters(project.Path, "osx-x64", targetFramework, portable: true);diff --git a/src/build/Restore/RestoreTask.cs b/src/build/Restore/RestoreTask.csindex 486cd40fa..6720637a7 100644--- a/src/build/Restore/RestoreTask.cs+++ b/src/build/Restore/RestoreTask.cs@@ -25,12 +25,12 @@ internal static class RestoreTask{System.Collections.Generic.IReadOnlyCollection<Output> results= PowerShellTasks- .PowerShell(_ => _- .SetFile(rootDirectory / "init.ps1")- .SetProcessLogOutput(true)- .SetProcessWorkingDirectory(rootDirectory)- .SetNoLogo(true)- .SetNoProfile(true));+ .PowerShell(_ => _+ .SetFile(rootDirectory / "init.ps1")+ .SetProcessLogOutput(true)+ .SetProcessWorkingDirectory(rootDirectory)+ .SetNoLogo(true)+ .SetNoProfile(true));return Task.CompletedTask;}@@ -39,7 +39,7 @@ internal static class RestoreTaskreturn Bash(rootDirectory / "init.sh");}- public static Task<int> Bash(string cmd)+ private static async Task<int> Bash(string cmd){var source = new TaskCompletionSource<int>();string escapedArgs = cmd.Replace("\"", "\\\"");@@ -48,9 +48,7 @@ internal static class RestoreTaskStartInfo = new ProcessStartInfo{FileName = "/bin/bash",- Arguments = $"-c \"sudo sh {escapedArgs}\"",- RedirectStandardOutput = true,- RedirectStandardError = true,+ Arguments = $"-c \"sh {escapedArgs}\"",UseShellExecute = false,CreateNoWindow = true},@@ -58,8 +56,6 @@ internal static class RestoreTask};process.Exited += (sender, args) =>{- Log.Warning(process.StandardError.ReadToEnd());- Log.Information(process.StandardOutput.ReadToEnd());if (process.ExitCode == 0){source.SetResult(0);@@ -75,6 +71,7 @@ internal static class RestoreTasktry{process.Start();+ await process.WaitForExitAsync();}catch (Exception e){@@ -82,6 +79,6 @@ internal static class RestoreTasksource.SetException(e);}- return source.Task;+ return await source.Task;}}