-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2076 from vbfox/squirell_v5
Squirell for FAKE v5
- Loading branch information
Showing
9 changed files
with
235 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Releasifying NuGet packages with Squirrel | ||
|
||
<div class="alert alert-info"> | ||
<h5>INFO</h5> | ||
<p>This documentation is for FAKE version 5.0 or later.</p> | ||
</div> | ||
|
||
[Squirrel.Windows](https://github.com/Squirrel/Squirrel.Windows) is an installation an auto-update system for Windows desktop apps. | ||
|
||
[API-Reference](apidocs/v5/fake-installer-squirrel.html) | ||
|
||
## Squirrel.exe CLI tool | ||
|
||
This module is a wrapper around the [Squirrel.exe](https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/squirrel-command-line.md) CLI tool that is available in the [squirrel.windows](https://www.nuget.org/packages/squirrel.windows/) NuGet package. | ||
|
||
## Releasify | ||
|
||
[Releasifying](https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/getting-started/2-packaging.md#releasifying) create all files necessary for release from a NuGet package | ||
|
||
```fsharp | ||
open Fake.Installer | ||
Squirrel.releasify "./my.nupkg" (fun p -> { p with ReleaseDir = "./squirrel_release") | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("FAKE - F# Make Squirrel for windows Squirrel.exe tool helper")>] | ||
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>] | ||
[<assembly: AssemblyVersionAttribute("5.3.1")>] | ||
[<assembly: AssemblyInformationalVersionAttribute("5.3.1-alpha")>] | ||
[<assembly: AssemblyFileVersionAttribute("5.3.1")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "FAKE - F# Make Squirrel for windows Squirrel.exe tool helper" | ||
let [<Literal>] AssemblyProduct = "FAKE - F# Make" | ||
let [<Literal>] AssemblyVersion = "5.3.1" | ||
let [<Literal>] AssemblyInformationalVersion = "5.3.1-alpha" | ||
let [<Literal>] AssemblyFileVersion = "5.3.1" |
24 changes: 24 additions & 0 deletions
24
src/app/Fake.Installer.Squirrel/Fake.Installer.Squirrel.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net46;netstandard1.6;netstandard2.0</TargetFrameworks> | ||
<DefineConstants>$(DefineConstants);NO_DOTNETCORE_BOOTSTRAP</DefineConstants> | ||
<AssemblyName>Fake.Installer.Squirrel</AssemblyName> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="Squirrel.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Fake.Core.Environment\Fake.Core.Environment.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Process\Fake.Core.Process.fsproj" /> | ||
<ProjectReference Include="..\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/// Contains types and utility functions related to creating [Squirrel](https://github.com/Squirrel/Squirrel.Windows) installer. | ||
[<RequireQualifiedAccess>] | ||
module Fake.Installer.Squirrel | ||
|
||
open Fake.Core | ||
open Fake.IO | ||
open Fake.IO.FileSystemOperators | ||
open Fake.IO.Globbing | ||
open System | ||
open System.IO | ||
open System.Text | ||
|
||
/// The [Squirrel](https://github.com/Squirrel/Squirrel.Windows) Console Parameters type. | ||
/// | ||
/// For reference, see: [Squirrel Command Line Options](https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/advanced-releasify.md) | ||
type ReleasifyParams = { | ||
/// The output directory for the generated installer | ||
ReleaseDir : string | ||
|
||
/// The working directory. | ||
WorkingDir : string option | ||
|
||
/// The full path to an optional setup.exe template | ||
BootstrapperExe : string option | ||
|
||
/// The full path to an optional animated gif to be displayed during installation | ||
LoadingGif : string option | ||
|
||
/// The full path to an optional icon, which will be used for the generated installer. | ||
SetupIcon : string option | ||
|
||
/// Do not create an MSI file | ||
NoMsi : bool | ||
|
||
/// The path to Squirrel: `squirrel.exe` | ||
ToolPath : string | ||
|
||
/// Maximum time to allow Squirrel to run before being killed. | ||
TimeOut : TimeSpan | ||
|
||
/// Sign the installer with signtool.exe | ||
SignExecutable : bool option | ||
|
||
/// The code signing certificate to be used for signing | ||
SigningKeyFile : string option | ||
|
||
/// The secret key for the code signing certificate | ||
SigningSecret : string option | ||
} | ||
|
||
let internal defaultParams = lazy( | ||
let toolname = "Squirrel.exe" | ||
{ ReleaseDir = "" | ||
WorkingDir = None | ||
BootstrapperExe = None | ||
LoadingGif = None | ||
SetupIcon = None | ||
NoMsi = false | ||
ToolPath = Tools.findToolInSubPath toolname ( Directory.GetCurrentDirectory() </> "tools" </> "Squirrel") | ||
TimeOut = TimeSpan.FromMinutes 10. | ||
SignExecutable = None | ||
SigningKeyFile = None | ||
SigningSecret = None }) | ||
|
||
let private createSigningArgs (parameters : ReleasifyParams) = | ||
new StringBuilder() | ||
|> StringBuilder.appendWithoutQuotes "--signWithParams=\"" | ||
|> StringBuilder.appendWithoutQuotes "/a" | ||
|> StringBuilder.appendIfSome parameters.SigningKeyFile (sprintf "/f %s") | ||
|> StringBuilder.appendIfSome parameters.SigningSecret (sprintf "/p %s") | ||
|> StringBuilder.appendWithoutQuotes "\"" | ||
|> StringBuilder.toText | ||
|
||
let internal buildSquirrelArgs parameters nugetPackage = | ||
new StringBuilder() | ||
|> StringBuilder.appendIfNotNullOrEmpty nugetPackage "--releasify=" | ||
|> StringBuilder.appendIfNotNullOrEmpty parameters.ReleaseDir "--releaseDir=" | ||
|> StringBuilder.appendIfSome parameters.LoadingGif (sprintf "\"--loadingGif=%s\"") | ||
|> StringBuilder.appendIfSome parameters.SetupIcon (sprintf "\"--setupIcon=%s\"") | ||
|> StringBuilder.appendIfTrue parameters.NoMsi "--no-msi" | ||
|> StringBuilder.appendIfSome parameters.BootstrapperExe (sprintf "\"--bootstrapperExe=%s\"") | ||
|> StringBuilder.appendIfSome parameters.SignExecutable (fun _ -> createSigningArgs parameters) | ||
|> StringBuilder.toText | ||
|
||
module internal ResultHandling = | ||
let (|OK|Failure|) = function | ||
| 0 -> OK | ||
| x -> Failure x | ||
|
||
let buildErrorMessage = function | ||
| OK -> None | ||
| Failure errorCode -> | ||
Some (sprintf "Squirrel reported an error (Error Code %d)" errorCode) | ||
|
||
let failBuildIfSquirrelReportedError = | ||
buildErrorMessage | ||
>> Option.iter failwith | ||
|
||
/// Creates a Squirrel installer for given NuGet package | ||
/// Will fail if Squirrel terminates with non-zero exit code. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `setParams` - Function used to manipulate the default `SquirrelParams` value. | ||
/// - `nugetPackage` - The package to create an installer for | ||
/// | ||
/// ## Sample usage | ||
/// | ||
/// Target.create "CreatePackage" (fun _ -> | ||
/// Squirrel.releasify "./my.nupkg" (fun p -> { p with ReleaseDir = "./squirrel_release") | ||
/// ) | ||
/// | ||
/// ## Defaults for setParams | ||
/// | ||
/// - `ReleaseDir` - `""` | ||
/// - `WorkingDir` - `None` | ||
/// - `BootstrapperExe` - `None` | ||
/// - `LoadingGif` - `None` | ||
/// - `SetupIcon` - `None` | ||
/// - `NoMsi` - `false` | ||
/// - `ToolPath` - The `squirrel.exe` path if it exists in a subdirectory of the current directory. | ||
/// - `TimeOut` - 10 minutes | ||
/// - `SignExecutable` - `None` | ||
/// - `SigningKeyFile` - `None` | ||
/// - `SigningSecret` - `None` | ||
let releasify (nugetPackage: string) (setParams: ReleasifyParams -> ReleasifyParams): unit = | ||
use __ = Trace.traceTask "Squirrel" nugetPackage | ||
let parameters = defaultParams.Value |> setParams | ||
let args = buildSquirrelArgs parameters nugetPackage | ||
Trace.tracefn "%s" args | ||
|
||
let result = | ||
Process.execSimple | ||
(fun info -> { info with | ||
FileName = parameters.ToolPath | ||
WorkingDirectory = defaultArg parameters.WorkingDir "." | ||
Arguments = args}) | ||
parameters.TimeOut | ||
|
||
ResultHandling.failBuildIfSquirrelReportedError result | ||
|
||
__.MarkSuccess() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters