Skip to content

Commit

Permalink
Merge pull request #1890 from kblohm/innoSetup
Browse files Browse the repository at this point in the history
Fake 5 InnoSetup Module
  • Loading branch information
matthid authored Apr 29, 2018
2 parents 47c2b0e + 78743d3 commit b7efb9f
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Fake.sln
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.JavaScript.Yarn", "src
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Sql.DacPac", "src/app/Fake.Sql.DacPac/Fake.Sql.DacPac.fsproj", "{3BC4A91C-3381-4BF9-BF11-8E06706CF878}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Installer.InnoSetup", "src/app/Fake.Installer.InnoSetup/Fake.Installer.InnoSetup.fsproj", "{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Testing.ReportGenerator", "src/app/Fake.Testing.ReportGenerator/Fake.Testing.ReportGenerator.fsproj", "{4E702236-A2B1-4920-B56D-4746CC0726D3}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.Testing.SpecFlow", "src/app/Fake.DotNet.Testing.SpecFlow/Fake.DotNet.Testing.SpecFlow.fsproj", "{DA58D728-C36A-4DC7-8D92-F2BA13667EA5}"
Expand Down Expand Up @@ -744,6 +746,18 @@ Global
{3BC4A91C-3381-4BF9-BF11-8E06706CF878}.Release|x64.Build.0 = Release|Any CPU
{3BC4A91C-3381-4BF9-BF11-8E06706CF878}.Release|x86.ActiveCfg = Release|Any CPU
{3BC4A91C-3381-4BF9-BF11-8E06706CF878}.Release|x86.Build.0 = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x64.ActiveCfg = Debug|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x64.Build.0 = Debug|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x86.ActiveCfg = Debug|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Debug|x86.Build.0 = Debug|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|Any CPU.Build.0 = Release|Any CPU
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x64.ActiveCfg = Release|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x64.Build.0 = Release|x64
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x86.ActiveCfg = Release|x86
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D}.Release|x86.Build.0 = Release|x86
{4E702236-A2B1-4920-B56D-4746CC0726D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E702236-A2B1-4920-B56D-4746CC0726D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E702236-A2B1-4920-B56D-4746CC0726D3}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -851,6 +865,7 @@ Global
{B636A082-4DB4-439D-8A37-E5214BDC00A3} = {901F162F-8925-4390-89C5-9EE2C343F744}
{DE7579F2-C20F-4C35-BC04-C10362912243} = {901F162F-8925-4390-89C5-9EE2C343F744}
{3BC4A91C-3381-4BF9-BF11-8E06706CF878} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{3C27E2CA-98DC-40ED-B334-87B84D7F3E0D} = {901F162F-8925-4390-89C5-9EE2C343F744}
{4E702236-A2B1-4920-B56D-4746CC0726D3} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{DA58D728-C36A-4DC7-8D92-F2BA13667EA5} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{2EC1798B-3AD5-42FE-9406-F358B995ACC3} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
Expand Down
3 changes: 2 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ let dotnetAssemblyInfos =
"Fake.Testing.ReportGenerator", "Convert XML coverage output to various formats"
"Fake.DotNet.Testing.OpenCover", "Code coverage with OpenCover"
"Fake.Sql.DacPac", "Sql Server Data Tools DacPac operations"
"Fake.Documentation.DocFx", "Documentation with DocFx" ]
"Fake.Documentation.DocFx", "Documentation with DocFx"
"Fake.Installer.InnoSetup", "Creating installers with InnoSetup" ]

