A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Made CI for Windows build
Etienne Baudouxc4c4df678b2f
diff --git a/.nuke/build.schema.json b/.nuke/build.schema.jsonindex eba815b55..d209b10b2 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 'Debug' (local) or 'Release' (server)",+ "description": "Configuration to build - Default is 'Release'","enum": ["Debug","Release"@@ -43,10 +43,6 @@"VSCode"]},- "IncrementalBuild": {- "type": "boolean",- "description": "Do an incremental build"- },"NoLogo": {"type": "boolean","description": "Disables displaying the NUKE logo"@@ -65,10 +61,10 @@"items": {"type": "string","enum": [- "Linux",+ "CLI","MacOS","Wasm",- "Windows"+ "WindowsUwp"]}},@@ -79,22 +75,6 @@"type": "string"}},- "PublishReadyToRun": {- "type": "boolean",- "description": "https://bit.ly/3RSEo7w"- },- "PublishSelfContained": {- "type": "boolean",- "description": "https://bit.ly/2OEU0KO - Enabled by default"- },- "PublishSingleFile": {- "type": "boolean",- "description": "https://bit.ly/3xvq7FA"- },- "PublishTrimmed": {- "type": "boolean",- "description": "https://bit.ly/3RKZkNH"- },"Root": {"type": "string","description": "Root directory during build execution"@@ -110,7 +90,7 @@"type": "string","enum": ["Clean",- "Compile",+ "PreliminaryCheck","Publish","Restore","SetVersion",@@ -129,7 +109,7 @@"type": "string","enum": ["Clean",- "Compile",+ "PreliminaryCheck","Publish","Restore","SetVersion",diff --git a/README.md b/README.mdindex 214e3f71f..83bca5ea6 100644--- a/README.md+++ b/README.md@@ -30,131 +30,7 @@## Introduction-DevToys helps in daily tasks like formatting JSON, comparing text, testing RegExp. No need to use many untruthful websites to do simple tasks with your data. With Smart Detection, DevToys is able to detect the best tool that can treat the data you copied in the clipboard of your Windows. Compact overlay lets you keep the app in small and on top of other windows. Multiple instances of the app can be used at once.--Many tools are available.--- Converters- - JSON <> YAML- - Timestamp- - Number Base- - Cron Parser-- Encoders / Decoders- - HTML- - URL- - Base64 Text & Image- - GZip- - JWT Decoder-- Formatters- - JSON- - SQL- - XML-- Generators- - Hash (MD5, SHA1, SHA256, SHA512)- - UUID 1 and 4- - Lorem Ipsum- - Checksum-- Text- - Escape / Unescape- - Inspector & Case Converter- - Regex Tester- - Text Comparer- - XML Validator- - Markdown Preview-- Graphic- - Color Blindness Simulator- - Color Picker & Contrast- - PNG / JPEG Compressor- - Image Converter--... and more are coming!----## Rate on Microsoft Store as of 5/23/2022----## How to install (as an end-user)--### Prerequisite--- You need Windows 10 build 1903+ or later.--### Microsoft Store--- Search for DevToys in the Microsoft Store App or click [here](https://www.microsoft.com/store/apps/9PGCV4V3BK4W)--### Manual--- Download and extract the latest [release](https://github.com/veler/DevToys/releases).-- Double click the *.msixbundle file.-- Install.--### WinGet--- Open a PowerShell command prompt.-- Type `winget search DevToys` to search and see details about DevToys.-- Type `winget install DevToys` to install the app.--__Note:__ a Microsoft Store account is required for WinGet. We're trying to workaround it. See here https://github.com/microsoft/winget-pkgs/pull/43996--### Chocolatey--- Make sure you already have [Chocolatey](https://chocolatey.org/) installed on your computer.-- Open a PowerShell command prompt.-- Type `choco install devtoys` or visit the [chocolatey community package](https://community.chocolatey.org/packages/devtoys/).--## App Permission--DevToys works entirely offline, meaning that none of the data used by the app goes on internet. However, the app requires some other permissions in order to work correctly.--1. `Uses all system resources` - This permission is required for some tools like `PNG / JPEG Compressor` or (upcoming) `On-screen color picker / measurer`, which use a 3rd party Open-Source Win32 process like [Efficient-Compression-Tool](https://github.com/fhanau/Efficient-Compression-Tool).- All the code requiring this permission can be found [here](https://github.com/veler/DevToys/tree/main/src/dev/impl/DevToys.OutOfProcService).--## How to run DevToys--### Using Start Menu--Open Windows start menu, type `DevToys` and press `[Enter]`.--### Using PowerShell--A cool thing about DevToys is that you can start it in command line! For this, simply open a PowerShell command prompt and type-`start devtoys:?tool={tool name}`--For example, `start devtoys:?tool=jsonyaml` will open DevToys and start on the `Json <> Yaml` tool.--Here is the list of tool name you can use:--- `base64` - Base64 Text Encoder/Decoder-- `base64img` - Base64 Image Encoder/Decoder-- `gzip` - GZip Encoder/Decoder-- `hash` - Hash Generator-- `uuid` - UUID Generator-- `loremipsum` - Lorem Ipsum Generator-- `checksum` - Checksum File-- `cronparser` - Cron Parser-- `jsonformat` Json Formatter-- `sqlformat` - SQL Formatter-- `xmlformat` - XML Formatter-- `jsonyaml` - Json <> Yaml-- `jwt` - JWT Decoder-- `colorblind` - Color Blindness Simulator-- `color` - Color Picker & Contrast-- `imgcomp` - PNG/JPEG compressor-- `imageconverter` - Image Converter-- `markdown` - Markdown Preview-- `regex` - Regular Expression Tester-- `time` - Unix Timestamp Converter-- `baseconverter` - Number Base Converter-- `string` - String Utilities-- `url` - URL Encoder/Decoder-- `html` - HTML Encoder/Decoder-- `diff` - Text Comparer-- `xmlvalidator` - XML Validator-- `escape` - Text Escape / Unescape-- `settings` - Settings+// TODO## Contribute@@ -180,8 +56,6 @@ DevToys is using a license that permits redistribution of the app as trialware o### Code contributors--<a href="https://github.com/veler/devtoys/graphs/contributors"><img src="https://contrib.rocks/image?repo=veler/devtoys" /></a>diff --git a/ci/azure-pipelines-release.yml b/ci/azure-pipelines-release.ymldeleted file mode 100644index bc428f140..000000000--- a/ci/azure-pipelines-release.yml+++ /dev/null@@ -1,174 +0,0 @@-# Universal Windows Platform-# Build a Universal Windows Platform project using Visual Studio.-# Add steps that test and distribute an app, save build artifacts, and more:-# https://aka.ms/yaml--trigger: none-pr: none--pool:- vmImage: 'windows-2022'--variables:- group: BuildPipelineVariables- uwpProject: '**/*.wapproj'- buildConfiguration: 'Release'- appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'- buildFolder: '$(Build.SourcesDirectory)\bin\'- certificateSecureFilePath: 'DevToys.Startup_TemporaryKey.pfx'--jobs:-### Sideload release ###-- job: SideloadRelease- displayName: 'Sideload Release Build'- timeoutInMinutes: 120- variables:- buildPlatform: 'x86|x64|arm64'- steps:-- - task: PowerShell@2- displayName: 'Rename app in appxmanifest'- inputs:- targetType: 'inline'- script: |- [xml]$xmlDoc = Get-Content $(Build.SourcesDirectory)\src\dev\DevToys.Startup\Package.appxmanifest- $xmlDoc.Package.Identity.Name="DevToys"- $xmlDoc.Package.Identity.Publisher="CN=etiennebaudoux"- $xmlDoc.Package.Properties.DisplayName="DevToys"- $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="DevToys"- $xmlDoc.Save('$(Build.SourcesDirectory)\src\dev\DevToys.Startup\Package.appxmanifest')- failOnStderr: true-- - task: PowerShell@2- displayName: 'Use Release Logo'- inputs:- targetType: 'inline'- script: |- gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process {- (Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\Logo-Prev", "Assets\Logo"}) | Set-Content $_ -NoNewline- }- failOnStderr: true-- - task: DownloadSecureFile@1- displayName: 'Download certificate'- name: signingCert- inputs:- secureFile: '$(certificateSecureFilePath)'-- - task: UseDotNet@2- displayName: 'Set to use .Net 6.0'- inputs:- packageType: sdk- version: 6.x-- # Run the init.ps1, which mostly restores dependencies- - task: PowerShell@2- displayName: 'Restore nuget packages & Monaco editor'- inputs:- filePath: 'init.ps1'- failOnStderr: true-- # Builds the msixbundle file- - task: MSBuild@1- displayName: 'Build Sideload package'- inputs:- solution: '$(uwpProject)'- platform: 'x86'- configuration: '$(buildConfiguration)'- msbuildArguments: '/bl:"$(buildFolder)\msbuild.binlog"- /t:build;_GenerateAppxPackage- /restore- /p:AppxBundlePlatforms="$(buildPlatform)"- /p:AppxPackageDir="$(appxPackageDir)"- /p:AppxBundle=Always- /p:UapAppxPackageBuildMode=Sideload- /p:AppxPackageSigningEnabled=true- /p:PackageCertificateKeyFile="$(signingCert.secureFilePath)"- /p:PackageCertificatePassword=""- /p:PackageCertificateThumbprint=""'- maximumCpuCount: true-- - task: PublishBuildArtifacts@1- displayName: 'Publish Artifact: drop'- inputs:- PathtoPublish: '$(appxPackageDir)'- condition: succeeded()-- - task: PublishBuildArtifacts@1- displayName: 'Publish Artifact: output'- inputs:- PathtoPublish: '$(buildFolder)'- condition: failed()--### Store release ###-- job: StoreRelease- displayName: 'Store Release Build'- timeoutInMinutes: 120- variables:- buildPlatform: 'x86|x64|arm64'- steps:-- - task: PowerShell@2- displayName: 'Rename app in appxmanifest'- inputs:- targetType: 'inline'- script: |- [xml]$xmlDoc = Get-Content $(Build.SourcesDirectory)\src\dev\DevToys.Startup\Package.appxmanifest- $xmlDoc.Package.Identity.Name="64360VelerSoftware.DevToys"- $xmlDoc.Package.Identity.Publisher="CN=3D87C8C2-C6F4-4875-B258-5FEC13B08F81"- $xmlDoc.Package.Properties.DisplayName="DevToys"- $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="DevToys"- $xmlDoc.Save('$(Build.SourcesDirectory)\src\dev\DevToys.Startup\Package.appxmanifest')- failOnStderr: true-- - task: PowerShell@2- displayName: 'Use Release Logo'- inputs:- targetType: 'inline'- script: |- gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process {- (Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\Logo-Prev", "Assets\Logo"}) | Set-Content $_ -NoNewline- }- failOnStderr: true-- - task: UseDotNet@2- displayName: 'Set to use .Net 6.0'- inputs:- packageType: sdk- version: 6.x-- # Run the init.ps1, which mostly restores dependencies- - task: PowerShell@2- displayName: 'Restore nuget packages & Monaco editor'- inputs:- filePath: 'init.ps1'- failOnStderr: true-- # Builds the msixbundle file- - task: MSBuild@1- displayName: 'Build Store package'- inputs:- solution: '$(uwpProject)'- platform: 'x86'- configuration: '$(buildConfiguration)'- msbuildArguments: '/bl:"$(buildFolder)\msbuild.binlog"- /t:build;_GenerateAppxPackage- /restore- /p:AppxBundlePlatforms="$(buildPlatform)"- /p:AppxPackageDir="$(appxPackageDir)"- /p:AppxBundle=Always- /p:UapAppxPackageBuildMode=StoreUpload- /p:AppxPackageSigningEnabled=false'- maximumCpuCount: true-- - task: PublishBuildArtifacts@1- displayName: 'Publish Artifact: drop'- inputs:- PathtoPublish: '$(appxPackageDir)'- condition: succeeded()-- - task: PublishBuildArtifacts@1- displayName: 'Publish Artifact: output'- inputs:- PathtoPublish: '$(buildFolder)'- condition: failed()\ No newline at end of filediff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.ymldeleted file mode 100644index 4b86e71d4..000000000--- a/ci/azure-pipelines.yml+++ /dev/null@@ -1,88 +0,0 @@-# Universal Windows Platform-# Build a Universal Windows Platform project using Visual Studio.-# Add steps that test and distribute an app, save build artifacts, and more:-# https://aka.ms/yaml--trigger:-- main--pool:- vmImage: 'windows-2022'--variables:- group: BuildPipelineVariables- uwpProject: '**/*.wapproj'- testProject: '**/*.Tests.csproj'- buildPlatform: 'x86|x64|arm64'- buildConfiguration: 'Release'- appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'- buildFolder: '$(Build.SourcesDirectory)\bin\'--jobs:-- job: Build- timeoutInMinutes: 120- steps:-- - task: UseDotNet@2- displayName: 'Set to use .Net 6.0'- inputs:- packageType: sdk- version: 6.x-- # Run the init.ps1, which mostly restores dependencies- - task: PowerShell@2- displayName: 'Restore nuget packages & Monaco editor'- inputs:- filePath: 'init.ps1'- failOnStderr: true-- # Builds the msixbundle file- - task: MSBuild@1- displayName: 'Build UWP AppxBundle'- inputs:- solution: '$(uwpProject)'- configuration: '$(buildConfiguration)'- msbuildArguments: '/bl:"$(buildFolder)\msbuild.binlog"- /t:build- /restore- /p:AppxBundlePlatforms="$(buildPlatform)"- /p:AppxPackageDir="$(appxPackageDir)"- /p:AppxPackageSigningEnabled=false- /p:AppxBundle=Always- /p:UapAppxPackageBuildMode=StoreUpload'- maximumCpuCount: true-- # Builds unit tests- - task: MSBuild@1- displayName: 'Build Unit Tests'- inputs:- solution: '$(testProject)'- configuration: 'Debug'- msbuildArguments: '/t:build /restore'- maximumCpuCount: true-- - task: VSTest@2- displayName: 'Run Unit Tests'- inputs:- testSelector: 'testAssemblies'- testAssemblyVer2: |- **\Debug\**\*.Tests.build.appxrecipe- !**\obj\**- searchFolder: '$(System.DefaultWorkingDirectory)'- otherConsoleOptions: '/Framework:FrameworkUap10'- platform: '$(BuildPlatform)'- configuration: '$(BuildConfiguration)'- diagnosticsEnabled: True- collectDumpOn: always-- - task: PublishBuildArtifacts@1- displayName: 'Publish Artifact: drop'- inputs:- PathtoPublish: '$(appxPackageDir)'- condition: succeeded()-- - task: PublishBuildArtifacts@1- displayName: 'Publish Artifact: output'- inputs:- PathtoPublish: '$(buildFolder)'- condition: failed()diff --git a/doc/public-api.md b/doc/public-api.mdnew file mode 100644index 000000000..0ffdd02fc--- /dev/null+++ b/doc/public-api.md@@ -0,0 +1 @@+// TODO\ No newline at end of filediff --git a/src/app/dev/platforms/desktop/windows/DevToys.Windows/DevToys.Windows.wapproj b/src/app/dev/platforms/desktop/windows/DevToys.Windows/DevToys.Windows.wapprojindex 276b8f851..1185c7136 100644--- a/src/app/dev/platforms/desktop/windows/DevToys.Windows/DevToys.Windows.wapproj+++ b/src/app/dev/platforms/desktop/windows/DevToys.Windows/DevToys.Windows.wapproj@@ -42,7 +42,7 @@<GenerateTestArtifacts>True</GenerateTestArtifacts><AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms><HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>- <AppxPackageDir>..\..\..\..\..\..\..\bin\AppPackages\</AppxPackageDir>+ <AppxPackageDir>..\..\..\..\..\..\..\publish\MSIX\</AppxPackageDir><AppxBundle>Always</AppxBundle><EntryPointProjectUniqueName>..\DevToys.Windows.Core\DevToys.Windows.Core.csproj</EntryPointProjectUniqueName><UapAppxPackageBuildMode>StoreAndSideload</UapAppxPackageBuildMode>diff --git a/src/build/AppVersion/AppVersion.cs b/src/build/AppVersion/AppVersionTask.cssimilarity index 97%rename from src/build/AppVersion/AppVersion.csrename to src/build/AppVersion/AppVersionTask.csindex a915f79ab..fd0d7b780 100644--- a/src/build/AppVersion/AppVersion.cs+++ b/src/build/AppVersion/AppVersionTask.cs@@ -3,7 +3,7 @@ using System.IO;using Nuke.Common.IO;using Serilog;-internal static class AppVersion+internal static class AppVersionTask{internal static void SetAppVersion(AbsolutePath rootDirectory){diff --git a/src/build/Build.cs b/src/build/Build.csindex 12ef661a0..165500ee4 100644--- a/src/build/Build.cs+++ b/src/build/Build.cs@@ -1,17 +1,25 @@using System;using System.Collections.Generic;+using System.Diagnostics;+using System.Linq;using System.Runtime.InteropServices;+using Microsoft.Build.Evaluation;using Nuke.Common;using Nuke.Common.IO;using Nuke.Common.ProjectModel;+using Nuke.Common.Tooling;using Nuke.Common.Tools.DotNet;using Nuke.Common.Tools.GitVersion;+using Nuke.Common.Tools.MSBuild;using Nuke.Common.Utilities.Collections;using Serilog;-using static AppVersion;+using static AppVersionTask;using static Nuke.Common.IO.FileSystemTasks;using static Nuke.Common.IO.PathConstruction;using static Nuke.Common.Tools.DotNet.DotNetTasks;+using static Nuke.Common.Tools.MSBuild.MSBuildTasks;+using static RestoreTask;+using Project = Nuke.Common.ProjectModel.Project;#pragma warning disable IDE1006 // Naming Stylesclass Build : NukeBuild@@ -24,86 +32,69 @@ class Build : NukeBuildpublic static int Main() => Execute<Build>(x => x.Publish);- [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]- readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;+ [Parameter("Configuration to build - Default is 'Release'")]+ readonly Configuration Configuration = Configuration.Release;[Parameter("The target platform")]readonly PlatformTarget[] PlatformTargets;- [Parameter("https://bit.ly/2OEU0KO - Enabled by default")]- readonly bool PublishSelfContained = true;-- [Parameter("https://bit.ly/3xvq7FA")]- readonly bool PublishSingleFile;-- [Parameter("https://bit.ly/3RSEo7w")]- readonly bool PublishReadyToRun;-- [Parameter("https://bit.ly/3RKZkNH")]- readonly bool PublishTrimmed;-[Parameter("Runs unit tests")]readonly bool RunTests;- [Parameter("Do an incremental build")]- readonly bool IncrementalBuild;-[Solution]readonly Solution Solution;+ Target PreliminaryCheck => _ => _+ .Before(Clean)+ .Executes(() =>+ {+ if (PlatformTargets == null || PlatformTargets.Length == 0)+ {+ Assert.Fail("Parameter `--platform-targets` is missing. Please check `build.sh --help`.");+ }++ if (PlatformTargets.Contains(PlatformTarget.WindowsUwp) && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 0, 0))+ {+ Assert.Fail("To build Windows UWP app, you need to run on Windows 10 or later.");+ }++ Log.Information("Preliminary checks are successful.");+ });+Target Clean => _ => _- .Before(Restore)- .OnlyWhenDynamic(() => !IncrementalBuild)+ .DependsOn(PreliminaryCheck).Executes(() =>{- RootDirectory.GlobDirectories("bin", "obj", "publish").ForEach(DeleteDirectory);+ if (!Debugger.IsAttached)+ {+ RootDirectory.GlobDirectories("bin", "obj", "publish").ForEach(DeleteDirectory);+ }});Target Restore => _ => _.DependsOn(Clean)- .Executes(() =>+ .Executes(async () =>{- DotNetRestore(s => s- .SetProjectFile(Solution)- .SetVerbosity(DotNetVerbosity.Quiet));+ if (!Debugger.IsAttached)+ {+ await RestoreDependenciesAsync(RootDirectory);+ }});-#pragma warning disable IDE0051 // Remove unused private membersTarget SetVersion => _ => _- .DependentFor(Compile)+ .DependentFor(Publish).After(Restore).OnlyWhenDynamic(() => Configuration == Configuration.Release).Executes(() =>{SetAppVersion(RootDirectory);});-#pragma warning restore IDE0051 // Remove unused private members-- Target Compile => _ => _- .DependsOn(Restore)- .Executes(() =>- {- foreach (DotnetParameters dotnetParameters in GetDotnetParameters())- {- Log.Information($"Building {dotnetParameters.ProjectOrSolutionPath + "-" + dotnetParameters.TargetFramework + "-" + dotnetParameters.RuntimeIdentifier}...");- DotNetBuild(s => s- .SetProjectFile(dotnetParameters.ProjectOrSolutionPath)- .SetConfiguration(Configuration)- .SetFramework(dotnetParameters.TargetFramework)- .SetRuntime(dotnetParameters.RuntimeIdentifier)- .SetSelfContained(dotnetParameters.SelfContained)- .SetPublishSingleFile(PublishSingleFile)- .SetPublishReadyToRun(PublishReadyToRun)- .SetPublishTrimmed(dotnetParameters.PublishTrimmed)- .SetNoIncremental(!IncrementalBuild)- .SetVerbosity(DotNetVerbosity.Quiet));- }- });#pragma warning disable IDE0051 // Remove unused private membersTarget UnitTests => _ => _.DependentFor(Publish)- .After(Compile)+ .After(Restore)+ .After(SetVersion).OnlyWhenDynamic(() => RunTests).Executes(() =>{@@ -118,91 +109,91 @@ class Build : NukeBuild#pragma warning restore IDE0051 // Remove unused private membersTarget Publish => _ => _- .DependsOn(Compile)+ .DependsOn(SetVersion)+ .DependsOn(Restore).Executes(() =>{- foreach (DotnetParameters dotnetParameters in GetDotnetParameters())+ if (PlatformTargets.Contains(PlatformTarget.WindowsUwp)){- Log.Information($"Publishing {dotnetParameters.ProjectOrSolutionPath + "-" + dotnetParameters.TargetFramework + "-" + dotnetParameters.RuntimeIdentifier}...");- DotNetPublish(s => s- .SetProject(dotnetParameters.ProjectOrSolutionPath)- .SetConfiguration(Configuration)- .SetFramework(dotnetParameters.TargetFramework)- .SetRuntime(dotnetParameters.RuntimeIdentifier)- .SetSelfContained(dotnetParameters.SelfContained)- .SetPublishSingleFile(PublishSingleFile)- .SetPublishReadyToRun(PublishReadyToRun)- .SetPublishTrimmed(dotnetParameters.PublishTrimmed)- .SetVerbosity(DotNetVerbosity.Quiet)- .SetOutput(RootDirectory / "publish" / dotnetParameters.ProjectOrSolutionPath.Name + "-" + dotnetParameters.TargetFramework + "-" + dotnetParameters.RuntimeIdentifier));+ RootDirectory+ .GlobFiles("**/*.wapproj")+ .ForEach(f =>+ {+ Log.Information($"Building {f}...");+ MSBuild(s => s+ .SetTargetPath(f)+ .SetConfiguration(Configuration)+ .SetTargets("Build")+ .AddProperty("AppxBundlePlatforms", "x86|x64|arm64")+ .AddProperty("AppxPackageDir", RootDirectory / "publish" / "MSIX")+ .AddProperty("AppxPackageSigningEnabled", false)+ .AddProperty("AppxSymbolPackageEnabled", true)+ .AddProperty("AppxBundle", "Always")+ .AddProperty("UapAppxPackageBuildMode", "StoreUpload")+ .SetProcessArgumentConfigurator(_ => _.Add($"/bl:\"{RootDirectory / "bin" / "msbuild.binlog"}\""))+ .SetVerbosity(MSBuildVerbosity.Quiet)+ .SetMaxCpuCount(1)+ .EnableRestore()+ // This is dummy but necessary otherwise MSBuild tries to use Any CPU, which doesn't work for UWP.+ .SetTargetPlatform(MSBuildTargetPlatform.x86));+ });+ }++ if (PlatformTargets.Contains(PlatformTarget.CLI))+ {+ foreach (DotnetParameters dotnetParameters in GetDotnetParametersForCliApp())+ {+ Log.Information($"Publishing {dotnetParameters.ProjectOrSolutionPath + "-" + dotnetParameters.TargetFramework + "-" + dotnetParameters.RuntimeIdentifier}...");+ DotNetPublish(s => s+ .SetProject(dotnetParameters.ProjectOrSolutionPath)+ .SetConfiguration(Configuration)+ .SetFramework(dotnetParameters.TargetFramework)+ .SetRuntime(dotnetParameters.RuntimeIdentifier)+ .SetSelfContained(dotnetParameters.Portable)+ .SetPublishSingleFile(true)+ .SetPublishReadyToRun(true)+ .SetPublishTrimmed(dotnetParameters.Portable)+ .SetVerbosity(DotNetVerbosity.Quiet)+ .SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));+ }}});- IEnumerable<DotnetParameters> GetDotnetParameters()+ IEnumerable<DotnetParameters> GetDotnetParametersForCliApp(){- PlatformTarget[] platformTargets = PlatformTargets;- if (PlatformTargets is null || PlatformTargets.Length == 0)+ string publishProject = "DevToys.CLI";+ Project project = Solution.GetProject(publishProject);++ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)){- // If not defined, detect automatically.- var p = new List<PlatformTarget>+ foreach (string targetFramework in project.GetTargetFrameworks()){- PlatformTarget.Wasm- };+ // 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);- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))- {- p.Add(PlatformTarget.MacOS);- //p.Add(PlatformTarget.iOS);- }- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))- {- p.Add(PlatformTarget.Windows);+ yield return new DotnetParameters(project.Path, "osx-arm64", targetFramework, portable: false);+ yield return new DotnetParameters(project.Path, "osx-arm64", targetFramework, portable: true);}- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))- {- p.Add(PlatformTarget.Linux);- }-- platformTargets = p.ToArray();}-- for (int i = 0; i < platformTargets.Length; i++)+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)){- PlatformTarget platformTarget = platformTargets[i];- string publishProject;- Project project;- switch (platformTarget)+ foreach (string targetFramework in project.GetTargetFrameworks()){- case PlatformTarget.Wasm:- publishProject = "DevToys.Wasm";- project = Solution.GetProject(publishProject);- foreach (string targetFramework in project.GetTargetFrameworks())- {- yield return new DotnetParameters(project.Path, runtimeIdentifier: string.Empty, targetFramework, PublishTrimmed, selfContained: false);- }- break;-- case PlatformTarget.Windows:- publishProject = "DevToys.Windows";- project = Solution.GetProject(publishProject);- foreach (string targetFramework in project.GetTargetFrameworks())- {- yield return new DotnetParameters(project.Path, "win10-x64", targetFramework, PublishTrimmed, PublishSelfContained);- yield return new DotnetParameters(project.Path, "win10-arm64", targetFramework, PublishTrimmed, PublishSelfContained);- yield return new DotnetParameters(project.Path, "win10-x86", targetFramework, PublishTrimmed, PublishSelfContained);- }- break;+ yield return new DotnetParameters(project.Path, "win10-x64", targetFramework, portable: false);+ yield return new DotnetParameters(project.Path, "win10-x64", targetFramework, portable: true);- case PlatformTarget.MacOS:- throw new NotSupportedException();+ yield return new DotnetParameters(project.Path, "win10-arm64", targetFramework, portable: false);+ yield return new DotnetParameters(project.Path, "win10-arm64", targetFramework, portable: true);- case PlatformTarget.Linux:- throw new NotSupportedException();-- default:- throw new NotSupportedException();+ yield return new DotnetParameters(project.Path, "win10-x86", targetFramework, portable: false);+ yield return new DotnetParameters(project.Path, "win10-x86", targetFramework, portable: true);}}+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))+ {+ // TODO+ }}#pragma warning restore IDE1006 // Naming Styles}diff --git a/src/build/DotnetParameters.cs b/src/build/DotnetParameters.csindex fd12904a2..fce4e8c53 100644--- a/src/build/DotnetParameters.cs+++ b/src/build/DotnetParameters.cs@@ -8,21 +8,16 @@ internal sealed record DotnetParametersinternal readonly string TargetFramework;- internal readonly bool PublishTrimmed;+ internal readonly bool Portable;- internal readonly bool SelfContained;+ internal readonly string OutputPath;- public DotnetParameters(- AbsolutePath projectOrSolutionPath,- string runtimeIdentifier,- string targetFramework,- bool publishTrimmed,- bool selfContained)+ public DotnetParameters(AbsolutePath projectOrSolutionPath, string runtimeIdentifier, string targetFramework, bool portable){ProjectOrSolutionPath = projectOrSolutionPath;RuntimeIdentifier = runtimeIdentifier;TargetFramework = targetFramework;- PublishTrimmed = publishTrimmed;- SelfContained = selfContained;+ Portable = portable;+ OutputPath = $"{ProjectOrSolutionPath.Name}-{TargetFramework}-{RuntimeIdentifier}{(portable ? "-portable" : string.Empty)}";}}diff --git a/src/build/PlatformTarget.cs b/src/build/PlatformTarget.csindex 9b73738ac..b84a57b17 100644--- a/src/build/PlatformTarget.cs+++ b/src/build/PlatformTarget.cs@@ -1,7 +1,7 @@enum PlatformTarget{- Windows,+ WindowsUwp,MacOS,- Linux,+ CLI,Wasm}diff --git a/src/build/Restore/RestoreTask.cs b/src/build/Restore/RestoreTask.csnew file mode 100644index 000000000..0ffb969d9--- /dev/null+++ b/src/build/Restore/RestoreTask.cs@@ -0,0 +1,86 @@+using System;+using System.Diagnostics;+using System.Threading.Tasks;+using Nuke.Common.IO;+using Nuke.Common.Tooling;+using Nuke.Common.Tools.PowerShell;+using Serilog;++internal static class RestoreTask+{+ internal static Task RestoreDependenciesAsync(AbsolutePath rootDirectory)+ {+ if (OperatingSystem.IsWindows())+ {+ return RestoreWindowsAsync(rootDirectory);+ }+ else+ {+ return RestoreUnixAsync(rootDirectory);+ }+ }++ private static Task RestoreWindowsAsync(AbsolutePath rootDirectory)+ {+ System.Collections.Generic.IReadOnlyCollection<Output> results+ = PowerShellTasks+ .PowerShell(_ => _+ .SetFile(rootDirectory / "init.ps1")+ .SetProcessLogOutput(true)+ .SetProcessWorkingDirectory(rootDirectory)+ .SetNoLogo(true)+ .SetNoProfile(true));+ return Task.CompletedTask;+ }++ private static Task RestoreUnixAsync(AbsolutePath rootDirectory)+ {+ return Bash(rootDirectory / "ini.sh");+ }++ public static Task<int> Bash(string cmd)+ {+ var source = new TaskCompletionSource<int>();+ string escapedArgs = cmd.Replace("\"", "\\\"");+ var process = new Process+ {+ StartInfo = new ProcessStartInfo+ {+ FileName = "bash",+ Arguments = $"-c \"{escapedArgs}\"",+ RedirectStandardOutput = true,+ RedirectStandardError = true,+ UseShellExecute = false,+ CreateNoWindow = true+ },+ EnableRaisingEvents = true+ };+ process.Exited += (sender, args) =>+ {+ Log.Warning(process.StandardError.ReadToEnd());+ Log.Information(process.StandardOutput.ReadToEnd());+ if (process.ExitCode == 0)+ {+ source.SetResult(0);+ }+ else+ {+ source.SetException(new Exception($"Command `{cmd}` failed with exit code `{process.ExitCode}`"));+ }++ process.Dispose();+ };++ try+ {+ process.Start();+ }+ catch (Exception e)+ {+ Log.Error(e, "Command {} failed", cmd);+ source.SetException(e);+ }++ return source.Task;+ }+}