├── .appveyor.yml ├── .gitignore ├── GitReleaseManager.yaml ├── LICENSE.md ├── README.md ├── build.ps1 ├── recipe.cake ├── src ├── Cake.Squirrel.Tests │ ├── Cake.Squirrel.Tests.csproj │ ├── Fixture │ │ ├── SquirrelRunnerFixture.cs │ │ └── SyncReleasesRunnerFixture.cs │ ├── SquirrelAliasesTests.cs │ ├── SquirrelRunnerTests.cs │ └── SyncReleasesRunnerTests.cs ├── Cake.Squirrel.sln └── Cake.Squirrel │ ├── Cake.Squirrel.csproj │ ├── SquirrelAliases.cs │ ├── SquirrelRunner.cs │ ├── SquirrelSettings.cs │ ├── SyncReleasesRunner.cs │ └── SyncReleasesSettings.cs └── tools └── packages.config /.appveyor.yml: -------------------------------------------------------------------------------- 1 | #---------------------------------# 2 | # Build Image # 3 | #---------------------------------# 4 | image: Visual Studio 2017 5 | 6 | #---------------------------------# 7 | # Build Script # 8 | #---------------------------------# 9 | build_script: 10 | - ps: .\build.ps1 -Target AppVeyor 11 | 12 | # Tests 13 | test: off 14 | 15 | #---------------------------------# 16 | # Branches to build # 17 | #---------------------------------# 18 | branches: 19 | # Whitelist 20 | only: 21 | - develop 22 | - master 23 | - /release/.*/ 24 | - /hotfix/.*/ 25 | 26 | #---------------------------------# 27 | # Build Cache # 28 | #---------------------------------# 29 | cache: 30 | - Source\packages -> Source\**\packages.config 31 | - tools -> setup.cake -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | 254 | # Cake - C# Make 255 | tools/* 256 | !tools/packages.config 257 | BuildArtifacts 258 | 259 | -------------------------------------------------------------------------------- /GitReleaseManager.yaml: -------------------------------------------------------------------------------- 1 | issue-labels-include: 2 | - Breaking change 3 | - Feature 4 | - Bug 5 | - Improvement 6 | - Documentation 7 | issue-labels-exclude: 8 | - Build 9 | issue-labels-alias: 10 | - name: Documentation 11 | header: Documentation 12 | plural: Documentation -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2015-2019 Jamie Phillips 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cake.Squirrel 2 | 3 | A Cake Addin for [Squirrel.Windows](https://github.com/Squirrel/Squirrel.Windows). 4 | 5 | [![Build status](https://ci.appveyor.com/api/projects/status/6bv8xgvgr5acpdki?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-squirrel) 6 | 7 | [![cakebuild.net](https://img.shields.io/badge/WWW-cakebuild.net-blue.svg)](http://cakebuild.net/) 8 | 9 | [![Join the chat at https://gitter.im/cake-build/cake](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cake-build/cake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 10 | 11 | ## Functionality 12 | 13 | Supports all the current command line options provided by Squirrel.Windows 14 | 15 | ```cmd 16 | Usage: Squirrel.exe command [OPTS] 17 | Manages Squirrel packages 18 | 19 | Commands 20 | --releasify=VALUE Update or generate a releases directory with a 21 | given NuGet package 22 | Options: 23 | -h, -?, --help Display Help and exit 24 | -r, --releaseDir=VALUE Path to a release directory to use with releasify 25 | -p, --packagesDir=VALUE Path to the NuGet Packages directory for C# apps 26 | --bootstrapperExe=VALUE 27 | Path to the Setup.exe to use as a template 28 | -g, --loadingGif=VALUE Path to an animated GIF to be displayed during 29 | installation 30 | -i, --icon=VALUE Path to an ICO file that will be used for icon 31 | shortcuts 32 | --setupIcon=VALUE Path to an ICO file that will be used for the 33 | Setup executable's icon 34 | -n, --signWithParams=VALUE Sign the installer via SignTool.exe with the 35 | parameters given 36 | -s, --silent Silent install 37 | -l, --shortcut-locations=VALUE 38 | Comma-separated string of shortcut locations, e.g. 39 | 'Desktop,StartMenu' 40 | --no-msi Don't generate an MSI package 41 | ``` 42 | 43 | ## Usage 44 | 45 | To use the addin just add it to Cake call the aliases and configure any settings you want. 46 | 47 | ```csharp 48 | #tool "Squirrel.Windows" 49 | #addin Cake.Squirrel 50 | 51 | ... 52 | 53 | // How to package with no settings 54 | Task("PackageNoSettings") 55 | .Does(() => { 56 | Squirrel(GetFile("Package.nupkg")); 57 | }); 58 | 59 | // How to package with the settings 60 | Task("PackageWithSettings") 61 | .Does(() => { 62 | var settings = new SquirrelSettings(); 63 | settings.NoMsi = true; 64 | settings.Silent = true; 65 | 66 | Squirrel(GetFile("Package.nupkg", settings)); 67 | }); 68 | ``` 69 | 70 | Thats it. 71 | 72 | Hope you enjoy using. 73 | 74 | ## Support 75 | 76 | If you would like to support this project, there are several opportunities. Pull Requests, bug reports, documentation, promotion, and encouragement are all great ways. If you would like to contribute monetarily, you can [Buy Me a Coffee](https://www.buymeacoffee.com/aQPnJ73O8). 77 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This is the Cake bootstrapper script for PowerShell. 3 | # This file was downloaded from https://github.com/cake-build/resources 4 | # Feel free to change this file to fit your needs. 5 | ########################################################################## 6 | 7 | <# 8 | 9 | .SYNOPSIS 10 | This is a Powershell script to bootstrap a Cake build. 11 | 12 | .DESCRIPTION 13 | This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) 14 | and execute your Cake build script with the parameters you provide. 15 | 16 | .PARAMETER Script 17 | The build script to execute. 18 | .PARAMETER Target 19 | The build script target to run. 20 | .PARAMETER Configuration 21 | The build configuration to use. 22 | .PARAMETER Verbosity 23 | Specifies the amount of information to be displayed. 24 | .PARAMETER Experimental 25 | Tells Cake to use the latest Roslyn release. 26 | .PARAMETER WhatIf 27 | Performs a dry run of the build script. 28 | No tasks will be executed. 29 | .PARAMETER Mono 30 | Tells Cake to use the Mono scripting engine. 31 | .PARAMETER SkipToolPackageRestore 32 | Skips restoring of packages. 33 | .PARAMETER ScriptArgs 34 | Remaining arguments are added here. 35 | 36 | .LINK 37 | http://cakebuild.net 38 | 39 | #> 40 | 41 | [CmdletBinding()] 42 | Param( 43 | [string]$Script = "recipe.cake", 44 | [string]$Target = "Default", 45 | [ValidateSet("Release", "Debug")] 46 | [string]$Configuration = "Release", 47 | [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] 48 | [string]$Verbosity = "Verbose", 49 | [switch]$Experimental, 50 | [Alias("DryRun","Noop")] 51 | [switch]$WhatIf, 52 | [switch]$Mono, 53 | [switch]$SkipToolPackageRestore, 54 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 55 | [string[]]$ScriptArgs 56 | ) 57 | 58 | [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null 59 | function MD5HashFile([string] $filePath) 60 | { 61 | if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) 62 | { 63 | return $null 64 | } 65 | 66 | [System.IO.Stream] $file = $null; 67 | [System.Security.Cryptography.MD5] $md5 = $null; 68 | try 69 | { 70 | $md5 = [System.Security.Cryptography.MD5]::Create() 71 | $file = [System.IO.File]::OpenRead($filePath) 72 | return [System.BitConverter]::ToString($md5.ComputeHash($file)) 73 | } 74 | finally 75 | { 76 | if ($file -ne $null) 77 | { 78 | $file.Dispose() 79 | } 80 | } 81 | } 82 | 83 | Write-Host "Preparing to run build script..." 84 | 85 | if(!$PSScriptRoot){ 86 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 87 | } 88 | 89 | $TOOLS_DIR = Join-Path $PSScriptRoot "tools" 90 | $NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" 91 | $CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" 92 | $NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" 93 | $PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" 94 | $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" 95 | 96 | # Should we use mono? 97 | $UseMono = ""; 98 | if($Mono.IsPresent) { 99 | Write-Verbose -Message "Using the Mono based scripting engine." 100 | $UseMono = "-mono" 101 | } 102 | 103 | # Should we use the new Roslyn? 104 | $UseExperimental = ""; 105 | if($Experimental.IsPresent -and !($Mono.IsPresent)) { 106 | Write-Verbose -Message "Using experimental version of Roslyn." 107 | $UseExperimental = "-experimental" 108 | } 109 | 110 | # Is this a dry run? 111 | $UseDryRun = ""; 112 | if($WhatIf.IsPresent) { 113 | $UseDryRun = "-dryrun" 114 | } 115 | 116 | # Make sure tools folder exists 117 | if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { 118 | Write-Verbose -Message "Creating tools directory..." 119 | New-Item -Path $TOOLS_DIR -Type directory | out-null 120 | } 121 | 122 | # Make sure that packages.config exist. 123 | if (!(Test-Path $PACKAGES_CONFIG)) { 124 | Write-Verbose -Message "Downloading packages.config..." 125 | try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { 126 | Throw "Could not download packages.config." 127 | } 128 | } 129 | 130 | # Try find NuGet.exe in path if not exists 131 | if (!(Test-Path $NUGET_EXE)) { 132 | Write-Verbose -Message "Trying to find nuget.exe in PATH..." 133 | $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) } 134 | $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 135 | if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { 136 | Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." 137 | $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName 138 | } 139 | } 140 | 141 | # Try download NuGet.exe if not exists 142 | if (!(Test-Path $NUGET_EXE)) { 143 | Write-Verbose -Message "Downloading NuGet.exe..." 144 | try { 145 | (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) 146 | } catch { 147 | Throw "Could not download NuGet.exe." 148 | } 149 | } 150 | 151 | # Save nuget.exe path to environment to be available to child processed 152 | $ENV:NUGET_EXE = $NUGET_EXE 153 | 154 | # Restore tools from NuGet? 155 | if(-Not $SkipToolPackageRestore.IsPresent) { 156 | Push-Location 157 | Set-Location $TOOLS_DIR 158 | 159 | # Check for changes in packages.config and remove installed tools if true. 160 | [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) 161 | if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or 162 | ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { 163 | Write-Verbose -Message "Missing or changed package.config hash..." 164 | Remove-Item * -Recurse -Exclude packages.config,nuget.exe 165 | } 166 | 167 | Write-Verbose -Message "Restoring tools from NuGet..." 168 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" 169 | 170 | if ($LASTEXITCODE -ne 0) { 171 | Throw "An error occured while restoring NuGet tools." 172 | } 173 | else 174 | { 175 | $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" 176 | } 177 | Write-Verbose -Message ($NuGetOutput | out-string) 178 | Pop-Location 179 | } 180 | 181 | # Make sure that Cake has been installed. 182 | if (!(Test-Path $CAKE_EXE)) { 183 | Throw "Could not find Cake.exe at $CAKE_EXE" 184 | } 185 | 186 | # Start Cake 187 | Write-Host "Running build script..." 188 | Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" 189 | exit $LASTEXITCODE -------------------------------------------------------------------------------- /recipe.cake: -------------------------------------------------------------------------------- 1 | #load nuget:?package=Cake.Recipe&version=1.0.0 2 | 3 | Environment.SetVariableNames(); 4 | 5 | BuildParameters.SetParameters(context: Context, 6 | buildSystem: BuildSystem, 7 | sourceDirectoryPath: "./src", 8 | title: "Cake.Squirrel", 9 | repositoryOwner: "cake-contrib", 10 | repositoryName: "Cake.Squirrel", 11 | appVeyorAccountName: "cakecontrib", 12 | shouldRunDupFinder: false, 13 | shouldRunInspectCode: false, 14 | shouldRunGitVersion: DirectoryExists(".git"), // This would allow building even without using a git repository 15 | shouldRunDotNetCorePack: true); 16 | 17 | BuildParameters.PrintParameters(Context); 18 | 19 | ToolSettings.SetToolSettings(context: Context, 20 | dupFinderExcludePattern: new string[] { 21 | BuildParameters.RootDirectoryPath + "/src/Cake.Squirrel.Tests/*.cs", BuildParameters.RootDirectoryPath + "/src/Cake.Squirrel/SquirrelAliases.cs" }, 22 | testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[FluentAssertions]*", 23 | testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", 24 | testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); 25 | Build.RunDotNetCore(); 26 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.Tests/Cake.Squirrel.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.Tests/Fixture/SquirrelRunnerFixture.cs: -------------------------------------------------------------------------------- 1 | using Cake.Core.IO; 2 | using Cake.Testing.Fixtures; 3 | 4 | namespace Cake.Squirrel.Tests.Fixture { 5 | internal sealed class SquirrelRunnerFixture : ToolFixture { 6 | public FilePath NuGetPath { get; set; } 7 | 8 | public SquirrelRunnerFixture() : base("Squirrel.exe") { 9 | NuGetPath = "Package.nupkg"; 10 | } 11 | 12 | protected override void RunTool() { 13 | var tool = new SquirrelRunner(FileSystem, Environment, ProcessRunner, Tools); 14 | tool.Run(NuGetPath, Settings); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.Tests/Fixture/SyncReleasesRunnerFixture.cs: -------------------------------------------------------------------------------- 1 | using Cake.Testing.Fixtures; 2 | 3 | namespace Cake.Squirrel.Tests.Fixture { 4 | internal sealed class SyncReleasesRunnerFixture : ToolFixture { 5 | public SyncReleasesRunnerFixture() : base("SyncReleases.exe") { } 6 | 7 | protected override void RunTool() { 8 | var tool = new SyncReleasesRunner(FileSystem, Environment, ProcessRunner, Tools); 9 | tool.Run(Settings); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.Tests/SquirrelAliasesTests.cs: -------------------------------------------------------------------------------- 1 | using Cake.Squirrel.Tests.Fixture; 2 | using System; 3 | using Xunit; 4 | using NSubstitute; 5 | using Cake.Core; 6 | using FluentAssertions; 7 | 8 | namespace Cake.Squirrel.Tests { 9 | public class SquirrelAliasesTests { 10 | [Fact] 11 | public void Should_Throw_If_Context_Is_Null() { 12 | // Given 13 | var fixture = new SquirrelRunnerFixture(); 14 | 15 | // When 16 | var result = Record.Exception(() => SquirrelAliases.Squirrel(null, fixture.NuGetPath, fixture.Settings)); 17 | 18 | // Then 19 | result.Should().BeOfType().Subject.ParamName.Should().Equals("context"); 20 | } 21 | 22 | [Fact] 23 | public void Should_Throw_If_NuGet_Package_Is_Null() { 24 | // Given 25 | var fixture = new SquirrelRunnerFixture(); 26 | var context = Substitute.For(); 27 | 28 | // When 29 | var result = Record.Exception(() => SquirrelAliases.Squirrel(context, null, fixture.Settings)); 30 | 31 | // Then 32 | result.Should().BeOfType().Subject.ParamName.Should().Equals("nugetPackage"); 33 | } 34 | 35 | [Fact] 36 | public void Should_Throw_If_Settings_Are_Null() { 37 | // Given 38 | var fixture = new SquirrelRunnerFixture(); 39 | var context = Substitute.For(); 40 | 41 | // When 42 | var result = Record.Exception(() => SquirrelAliases.Squirrel(context, fixture.NuGetPath, null)); 43 | 44 | // Then 45 | result.Should().BeOfType().Subject.ParamName.Should().Equals("settings"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.Tests/SquirrelRunnerTests.cs: -------------------------------------------------------------------------------- 1 | using Cake.Squirrel.Tests.Fixture; 2 | using System; 3 | using Xunit; 4 | using Cake.Core; 5 | using Cake.Testing; 6 | using FluentAssertions; 7 | 8 | namespace Cake.Squirrel.Tests { 9 | public class SquirrelRunnerTests { 10 | [Fact] 11 | public void Should_Throw_NuGet_Package_Is_Null() { 12 | // Given 13 | var fixture = new SquirrelRunnerFixture(); 14 | fixture.NuGetPath = null; 15 | 16 | // When 17 | var result = Record.Exception(() => fixture.Run()); 18 | 19 | // Then 20 | result.Should().BeOfType().Subject.ParamName.Should().Equals("nugetPackage"); 21 | } 22 | 23 | [Fact] 24 | public void Should_Throw_If_Settings_Are_Null() { 25 | // Given 26 | var fixture = new SquirrelRunnerFixture(); 27 | fixture.Settings = null; 28 | 29 | // When 30 | var result = Record.Exception(() => fixture.Run()); 31 | 32 | // Then 33 | result.Should().BeOfType().Subject.ParamName.Should().Equals("settings"); 34 | } 35 | 36 | [Fact] 37 | public void Should_Throw_If_Squirrel_Executable_Was_Not_Found() { 38 | // Given 39 | var fixture = new SquirrelRunnerFixture(); 40 | fixture.GivenDefaultToolDoNotExist(); 41 | 42 | // When 43 | var result = Record.Exception(() => fixture.Run()); 44 | 45 | // Then 46 | result.Should().BeOfType().Subject.Message.Should().Equals("Squirrel: Could not locate executable."); 47 | } 48 | 49 | [Theory] 50 | [InlineData("/bin/tools/Squirrel/Squirrel.exe", "/bin/tools/Squirrel/Squirrel.exe")] 51 | [InlineData("./tools/Squirrel/Squirrel.exe", "/Working/tools/Squirrel/Squirrel.exe")] 52 | public void Should_Use_Squirrel_Executable_From_Tool_Path_If_Provided(string toolPath, string expected) { 53 | // Given 54 | var fixture = new SquirrelRunnerFixture(); 55 | fixture.Settings.ToolPath = toolPath; 56 | fixture.GivenSettingsToolPathExist(); 57 | 58 | // When 59 | var result = fixture.Run(); 60 | 61 | // Then 62 | result.Path.FullPath.Should().Equals(expected); 63 | } 64 | 65 | [Fact] 66 | public void Should_Throw_If_Process_Was_Not_Started() { 67 | // Given 68 | var fixture = new SquirrelRunnerFixture(); 69 | fixture.GivenProcessCannotStart(); 70 | 71 | // When 72 | var result = Record.Exception(() => fixture.Run()); 73 | 74 | // Then 75 | result.Should().BeOfType().Subject.Message.Should().Equals("Squirrel: Process was not started."); 76 | } 77 | 78 | [Fact] 79 | public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() { 80 | // Given 81 | var fixture = new SquirrelRunnerFixture(); 82 | fixture.GivenProcessExitsWithCode(1); 83 | 84 | // When 85 | var result = Record.Exception(() => fixture.Run()); 86 | 87 | // Then 88 | result.Should().BeOfType() 89 | .Subject.Message.Should().Equals("Squirrel: Process returned an error (exit code 1)."); 90 | } 91 | 92 | [Fact] 93 | public void Should_Find_Squirrel_Executable_If_Tool_Path_Not_Provided() { 94 | // Given 95 | var fixture = new SquirrelRunnerFixture(); 96 | 97 | // When 98 | var result = fixture.Run(); 99 | 100 | // Then 101 | result.Path.FullPath.Should().Equals("/Working/tools/Squirrel.exe"); 102 | } 103 | 104 | [Fact] 105 | public void Should_Add_NuGet_Package_To_Arguments() { 106 | // Given 107 | var fixture = new SquirrelRunnerFixture(); 108 | 109 | // When 110 | var result = fixture.Run(); 111 | 112 | // Then 113 | result.Args.Should().Equals("--releasify \"Package.nupkg\""); 114 | } 115 | 116 | [Fact] 117 | public void Should_Include_No_Delta_Flag_To_Arguments() 118 | { 119 | // Given 120 | var fixture = new SquirrelRunnerFixture(); 121 | 122 | // When 123 | fixture.Settings.NoDelta = true; 124 | var result = fixture.Run(); 125 | 126 | // Then 127 | result.Args.Should().Equals("--releasify \"Package.nupkg\" --no-delta"); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.Tests/SyncReleasesRunnerTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Cake.Core; 3 | using Cake.Squirrel.Tests.Fixture; 4 | using Cake.Testing; 5 | using FluentAssertions; 6 | using Xunit; 7 | 8 | namespace Cake.Squirrel.Tests { 9 | public class SyncReleasesRunnerTests { 10 | [Fact] 11 | public void Should_Throw_If_Settings_Are_Null() { 12 | // Given 13 | var fixture = new SyncReleasesRunnerFixture(); 14 | fixture.Settings = null; 15 | 16 | // When 17 | var result = Record.Exception(() => fixture.Run()); 18 | 19 | // Then 20 | result.Should().BeOfType().Subject.ParamName.Should().Equals("settings"); 21 | } 22 | 23 | [Fact] 24 | public void Should_Throw_If_SyncReleasesl_Executable_Was_Not_Found() { 25 | // Given 26 | var fixture = new SyncReleasesRunnerFixture(); 27 | fixture.GivenDefaultToolDoNotExist(); 28 | 29 | // When 30 | var result = Record.Exception(() => fixture.Run()); 31 | 32 | // Then 33 | result.Should().BeOfType().Subject.Message.Should().Equals("SyncReleases: Could not locate executable."); 34 | } 35 | 36 | [Theory] 37 | [InlineData("/bin/tools/Squirrel/SyncReleases.exe", "/bin/tools/Squirrel/SyncReleases.exe")] 38 | [InlineData("./tools/Squirrel/SyncReleases.exe", "/Working/tools/Squirrel/SyncReleases.exe")] 39 | public void Should_Use_SyncReleases_Executable_From_Tool_Path_If_Provided(string toolPath, string expected) { 40 | // Given 41 | var fixture = new SyncReleasesRunnerFixture(); 42 | fixture.Settings.ToolPath = toolPath; 43 | fixture.GivenSettingsToolPathExist(); 44 | 45 | // When 46 | var result = fixture.Run(); 47 | 48 | // Then 49 | result.Path.FullPath.Should().Equals(expected); 50 | } 51 | 52 | [Fact] 53 | public void Should_Throw_If_Process_Was_Not_Started() { 54 | // Given 55 | var fixture = new SyncReleasesRunnerFixture(); 56 | fixture.GivenProcessCannotStart(); 57 | 58 | // When 59 | var result = Record.Exception(() => fixture.Run()); 60 | 61 | // Then 62 | result.Should().BeOfType().Subject.Message.Should().Equals("SyncReleases: Process was not started."); 63 | } 64 | 65 | [Fact] 66 | public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() { 67 | // Given 68 | var fixture = new SyncReleasesRunnerFixture(); 69 | fixture.GivenProcessExitsWithCode(1); 70 | 71 | // When 72 | var result = Record.Exception(() => fixture.Run()); 73 | 74 | // Then 75 | result.Should().BeOfType() 76 | .Subject.Message.Should().Equals("SyncReleases: Process returned an error (exit code 1)."); 77 | } 78 | 79 | [Fact] 80 | public void Should_Find_SyncReleases_Executable_If_Tool_Path_Not_Provided() { 81 | // Given 82 | var fixture = new SyncReleasesRunnerFixture(); 83 | 84 | // When 85 | var result = fixture.Run(); 86 | 87 | // Then 88 | result.Path.FullPath.Should().Equals("/Working/tools/SyncReleases.exe"); 89 | } 90 | 91 | [Fact] 92 | public void Should_Add_Url_To_Arguments() { 93 | // Given 94 | var fixture = new SyncReleasesRunnerFixture(); 95 | fixture.Settings.Url = "https://google.com"; 96 | 97 | // When 98 | var result = fixture.Run(); 99 | 100 | // Then 101 | result.Args.Should().Equals("--url https://google.com"); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/Cake.Squirrel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2036 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Squirrel", "Cake.Squirrel\Cake.Squirrel.csproj", "{A6EEBD31-93F0-4F23-BB14-6386FE945D95}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Squirrel.Tests", "Cake.Squirrel.Tests\Cake.Squirrel.Tests.csproj", "{4E611C92-9587-425D-9628-94F8EE47C027}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A6EEBD31-93F0-4F23-BB14-6386FE945D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {A6EEBD31-93F0-4F23-BB14-6386FE945D95}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {A6EEBD31-93F0-4F23-BB14-6386FE945D95}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {A6EEBD31-93F0-4F23-BB14-6386FE945D95}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {4E611C92-9587-425D-9628-94F8EE47C027}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {4E611C92-9587-425D-9628-94F8EE47C027}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {4E611C92-9587-425D-9628-94F8EE47C027}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {4E611C92-9587-425D-9628-94F8EE47C027}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E7F88D57-C60D-4255-8C03-0D4717506DAC} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /src/Cake.Squirrel/Cake.Squirrel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | Jamie Phillips 10 | Copyright © 2015-$([System.DateTime]::Now.Year) - Jamie Phillips 11 | Cake Addin to Add Squirrel.Windows support. 12 | https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png 13 | Apache-2.0 14 | https://github.com/cake-contrib/Cake.Squirrel 15 | Cake;Script;Build;Squirrel 16 | $(PackageProjectUrl).git 17 | git 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Cake.Squirrel/SquirrelAliases.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Cake.Core; 3 | using Cake.Core.Annotations; 4 | using Cake.Core.IO; 5 | 6 | namespace Cake.Squirrel { 7 | /// 8 | /// Contains functionality related to running Squirrel. 9 | /// 10 | [CakeAliasCategory("Squirrel")] 11 | public static class SquirrelAliases 12 | { 13 | /// 14 | /// Runs Squirrel Releasify against the specified NuGet package. 15 | /// 16 | /// 17 | /// 18 | /// #tool "Squirrel.Windows" 19 | /// #addin Cake.Squirrel 20 | /// 21 | /// Task("PackageNoSettings") 22 | /// .Does(() => { 23 | /// Squirrel(File("Package.nupkg")); 24 | /// }); 25 | /// 26 | /// 27 | /// The context. 28 | /// NuGet package to releasify. 29 | [CakeMethodAlias] 30 | public static void Squirrel(this ICakeContext context, FilePath nugetPackage) { 31 | Squirrel(context, nugetPackage, new SquirrelSettings()); 32 | } 33 | 34 | /// 35 | /// Runs Squirrel Releasify against the specified NuGet package 36 | /// using the specified settings. 37 | /// 38 | /// 39 | /// 40 | /// #tool "Squirrel.Windows" 41 | /// #addin Cake.Squirrel 42 | /// 43 | /// Task("PackageWithSettings") 44 | /// .Does(() => { 45 | /// var settings = new SquirrelSettings(); 46 | /// settings.NoMsi = true; 47 | /// settings.Silent = true; 48 | /// 49 | /// Squirrel(File("Package.nupkg"), settings); 50 | /// }); 51 | /// 52 | /// 53 | /// The context. 54 | /// NuGet package to releasify. 55 | /// The settings. 56 | [CakeMethodAlias] 57 | public static void Squirrel(this ICakeContext context, FilePath nugetPackage, SquirrelSettings settings) { 58 | if (context == null) { 59 | throw new ArgumentNullException(nameof(context)); 60 | } 61 | var runner = new SquirrelRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); 62 | runner.Run(nugetPackage, settings); 63 | } 64 | 65 | /// 66 | /// Runs Squirrel Releasify against the specified NuGet package 67 | /// using the specified settings, if output should be redirected, and 68 | /// if it should be silent. 69 | /// 70 | /// 71 | /// 72 | /// #tool "Squirrel.Windows" 73 | /// #addin Cake.Squirrel 74 | /// 75 | /// Task("PackageWithSettings") 76 | /// .Does(() => { 77 | /// var settings = new SquirrelSettings(); 78 | /// settings.NoMsi = true; 79 | /// settings.Silent = true; 80 | /// 81 | /// Squirrel(File("Package.nupkg"), settings, true, false); 82 | /// }); 83 | /// 84 | /// 85 | /// The context. 86 | /// NuGet package to releasify. 87 | /// The settings. 88 | /// Sets if the output of an tool is written to the stream. 89 | /// Sets if the tool output should be suppressed. 90 | [CakeMethodAlias] 91 | public static void Squirrel(this ICakeContext context, FilePath nugetPackage, SquirrelSettings settings, bool redirectStandardOutput, bool silent) { 92 | if (context == null) { 93 | throw new ArgumentNullException(nameof(context)); 94 | } 95 | var runner = new SquirrelRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); 96 | runner.Run(nugetPackage, settings, new ProcessSettings { RedirectStandardOutput = redirectStandardOutput, Silent = silent }); 97 | } 98 | 99 | /// 100 | /// Runs SyncReleases using the specified settings. 101 | /// 102 | /// 103 | /// 104 | /// #tool "Squirrel.Windows" 105 | /// #addin Cake.Squirrel 106 | /// 107 | /// Task("SyncReleases") 108 | /// .Does(() => { 109 | /// var settings = new SyncReleasesSettings { 110 | /// ReleaseDirectory = "pathToDirectory" 111 | /// Url = new Uri("https://someurl.com"); 112 | /// Token = "myToken" 113 | /// }; 114 | /// 115 | /// SyncReleases(settings); 116 | /// }); 117 | /// 118 | /// 119 | /// The context. 120 | /// The settings. 121 | [CakeMethodAlias] 122 | public static void SyncReleases(this ICakeContext context, SyncReleasesSettings settings) 123 | { 124 | if (context == null) 125 | { 126 | throw new ArgumentNullException(nameof(context)); 127 | } 128 | var runner = new SyncReleasesRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); 129 | runner.Run(settings); 130 | } 131 | 132 | /// 133 | /// Runs SyncReleases using the specified settings, if output should be redirected, and 134 | /// if it should be silent. 135 | /// 136 | /// 137 | /// 138 | /// #tool "Squirrel.Windows" 139 | /// #addin Cake.Squirrel 140 | /// 141 | /// Task("SyncReleases") 142 | /// .Does(() => { 143 | /// var settings = new SyncReleasesSettings { 144 | /// ReleaseDirectory = "pathToDirectory" 145 | /// Url = new Uri("https://someurl.com"); 146 | /// Token = "myToken" 147 | /// }; 148 | /// 149 | /// SyncReleases(settings, true, false); 150 | /// }); 151 | /// 152 | /// 153 | /// The context. 154 | /// The settings. 155 | /// Sets if the output of an tool is written to the stream. 156 | /// Sets if the tool output should be suppressed. 157 | [CakeMethodAlias] 158 | public static void SyncReleases(this ICakeContext context, SyncReleasesSettings settings, bool redirectStandardOutput, bool silent) 159 | { 160 | if (context == null) 161 | { 162 | throw new ArgumentNullException(nameof(context)); 163 | } 164 | var runner = new SyncReleasesRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); 165 | runner.Run(settings, new ProcessSettings { RedirectStandardOutput = redirectStandardOutput, Silent = silent }); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/Cake.Squirrel/SquirrelRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Cake.Core; 4 | using Cake.Core.IO; 5 | using Cake.Core.Tooling; 6 | 7 | namespace Cake.Squirrel { 8 | /// 9 | /// The Squirrel package runner. 10 | /// 11 | public class SquirrelRunner : Tool { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | public SquirrelRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IToolLocator tools) 20 | : base(fileSystem, environment, processRunner, tools) { 21 | 22 | } 23 | /// 24 | /// Executes Squirrel with the specificed parameters. 25 | /// 26 | /// The nuget package. 27 | /// The settings. 28 | public void Run(FilePath nugetPackage, SquirrelSettings settings) { 29 | if (nugetPackage == null) { 30 | throw new ArgumentNullException(nameof(nugetPackage)); 31 | } 32 | 33 | if (settings == null) { 34 | throw new ArgumentNullException(nameof(settings)); 35 | } 36 | 37 | Run(settings, GetArguments(nugetPackage, settings)); 38 | } 39 | 40 | /// 41 | /// Executes Squirrel with the specificed parameters. 42 | /// 43 | /// The nuget package. 44 | /// The settings. 45 | /// The process settings. 46 | public void Run(FilePath nugetPackage, SquirrelSettings settings, ProcessSettings processSettings) { 47 | if (nugetPackage == null) { 48 | throw new ArgumentNullException(nameof(nugetPackage)); 49 | } 50 | 51 | if (settings == null) { 52 | throw new ArgumentNullException(nameof(settings)); 53 | } 54 | if (settings == null) { 55 | throw new ArgumentNullException(nameof(processSettings)); 56 | } 57 | Run(settings, GetArguments(nugetPackage, settings), processSettings, null); 58 | } 59 | 60 | 61 | private ProcessArgumentBuilder GetArguments(FilePath nugetPackage, SquirrelSettings settings) { 62 | var builder = new ProcessArgumentBuilder(); 63 | builder.Append("--releasify \"{0}\"", nugetPackage.FullPath); 64 | if (settings.ReleaseDirectory != null) { 65 | builder.Append("--releaseDir {0}", settings.ReleaseDirectory.FullPath); 66 | } 67 | if (settings.PackagesDirectory != null) { 68 | builder.Append("--packagesDir {0}", settings.PackagesDirectory.FullPath); 69 | } 70 | if (settings.BootstrapperExe != null) { 71 | builder.Append("--bootstrapperExe {0}", settings.BootstrapperExe.FullPath); 72 | } 73 | if (settings.LoadingGif != null) { 74 | builder.Append("--loadingGif {0}", settings.LoadingGif.FullPath); 75 | } 76 | if (settings.Icon != null) { 77 | builder.Append("--icon {0}", settings.Icon.FullPath); 78 | } 79 | if (settings.SetupIcon != null) { 80 | builder.Append("--setupIcon {0}", settings.SetupIcon.FullPath); 81 | } 82 | if (!string.IsNullOrEmpty(settings.SigningParameters)) { 83 | builder.Append("--signWithParams \"{0}\"", settings.SigningParameters); 84 | } 85 | if (settings.Silent) { 86 | builder.Append("--silent"); 87 | } 88 | if (settings.NoMsi) { 89 | builder.Append("--no-msi"); 90 | } 91 | if (!string.IsNullOrWhiteSpace(settings.FrameworkVersion)) { 92 | builder.Append("--framework-version {0}", settings.FrameworkVersion); 93 | } 94 | if (settings.NoDelta) { 95 | builder.Append("--no-delta"); 96 | } 97 | return builder; 98 | } 99 | 100 | /// 101 | /// Gets the name of the tool. 102 | /// 103 | /// The name of the tool. 104 | protected override IEnumerable GetToolExecutableNames() { 105 | return new[] { "Squirrel.exe" }; 106 | } 107 | 108 | /// 109 | /// Gets the possible names of the tool executable. 110 | /// 111 | /// List of possible executable names. 112 | protected override string GetToolName() { 113 | return "Squirrel"; 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/Cake.Squirrel/SquirrelSettings.cs: -------------------------------------------------------------------------------- 1 | using Cake.Core.IO; 2 | using Cake.Core.Tooling; 3 | 4 | namespace Cake.Squirrel { 5 | /// 6 | /// Contains settings used by . 7 | /// 8 | public class SquirrelSettings : ToolSettings { 9 | /// 10 | /// Initializes a new instance of the class. 11 | /// 12 | public SquirrelSettings() {} 13 | 14 | /// 15 | /// Gets or sets the release directory location. 16 | /// 17 | /// 18 | /// Path to a release directory to use with releasify. 19 | /// 20 | public DirectoryPath ReleaseDirectory { get; set; } 21 | 22 | /// 23 | /// Gets or sets the packages directory location. 24 | /// 25 | /// 26 | /// Path to the NuGet Packages directory for C# apps 27 | /// 28 | public DirectoryPath PackagesDirectory { get; set; } 29 | 30 | /// 31 | /// Gets or sets the Setup.exe for boostrapping. 32 | /// 33 | /// 34 | /// Path to the Setup.exe to use as a template 35 | /// 36 | public DirectoryPath BootstrapperExe { get; set; } 37 | 38 | /// 39 | /// Gets or sets the filepath to the loading gif. 40 | /// 41 | /// 42 | /// Path to an animated GIF to be displayed during installation. 43 | /// 44 | public FilePath LoadingGif { get; set; } 45 | 46 | /// 47 | /// Gets or sets the filepath to the icon for shortcuts. 48 | /// 49 | /// 50 | /// Path to an ICO file that will be used for icon shortcuts. 51 | /// 52 | public FilePath Icon { get; set; } 53 | 54 | /// 55 | /// Gets or sets the filepath to the setup executable's icon. 56 | /// 57 | /// 58 | /// Path to an ICO file that will be used for the Setup executable's icon. 59 | /// 60 | public FilePath SetupIcon { get; set; } 61 | 62 | /// 63 | /// Gets or sets the parameters to be passed to SignTool.exe. 64 | /// 65 | /// 66 | /// Sign the installer via SignTool.exe with the parameters given 67 | /// 68 | public string SigningParameters { get; set; } 69 | 70 | /// 71 | /// Gets or sets if it should be a silent install. 72 | /// 73 | /// 74 | /// true if a silent install; otherwise, false. 75 | /// 76 | public bool Silent { get; set; } 77 | 78 | /// 79 | /// Gets or sets shortcut locations. 80 | /// 81 | /// 82 | /// Comma-separated string of shortcut locations, e.g. 'Desktop,StartMenu'. 83 | /// 84 | public string ShortCutLocations { get; set; } 85 | 86 | /// 87 | /// Gets or sets if an MSI package should be created. 88 | /// 89 | /// 90 | /// true to not generate an MSI package; otherwise, false. 91 | /// 92 | public bool NoMsi { get; set; } 93 | 94 | /// 95 | /// Gets or sets the required .NET framework version 96 | /// 97 | /// 98 | /// .NET framework version, e.g. net461 99 | /// 100 | public string FrameworkVersion { get; set; } 101 | 102 | /// 103 | /// Gets or sets Don't generate delta packages to save time. 104 | /// 105 | /// 106 | /// true to not generate delta packages; otherwise, false. 107 | /// 108 | public bool NoDelta { get; set; } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Cake.Squirrel/SyncReleasesRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Cake.Core; 4 | using Cake.Core.IO; 5 | using Cake.Core.Tooling; 6 | 7 | namespace Cake.Squirrel { 8 | /// 9 | /// The SyncReleases runner. 10 | /// 11 | public class SyncReleasesRunner : Tool { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The file system. 16 | /// The environment. 17 | /// The process runner. 18 | /// The tool locator. 19 | public SyncReleasesRunner(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, 20 | IToolLocator tools) : base(fileSystem, environment, processRunner, tools) { } 21 | 22 | /// 23 | /// Executes SyncReleases with the specificed parameters. 24 | /// 25 | /// The settings. 26 | public void Run(SyncReleasesSettings settings) { 27 | if (settings == null) { 28 | throw new ArgumentNullException(nameof(settings)); 29 | } 30 | 31 | Run(settings, GetArguments(settings)); 32 | } 33 | 34 | /// 35 | /// Executes SyncReleases with the specificed parameters. 36 | /// 37 | /// The settings. 38 | /// The process settings. 39 | public void Run(SyncReleasesSettings settings, ProcessSettings processSettings) { 40 | if (settings == null) { 41 | throw new ArgumentNullException(nameof(settings)); 42 | } 43 | if (settings == null) { 44 | throw new ArgumentNullException(nameof(processSettings)); 45 | } 46 | Run(settings, GetArguments(settings), processSettings, null); 47 | } 48 | 49 | private ProcessArgumentBuilder GetArguments(SyncReleasesSettings settings) { 50 | var builder = new ProcessArgumentBuilder(); 51 | if (settings.ReleaseDirectory != null) { 52 | builder.Append("--releaseDir {0}", settings.ReleaseDirectory.FullPath); 53 | } 54 | if (!string.IsNullOrWhiteSpace(settings.Url)) { 55 | builder.Append("--url {0}", settings.Url); 56 | } 57 | if (!string.IsNullOrWhiteSpace(settings.Token)) { 58 | builder.Append("--token {0}", settings.Token); 59 | } 60 | 61 | return builder; 62 | } 63 | 64 | /// 65 | /// Gets the name of the tool. 66 | /// 67 | /// The name of the tool. 68 | protected override string GetToolName() { 69 | return "SyncReleases"; 70 | } 71 | 72 | /// 73 | /// Gets the possible names of the tool executable. 74 | /// 75 | /// List of possible executable names. 76 | protected override IEnumerable GetToolExecutableNames() { 77 | return new[] {"SyncReleases.exe"}; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Cake.Squirrel/SyncReleasesSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Cake.Core.IO; 3 | using Cake.Core.Tooling; 4 | 5 | namespace Cake.Squirrel { 6 | /// 7 | /// Contains settings used by . 8 | /// 9 | public class SyncReleasesSettings : ToolSettings { 10 | /// 11 | /// Gets or sets the release directory path to download to. 12 | /// 13 | public DirectoryPath ReleaseDirectory { get; set; } 14 | 15 | /// 16 | /// Gets or sets the URL to the remote releases folder. When pointing to GitHub, use the URL 17 | /// to the repository root page, else point to an existing remote Releases folder 18 | /// 19 | public string Url { get; set; } 20 | 21 | /// 22 | /// Gets or sets the OAth token to use as login credentials. 23 | /// 24 | public string Token { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tools/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | --------------------------------------------------------------------------------