diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..a4035365b0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: ci + +on: [push] + +jobs: + windows-latest: + name: windows-latest + runs-on: windows-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: 'Cache: .nuke/temp, ~/.nuget/packages' + uses: actions/cache@v3 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} + - name: 'Restore, Build and Test' + run: ./build.cmd RunTests + ubuntu-latest: + name: ubuntu-latest + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: 'Cache: .nuke/temp, ~/.nuget/packages' + uses: actions/cache@v3 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} + - name: 'Restore, Build and Test' + run: ./build.cmd RunTests + macos-latest: + name: macos-14 + runs-on: macos-14 + timeout-minutes: 30 + steps: + - name: Set to use Xcode 15.1 + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.1' + - uses: actions/checkout@v3 + - name: 'Cache: .nuke/temp, ~/.nuget/packages' + uses: actions/cache@v3 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} + - name: 'Restore, Build and Test' + run: ./build.cmd RunTests diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index b11ef725aa..46b10a48b5 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -8,7 +8,7 @@ "properties": { "Configuration": { "type": "string", - "description": "Configuration to build - Default is 'Release'", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", "enum": [ "Debug", "Release" @@ -63,20 +63,6 @@ "type": "boolean", "description": "Shows the execution plan (HTML)" }, - "PlatformTargets": { - "type": "array", - "description": "The target platform", - "items": { - "type": "string", - "enum": [ - "CLI", - "Linux", - "MacOS", - "Wasm", - "Windows" - ] - } - }, "Profile": { "type": "array", "description": "Defines the profiles to load", @@ -88,25 +74,20 @@ "type": "string", "description": "Root directory during build execution" }, - "RunTests": { - "type": "boolean", - "description": "Runs unit tests" - }, "Skip": { "type": "array", "description": "List of targets to be skipped. Empty list skips all dependencies", "items": { "type": "string", "enum": [ - "BuildGenerators", - "BuildPlugins", "Clean", + "Compile", + "CompileGenerators", "GenerateSdkNuGet", - "PreliminaryCheck", "PublishApp", "Restore", - "SetVersion", - "UnitTests" + "RunTests", + "SetVersion" ] } }, @@ -116,15 +97,14 @@ "items": { "type": "string", "enum": [ - "BuildGenerators", - "BuildPlugins", "Clean", + "Compile", + "CompileGenerators", "GenerateSdkNuGet", - "PreliminaryCheck", "PublishApp", "Restore", - "SetVersion", - "UnitTests" + "RunTests", + "SetVersion" ] } }, diff --git a/build.cmd b/build.cmd old mode 100644 new mode 100755 diff --git a/build.ps1 b/build.ps1 old mode 100644 new mode 100755 diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/init.cmd b/init.cmd old mode 100644 new mode 100755 diff --git a/init.ps1 b/init.ps1 old mode 100644 new mode 100755 diff --git a/init.sh b/init.sh old mode 100644 new mode 100755 diff --git a/src/Build.sln b/src/Build.sln new file mode 100644 index 0000000000..6d8aebc3a7 --- /dev/null +++ b/src/Build.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34607.119 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{31D5C875-27D6-460B-AD34-7CCD984A69DD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {31D5C875-27D6-460B-AD34-7CCD984A69DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31D5C875-27D6-460B-AD34-7CCD984A69DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31D5C875-27D6-460B-AD34-7CCD984A69DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31D5C875-27D6-460B-AD34-7CCD984A69DD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5D3E4460-FF5C-4D38-BBE5-8A51D08F2C29} + EndGlobalSection +EndGlobal diff --git a/src/DevToys-Linux.sln b/src/DevToys-Linux.sln index 4679412858..a5776d44de 100644 --- a/src/DevToys-Linux.sln +++ b/src/DevToys-Linux.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33122.133 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{0AC87D9B-BBEC-4DCE-A9D4-82A159E5E7C1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{C85D2D7C-3D69-482A-8AB6-BCA934220EC0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{B20E4027-0777-4A75-A848-609594E9A6B0}" @@ -43,8 +41,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "desktops", "desktops", "{22 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.CLI", "app\dev\platforms\desktop\DevToys.CLI\DevToys.CLI.csproj", "{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.Api", "app\dev\DevToys.Api\DevToys.Api.csproj", "{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.UnitTests", "app\tests\DevToys.UnitTests\DevToys.UnitTests.csproj", "{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}" @@ -98,22 +94,6 @@ Global {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x64.Build.0 = Release|AnyCPU {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x86.ActiveCfg = Release|AnyCPU {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x86.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|ARM64.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|ARM64.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x64.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x64.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x86.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x86.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|ARM64.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|ARM64.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x64.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x64.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x86.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x86.Build.0 = Release|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.Build.0 = Debug|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|ARM64.ActiveCfg = Debug|AnyCPU @@ -253,7 +233,6 @@ Global {9771D1F8-D331-4B26-8E96-6024893009F4} = {B20E4027-0777-4A75-A848-609594E9A6B0} {22EE9386-CEFA-47D8-97B2-09A63EDF7F2E} = {3D2285D5-0E44-4B1A-9B74-2BBE3108D5B7} {8C72D38A-658D-4C9D-B0AD-2DA975BE7826} = {22EE9386-CEFA-47D8-97B2-09A63EDF7F2E} - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4} = {0AC87D9B-BBEC-4DCE-A9D4-82A159E5E7C1} {89A4D88F-5AC0-436A-8EC5-8E98728CA89E} = {B20E4027-0777-4A75-A848-609594E9A6B0} {CCAB7530-4341-4C24-B4E8-28679BB6C4FB} = {4C40BF47-315A-4B60-9ED6-8D65B5E79C2C} {A730FA8A-3713-4F7A-915D-79098CA12DF0} = {B20E4027-0777-4A75-A848-609594E9A6B0} diff --git a/src/DevToys-MacOS.sln b/src/DevToys-MacOS.sln index a0bf8d07be..7eeb37c9b6 100644 --- a/src/DevToys-MacOS.sln +++ b/src/DevToys-MacOS.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33122.133 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{0AC87D9B-BBEC-4DCE-A9D4-82A159E5E7C1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{C85D2D7C-3D69-482A-8AB6-BCA934220EC0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{B20E4027-0777-4A75-A848-609594E9A6B0}" @@ -42,8 +40,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "desktops", "desktops", "{22 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.CLI", "app\dev\platforms\desktop\DevToys.CLI\DevToys.CLI.csproj", "{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.Api", "app\dev\DevToys.Api\DevToys.Api.csproj", "{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.UnitTests", "app\tests\DevToys.UnitTests\DevToys.UnitTests.csproj", "{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}" @@ -75,10 +71,6 @@ Global {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|AnyCPU.Build.0 = Debug|AnyCPU {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|AnyCPU.ActiveCfg = Release|AnyCPU {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|AnyCPU.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.Build.0 = Release|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.Build.0 = Debug|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|AnyCPU.ActiveCfg = Release|AnyCPU @@ -122,7 +114,6 @@ Global {9771D1F8-D331-4B26-8E96-6024893009F4} = {B20E4027-0777-4A75-A848-609594E9A6B0} {22EE9386-CEFA-47D8-97B2-09A63EDF7F2E} = {3D2285D5-0E44-4B1A-9B74-2BBE3108D5B7} {8C72D38A-658D-4C9D-B0AD-2DA975BE7826} = {22EE9386-CEFA-47D8-97B2-09A63EDF7F2E} - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4} = {0AC87D9B-BBEC-4DCE-A9D4-82A159E5E7C1} {89A4D88F-5AC0-436A-8EC5-8E98728CA89E} = {B20E4027-0777-4A75-A848-609594E9A6B0} {CCAB7530-4341-4C24-B4E8-28679BB6C4FB} = {4C40BF47-315A-4B60-9ED6-8D65B5E79C2C} {A730FA8A-3713-4F7A-915D-79098CA12DF0} = {B20E4027-0777-4A75-A848-609594E9A6B0} diff --git a/src/DevToys-Windows.sln b/src/DevToys-Windows.sln index 480d744230..3df97a2f97 100644 --- a/src/DevToys-Windows.sln +++ b/src/DevToys-Windows.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33122.133 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{0AC87D9B-BBEC-4DCE-A9D4-82A159E5E7C1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{C85D2D7C-3D69-482A-8AB6-BCA934220EC0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{B20E4027-0777-4A75-A848-609594E9A6B0}" @@ -39,8 +37,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "desktops", "desktops", "{22 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.CLI", "app\dev\platforms\desktop\DevToys.CLI\DevToys.CLI.csproj", "{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.Api", "app\dev\DevToys.Api\DevToys.Api.csproj", "{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.UnitTests", "app\tests\DevToys.UnitTests\DevToys.UnitTests.csproj", "{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}" @@ -94,22 +90,6 @@ Global {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x64.Build.0 = Release|AnyCPU {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x86.ActiveCfg = Release|AnyCPU {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x86.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|ARM64.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|ARM64.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x64.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x64.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x86.ActiveCfg = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x86.Build.0 = Debug|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|ARM64.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|ARM64.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x64.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x64.Build.0 = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x86.ActiveCfg = Release|AnyCPU - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x86.Build.0 = Release|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.Build.0 = Debug|AnyCPU {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|ARM64.ActiveCfg = Debug|AnyCPU @@ -249,7 +229,6 @@ Global {9771D1F8-D331-4B26-8E96-6024893009F4} = {B20E4027-0777-4A75-A848-609594E9A6B0} {22EE9386-CEFA-47D8-97B2-09A63EDF7F2E} = {3D2285D5-0E44-4B1A-9B74-2BBE3108D5B7} {8C72D38A-658D-4C9D-B0AD-2DA975BE7826} = {22EE9386-CEFA-47D8-97B2-09A63EDF7F2E} - {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4} = {0AC87D9B-BBEC-4DCE-A9D4-82A159E5E7C1} {89A4D88F-5AC0-436A-8EC5-8E98728CA89E} = {B20E4027-0777-4A75-A848-609594E9A6B0} {CCAB7530-4341-4C24-B4E8-28679BB6C4FB} = {4C40BF47-315A-4B60-9ED6-8D65B5E79C2C} {A730FA8A-3713-4F7A-915D-79098CA12DF0} = {B20E4027-0777-4A75-A848-609594E9A6B0} diff --git a/src/build/Build.cs b/src/build/Build.cs index ec2b61c86a..c8f1e3555a 100644 --- a/src/build/Build.cs +++ b/src/build/Build.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Runtime.InteropServices; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.ProjectModel; @@ -13,13 +12,10 @@ using Nuke.Common.Utilities.Collections; using Serilog; using static AppVersionTask; -using static Nuke.Common.IO.FileSystemTasks; -using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.Tools.DotNet.DotNetTasks; using static RestoreTask; using Project = Nuke.Common.ProjectModel.Project; -#pragma warning disable IDE1006 // Naming Styles class Build : NukeBuild { /// Support plugins are available for: @@ -28,65 +24,27 @@ class Build : NukeBuild /// - Microsoft VisualStudio https://nuke.build/visualstudio /// - Microsoft VSCode https://nuke.build/vscode - public static int Main() => Execute(x => x.PublishApp); + public static int Main() => Execute(x => x.RunTests); - [Parameter("Configuration to build - Default is 'Release'")] - readonly Configuration Configuration = Configuration.Release; + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] + readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - [Parameter("The target platform")] - readonly PlatformTarget[]? PlatformTargets; - - [Parameter("Runs unit tests")] - readonly bool RunTests; - - [Solution] + [Solution(SuppressBuildProjectCheck = true)] readonly Solution? WindowsSolution; - [Solution] + [Solution(SuppressBuildProjectCheck = true)] readonly Solution? MacSolution; - [Solution] + [Solution(SuppressBuildProjectCheck = true)] readonly Solution? LinuxSolution; - Target PreliminaryCheck => _ => _ - .Before(Clean) - .Executes(() => - { - if (PlatformTargets == null || PlatformTargets.Length == 0) - { - Assert.Fail("Parameter `--platform-targets` is missing. Please check `build.sh --help`."); - return; - } - - if (PlatformTargets.Contains(PlatformTarget.Windows) && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 0, 0)) - { - Assert.Fail("To build Windows app, you need to run on Windows 10 or later."); - return; - } - - if (PlatformTargets.Contains(PlatformTarget.MacOS) && !OperatingSystem.IsMacOS()) - { - Assert.Fail("To build macOS app, you need to run on macOS Ventura 13.1 or later."); - return; - } - - if (PlatformTargets.Contains(PlatformTarget.Linux) && !OperatingSystem.IsLinux()) - { - Assert.Fail("To build Linux app, you need to run on Linux."); - return; - } - - Log.Information("Preliminary checks are successful."); - }); - Target Clean => _ => _ - .DependsOn(PreliminaryCheck) .Executes(() => { - if (!Debugger.IsAttached) - { - RootDirectory.GlobDirectories("bin", "obj", "packages", "publish").ForEach(path => path.CreateOrCleanDirectory()); - } + RootDirectory + .GlobDirectories("bin", "obj", "packages", "publish") + .ForEach(path => path.CreateOrCleanDirectory()); + Log.Information("Cleaned bin, obj, packages and publish folders."); }); Target Restore => _ => _ @@ -100,7 +58,6 @@ class Build : NukeBuild }); Target SetVersion => _ => _ - .DependentFor(GenerateSdkNuGet) .After(Restore) .OnlyWhenDynamic(() => Configuration == Configuration.Release) .Executes(() => @@ -108,15 +65,13 @@ class Build : NukeBuild SetAppVersion(RootDirectory); }); - Target BuildGenerators => _ => _ - .DependentFor(GenerateSdkNuGet) - .After(Restore) - .After(SetVersion) + Target CompileGenerators => _ => _ + .DependsOn(Restore) .Executes(() => { Log.Information($"Building generators ..."); RootDirectory - .GlobFiles("**/generators/*.csproj") + .GlobFiles("**/generators/**/*.csproj") .ForEach(f => DotNetBuild(s => s .SetProjectFile(f) @@ -126,31 +81,38 @@ class Build : NukeBuild .SetVerbosity(DotNetVerbosity.quiet))); }); - Target BuildPlugins => _ => _ - .DependentFor(GenerateSdkNuGet) - .After(Restore) - .After(SetVersion) - .After(BuildGenerators) + Target Compile => _ => _ + .DependsOn(CompileGenerators) .Executes(() => { - Log.Information($"Building plugins ..."); - Project project = WindowsSolution!.GetAllProjects("DevToys.Tools").Single(); + Log.Information($"Building solution ..."); + + Solution solution; + if (OperatingSystem.IsMacOS()) + { + solution = MacSolution!; + } + else if (OperatingSystem.IsWindows()) + { + solution = WindowsSolution!; + } + else if (OperatingSystem.IsLinux()) + { + solution = LinuxSolution!; + } + else + { + throw new InvalidOperationException("You must run Windows, macOS or Linux."); + } + DotNetBuild(s => s - .SetProjectFile(project) + .SetProjectFile(solution) .SetConfiguration(Configuration) - .SetSelfContained(false) - .SetPublishTrimmed(false) .SetVerbosity(DotNetVerbosity.quiet)); }); -#pragma warning disable IDE0051 // Remove unused private members - Target UnitTests => _ => _ - .DependentFor(GenerateSdkNuGet) - .After(Restore) - .After(SetVersion) - .After(BuildGenerators) - .After(BuildPlugins) - .OnlyWhenDynamic(() => RunTests) + Target RunTests => _ => _ + .DependsOn(Compile) .Executes(() => { RootDirectory @@ -159,15 +121,14 @@ class Build : NukeBuild DotNetTest(s => s .SetProjectFile(f) .SetConfiguration(Configuration) - .SetVerbosity(DotNetVerbosity.quiet))); + .SetVerbosity(DotNetVerbosity.minimal))); }); -#pragma warning restore IDE0051 // Remove unused private members Target GenerateSdkNuGet => _ => _ .Description("Generate the DevToys SDK NuGet package") .DependsOn(SetVersion) .DependsOn(Restore) - .DependsOn(BuildGenerators) + .DependsOn(CompileGenerators) .Executes(() => { Log.Information($"Building NuGet packages ..."); @@ -186,25 +147,22 @@ class Build : NukeBuild .DependsOn(GenerateSdkNuGet) .Executes(() => { - if (PlatformTargets!.Contains(PlatformTarget.Windows)) + if (OperatingSystem.IsWindows()) { PublishWindowsApp(); } - if (PlatformTargets!.Contains(PlatformTarget.MacOS)) + if (OperatingSystem.IsMacOS()) { PublishMacApp(); } - if (PlatformTargets!.Contains(PlatformTarget.Linux)) + if (OperatingSystem.IsLinux()) { PublishLinuxApp(); } - if (PlatformTargets!.Contains(PlatformTarget.CLI)) - { - PublishCliApp(); - } + PublishCliApp(); }); void PublishWindowsApp() @@ -309,7 +267,7 @@ IEnumerable GetDotnetParametersForCliApp() string publishProject = "DevToys.CLI"; Project project; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + if (OperatingSystem.IsMacOS()) { project = MacSolution!.GetProject(publishProject); foreach (string targetFramework in project.GetTargetFrameworks()) @@ -321,7 +279,7 @@ IEnumerable GetDotnetParametersForCliApp() yield return new DotnetParameters(project.Path, "osx-arm64", targetFramework, portable: true); } } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + else if (OperatingSystem.IsWindows()) { project = WindowsSolution!.GetAllProjects(publishProject).Single(); foreach (string targetFramework in project.GetTargetFrameworks()) @@ -336,7 +294,7 @@ IEnumerable GetDotnetParametersForCliApp() yield return new DotnetParameters(project.Path, "win-x86", targetFramework, portable: true); } } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + else if (OperatingSystem.IsLinux()) { project = LinuxSolution!.GetAllProjects(publishProject).Single(); foreach (string targetFramework in project.GetTargetFrameworks()) @@ -355,7 +313,7 @@ IEnumerable GetDotnetParametersForWindowsApp() string publishProject = "DevToys.Windows"; Project project; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (OperatingSystem.IsWindows()) { project = WindowsSolution!.GetAllProjects(publishProject).Single(); foreach (string targetFramework in project.GetTargetFrameworks()) @@ -380,7 +338,7 @@ IEnumerable GetDotnetParametersForLinuxApp() string publishProject = "DevToys.Linux"; Project project; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + if (OperatingSystem.IsLinux()) { project = LinuxSolution!.GetAllProjects(publishProject).Single(); foreach (string targetFramework in project.GetTargetFrameworks()) @@ -403,7 +361,7 @@ IEnumerable GetDotnetParametersForMacOSApp() string publishProject = "DevToys.MacOS"; Project project; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + if (OperatingSystem.IsMacOS()) { project = MacSolution!.GetAllProjects(publishProject).Single(); foreach (string targetFramework in project.GetTargetFrameworks()) @@ -417,5 +375,4 @@ IEnumerable GetDotnetParametersForMacOSApp() throw new NotSupportedException(); } } -#pragma warning restore IDE1006 // Naming Styles } diff --git a/src/build/PlatformTarget.cs b/src/build/PlatformTarget.cs deleted file mode 100644 index 4b30f8c2dd..0000000000 --- a/src/build/PlatformTarget.cs +++ /dev/null @@ -1,8 +0,0 @@ -enum PlatformTarget -{ - Windows, - MacOS, - CLI, - Wasm, - Linux // TODO: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/#prerequisites -} diff --git a/src/build/_build.csproj b/src/build/_build.csproj index ef862c72b6..960f81079d 100644 --- a/src/build/_build.csproj +++ b/src/build/_build.csproj @@ -5,10 +5,11 @@ Exe $(NetCore) - CS0649;CS0169 + CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006 ..\.. ..\.. 1 + false false