let assemblyInfos =
[ legacyDir </> "FAKE/AssemblyInfo.fs",
Expand Down
6 changes: 6 additions & 0 deletions help/templates/template.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@
<li><a href="@(prefix)apidocs/fake-javascript-yarn.html">Yarn</a></li>
</ul>
</li>
<li>
<a href="@(prefix)apidocs/index.html#Fake.Installer">Installer</a>
<ul>
<li><a href="@(prefix)apidocs/fake-installer-innosetup.html">InnoSetup</a></li>
</ul>
</li>
<li>
<a href="@(prefix)apidocs/index.html#Fake">Legacy / Not Migrated</a>
<ul>
Expand Down
17 changes: 17 additions & 0 deletions src/app/Fake.Installer.InnoSetup/AssemblyInfo.fs
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 Creating installers with InnoSetup")>]
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>]
[<assembly: AssemblyVersionAttribute("5.0.0")>]
[<assembly: AssemblyInformationalVersionAttribute("5.0.0-rc007")>]
[<assembly: AssemblyFileVersionAttribute("5.0.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "FAKE - F# Make Creating installers with InnoSetup"
let [<Literal>] AssemblyProduct = "FAKE - F# Make"
let [<Literal>] AssemblyVersion = "5.0.0"
let [<Literal>] AssemblyInformationalVersion = "5.0.0-rc007"
let [<Literal>] AssemblyFileVersion = "5.0.0"
22 changes: 22 additions & 0 deletions src/app/Fake.Installer.InnoSetup/Fake.Installer.InnoSetup.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFrameworks>net46;netstandard1.6;netstandard2.0</TargetFrameworks>
<AssemblyName>Fake.Installer.InnoSetup</AssemblyName>
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="InnoSetup.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fake.Core.Process\Fake.Core.Process.fsproj" />
<ProjectReference Include="..\Fake.Core.String\Fake.Core.String.fsproj" />
<ProjectReference Include="..\Fake.Core.Trace\Fake.Core.Trace.fsproj" />
<ProjectReference Include="..\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" />
</ItemGroup>
<Import Project="..\..\..\.paket\Paket.Restore.targets" />
</Project>
124 changes: 124 additions & 0 deletions src/app/Fake.Installer.InnoSetup/InnoSetup.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@

/// This module contains helper functions to create [Inno Setup](http://www.jrsoftware.org/isinfo.php) installers.
[<RequireQualifiedAccess>]
module Fake.Installer.InnoSetup

open System
open System.IO
open Fake.Core
open Fake.IO
open Fake.IO.Globbing
open Fake.IO.FileSystemOperators
open System.Text

let private toolPath =
let innoExe = "ISCC.exe"
let toolPath = Tools.findToolInSubPath innoExe (Directory.GetCurrentDirectory() @@ "tools" @@ "Tools.InnoSetup" @@ "tools")
if File.exists toolPath then toolPath
else
match Process.tryFindFileOnPath innoExe with
| Some inno when File.exists inno -> inno
| _ -> toolPath

let private timeout = TimeSpan.FromMinutes 5.

/// Output verbosity
type QuietMode =
| Default /// Default output when compiling
| Quiet /// Quiet compile (print error messages only)
| QuietAndProgress /// Enable quiet compile while still displaying progress
/// InnoSetup build parameters
type InnoSetupParams =
{
/// The tool path - FAKE tries to find ISCC.exe automatically in any sub folder.
ToolPath : string

/// Specify the process working directory
WorkingDirectory : string

/// Specify a timeout for ISCC. Default: 5 min.
Timeout : TimeSpan

/// Enable or disable output (overrides Output)
EnableOutput : bool option

/// Output files to specified path (overrides OutputDir)
OutputFolder : string

/// Overrides OutputBaseFilename with the specified filename
OutputBaseFilename : string

/// Specifies output mode when compiling
QuietMode : QuietMode

/// Emulate #define public <name> <value>
Defines : Map<string,string>

/// Additional parameters
AdditionalParameters : string option

/// Path to inno-script file
ScriptFile : string
}

/// InnoSetup default parameters
static member Create()=
{
ToolPath = toolPath
WorkingDirectory = ""
Timeout = timeout
ScriptFile = "innosetup.iss"
EnableOutput = None
OutputFolder = ""
OutputBaseFilename = ""
QuietMode = Default
Defines = Map.empty
AdditionalParameters = None
}

let private run toolPath workingDirectory timeout command =
use __ = Trace.traceTask "InnoSetup" command
if 0 <> Process.execSimple ((fun info ->
{ info with
FileName = toolPath
WorkingDirectory = workingDirectory
Arguments = command })) timeout
then failwithf "InnoSetup command %s failed." command

let private serializeInnoSetupParams p =
let appendDefine (key,value) _ sb =
if String.isNullOrEmpty value then
StringBuilder.append (sprintf "/D%s" key) sb
else
StringBuilder.append (sprintf "/D%s=%s" key value) sb

StringBuilder()
|> StringBuilder.appendIfSome p.AdditionalParameters id
|> StringBuilder.appendIfSome p.EnableOutput (fun enableOutput -> if enableOutput then "/O+" else "/O-")
|> StringBuilder.appendIfNotNullOrEmpty p.OutputFolder "/O"
|> StringBuilder.appendIfNotNullOrEmpty p.OutputBaseFilename "/F"
|> StringBuilder.appendWithoutQuotes
(match p.QuietMode with
| Quiet -> "/Q"
| QuietAndProgress -> "/Qp"
|_ -> "")
|> StringBuilder.forEach (p.Defines |> Map.toList) appendDefine ""
|> StringBuilder.append p.ScriptFile
|> StringBuilder.toText

/// Builds the InnoSetup installer.
/// ## Parameters
/// - `setParams` - Function used to manipulate the default build parameters. See `InnoSetupParams.Create()`
/// ## Sample
///
/// InnoSetup.build (fun p ->
/// { p with
/// OutputFolder = "build" @@ "installer"
/// ScriptFile = "installer" @@ "setup.iss"
/// })
let build setParams =
let p = InnoSetupParams.Create() |> setParams
p
|> serializeInnoSetupParams
|> run p.ToolPath p.WorkingDirectory p.Timeout
4 changes: 4 additions & 0 deletions src/app/Fake.Installer.InnoSetup/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
group netcore

FSharp.Core
NETStandard.Library

0 comments on commit b7efb9f

Please sign in to comment.