### Minimal SonarQube Integration Example Source: https://fake.build/articles/testing-sonarqube.html This FAKE script demonstrates the minimal setup for SonarQube analysis. It defines targets to start and finish the SonarQube analysis, integrating them into the build process. Ensure SonarQube.exe is available in the tools directory. ```fsharp #r "paket: nuget Fake.Core.Target nuget Fake.Testing.SonarQube //" open Fake.Core open Fake.Core.TargetOperators open Fake.Testing Target.create "BeginSonarQube" (fun _ -> SonarQube.start (fun p -> {p with Key = "MyProject" Name = "Main solution" Version = "1.0.0" } ) ) Target.create "EndSonarQube" (fun _ -> SonarQube.finish None ) Target.create "Default" DoNothing "Clean" ==> "SetAssemblyInfo" ==> "BeginSonarQube" ==> "Build" <=> "BuildTests" ==> "EndSonarQube" ==> "RunTests" ==> "Deploy" ==> "Default" Target.runOrDefault "Default" ``` -------------------------------- ### Build Inno Setup Installer with Custom Parameters Source: https://fake.build/reference/fake-installer-innosetup.html Use this snippet to build an Inno Setup installer with a specified output folder and script file. It customizes the default build parameters by providing a function to `InnoSetup.build`. ```fsharp InnoSetup.build (fun p -> { p with OutputFolder = "build" @@ "installer" ScriptFile = "installer" @@ "setup.iss" }) ``` -------------------------------- ### Create Squirrel Installer Example Source: https://fake.build/reference/fake-installer-squirrel.html Demonstrates how to create a Squirrel installer for a given NuGet package using the Squirrel.releasify function. It shows how to specify the release directory. ```fsharp Target.create "CreatePackage" (fun _ -> Squirrel.releasify "./my.nupkg" (fun p -> { p with ReleaseDir = "./squirrel_release") ) ``` -------------------------------- ### Setup Environment for .NET SDK Installation Source: https://fake.build/reference/fake-dotnet-dotnet.html Sets up the environment (PATH and DOTNET_ROOT) to use a specific .NET SDK installation. Useful for tools like Fable. ```fsharp DotNet.setupEnv install ``` -------------------------------- ### Install Instance Member Source: https://fake.build/reference/fake-core-buildserverinstaller.html Installs the build server. ```APIDOC ## Install ### Description Installs the build server. ### Method Instance member ### Modifiers abstract ``` -------------------------------- ### Setup Fake Build Script Source: https://fake.build/guide/fake-template.html After installing the template, use this command to set up a default FAKE build script (`build.fsx`) and associated shell scripts. ```bash dotnet new fake ``` -------------------------------- ### Minimal SpecFlow Integration Example Source: https://fake.build/articles/dotnet-testing-specflow.html This FSI script demonstrates a basic setup for SpecFlow integration within FAKE. It includes installing necessary NuGet packages and defining targets for regenerating test classes and creating step definition reports. ```fsharp #r "paket: nuget Fake.Core.Target nuget Fake.DotNet.Testing.SpecFlow //" open Fake.Core open Fake.DotNet.Testing let specsProject = "IntegrationTests.csproj" Target.create "Regenerate Test Classes" (fun _ -> specsProject |> SpecFlowNext.run id ) Target.create "Create StepDefinition Report" (fun _ -> specsProject |> SpecFlowNext.run (fun p -> { p with SubCommand = StepDefinitionReport BinFolder = Some "bin/Debug" OutputFile = Some "StepDefinitionReport.html" }) ) Target.create "Default" Target.DoNothing "Clean" ==> "Regenerate Test Classes" ==> "Build" ==> "Run Integration Tests" ==> "Create StepDefinition Report" ==> "Default" Target.runOrDefault "Default" ``` -------------------------------- ### Build Setup with WiX Script Generation Source: https://fake.build/reference/fake-installer-wix.html This snippet demonstrates the build setup process, including copying necessary files, replacing tags in a WiX template to generate the WiX script, and running WiX tools. ```fakebuild Target "BuildSetup" (fun _ -> // Copy all important files to the deploy directory !! (buildDir + "/**/*.dll") ++ (buildDir + "/**/*.exe") ++ (buildDir + "/**/*.config") |> Copy deployPrepDir // replace tags in a template file in order to generate a WiX script let ALLFILES = fun _ -> true let replacements = [ "@build.number@",if not isLocalBuild then buildVersion else "0.1.0.0" "@product.productcode@",System.Guid.NewGuid().ToString() "@HelpFiles@",getFilesAsWiXString helpFiles "@ScriptFiles@",getFilesAsWiXString scriptFiles "@icons@",getWixDirTag ALLFILES true (directoryInfo(bundledDir @@ "icons"))] processTemplates replacements setupFiles // run the WiX tools WiX (fun p -> {p with ToolDirectory = WiXPath}) setupFileName (setupBuildDir + "Setup.wxs.template") ) ``` -------------------------------- ### Run Yarn Install with --flat flag Source: https://fake.build/reference/fake-javascript-yarn.html Execute `yarn install --flat` to install dependencies flatly. Configure the working directory as needed. ```fake Yarn.installFlat (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### DotNetFDDOptions.Create(install) Source: https://fake.build/reference/fake-dotnet-dotnetfddoptions.html Creates a new instance of DotNetFDDOptions with specified installation options. ```APIDOC ## DotNetFDDOptions.Create(install) ### Description Creates a new instance of DotNetFDDOptions with specified installation options. ### Method Static ### Parameters #### Path Parameters - **install** (`Options -> Options`) - Required - Parameters as for the dotnet call ### Returns `DotNetFDDOptions` ``` -------------------------------- ### Install and Use GitVersion in FAKE Source: https://fake.build/articles/tools-gitversion.html This snippet demonstrates how to install the GitVersion tool using FAKE's DotNet.install and then use it to generate version properties within a FAKE target. It ensures the necessary NuGet packages are referenced. ```fsharp #r "paket: nuget Fake.Core.Target nuget Fake.DotNet.Cli nuget Fake.Tools.GitVersion //" open Fake.Core open Fake.DotNet open Fake.Tools let install = lazy DotNet.install DotNet.Versions.FromGlobalJson Target.create "Version" (fun _ -> GitVersion.generateProperties (fun p -> { p with ToolType = ToolType.CreateCLIToolReference(install.Value) }) ) ``` -------------------------------- ### Npm.install Source: https://fake.build/reference/fake-javascript-npm.html Runs 'npm install' to install dependencies. Allows customization of parameters. ```APIDOC ## Npm.install ### Description Runs `npm install` to install dependencies. Allows customization of parameters. ### Method (Not specified, likely a function call in F#) ### Parameters #### Path Parameters (None specified) #### Query Parameters (None specified) #### Request Body (None specified) ### Parameters - **setParams** (`NpmParams -> NpmParams`) - Set command parameters ### Request Example ```fsharp Npm.install (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` ### Response (Not specified) #### Success Response (200) (Not specified) #### Response Example (Not specified) ``` -------------------------------- ### DotNet.install setParams Source: https://fake.build/reference/fake-dotnet-dotnet.html Installs the .NET Core SDK if it is not already installed, with specified options. ```APIDOC ## DotNet.install setParams ### Description Installs the .NET Core SDK if it is not already installed. Allows setting installation options to customize the installation process. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Method * Not applicable (SDK function) ### Endpoint * Not applicable (SDK function) ### Request Example * Not applicable (SDK function) ### Response #### Success Response * **Returns**: `Options -> Options` - Returns options related to the installation. ### Parameters * **setParams** (`CliInstallOptions -> CliInstallOptions`) - set installation options ``` -------------------------------- ### Run Yarn Install with --production flag Source: https://fake.build/reference/fake-javascript-yarn.html Execute `yarn install --production` to install only production dependencies. Set the working directory for the operation. ```fake Yarn.installProduction (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Install Chocolatey Package Source: https://fake.build/articles/windows-chocolatey.html Demonstrates how to install a Chocolatey package using the `Choco.install` function. It shows a conditional installation based on a target and how to specify the package ID. ```fsharp "BuildApp" =?> ("InspectCodeAnalysis", Choco.IsAvailable) Target.create "InspectCodeAnalysis" (fun _ - "resharper-clt.portable" |> Choco.install id ... ) ``` -------------------------------- ### Build WiX Setup with FAKE Source: https://fake.build/articles/installer-wix.html This snippet demonstrates how to define a FAKE target to build an MSI setup. It includes file filtering, component creation, feature generation, and WiX template filling. ```fake Target "BuildWiXSetup" (fun _ -> // This defines, which files should be collected when running bulkComponentCreation let fileFilter = fun (file : FileInfo) -> if file.Extension = ".dll" || file.Extension = ".exe" || file.Extension = ".config" then true else false // Collect Files which should be shipped. Pass directory with your deployment output for deployDir // along with the targeted architecture. let components = bulkComponentCreation fileFilter (DirectoryInfo deployDir) Architecture.X86 // Collect component references for usage in features let componentRefs = components |> Seq.map(fun comp -> comp.ToComponentRef()) let completeFeature = generateFeatureElement (fun f -> {f with Id = "Complete" Title = "Complete Feature" Level = 1 Description = "Installs all features" Components = componentRefs Display = Expand }) // Generates a predefined WiX template with placeholders which will be replaced in "FillInWiXScript" generateWiXScript "SetupTemplate.wxs" let WiXUIMondo = generateUIRef (fun f -> {f with Id = "WixUI_Mondo" }) let WiXUIError = generateUIRef (fun f -> {f with Id = "WixUI_ErrorProgressText" }) let MajorUpgrade = generateMajorUpgradeVersion( fun f -> {f with Schedule = MajorUpgradeSchedule.AfterInstallExecute DowngradeErrorMessage = "A later version is already installed, exiting." }) FillInWiXTemplate "" (fun f -> {f with // Guid which should be generated on every build ProductCode = Guid.NewGuid() ProductName = "Test Setup" Description = "Description of Test Setup" ProductLanguage = 1033 ProductVersion = "1.0.0" ProductPublisher = "YouOrYourCompany" // Set fixed upgrade guid, this should never change for this project! UpgradeGuid = WixProductUpgradeGuid MajorUpgrade = [MajorUpgrade] UIRefs = [WiXUIMondo; WiXUIError] ProgramFilesFolder = ProgramFiles32 Components = components BuildNumber = "Build number" Features = [completeFeature] }) // run the WiX tools WiX (fun p -> {p with ToolDirectory = WiXPath}) setupFileName @".\SetupTemplate.wxs" ) ``` -------------------------------- ### DotNetLocalTool.Create(install) Source: https://fake.build/reference/fake-dotnet-dotnetlocaltool.html Creates a new instance of DotNetLocalTool with specified installation options. ```APIDOC ## DotNetLocalTool.Create(install) ### Description Creates a new instance of DotNetLocalTool, allowing for custom installation configurations. ### Parameters #### Path Parameters - **install** (`Options -> Options`) - Required - The installation configuration function. ### Returns `DotNetLocalTool` - A new instance of DotNetLocalTool configured with the provided installation options. ``` -------------------------------- ### Install FAKE Locally Source: https://fake.build/guide/contributing.html Installs FAKE as a local tool using the dotnet SDK. Ensure you are in the project directory before running. ```bash cd /projects/FAKE dotnet tool restore dotnet fake --version ``` -------------------------------- ### Run Yarn Install with --frozen-lockfile flag Source: https://fake.build/reference/fake-javascript-yarn.html Execute `yarn install --frozen-lockfile` to ensure the lockfile is respected. Set the working directory for the operation. ```fake Yarn.installFrozenLockFile (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Run Yarn Install with --force flag Source: https://fake.build/reference/fake-javascript-yarn.html Use this to run `yarn install --force`, which can be useful for overwriting existing dependencies. Specify the working directory for the command. ```fake Yarn.installForced (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Minimal Report Generation Example Source: https://fake.build/articles/testing-reportgenerator.html This snippet shows the basic setup for generating reports using ReportGenerator in FAKE. It includes installing necessary packages and defining a target to process OpenCover XML reports and output them to a specified directory. ```fsharp #r paket: nuget Fake.Core.Target nuget Fake.Testing.ReportGenerator" open Fake.Core open Fake.Core.TargetOperators open Fake.Testing Target.create "Generate Reports" (fun _ -> !! "**/opencover.xml" |> Seq.toList |> ReportGenerator.generateReports (fun p -> { p with TargetDir = "c:/reports/" }) ) Target.runOrDefault "Generate Reports" ``` -------------------------------- ### Minimal .NET CLI Example with FAKE Source: https://fake.build/guide/dotnet-cli.html Demonstrates basic usage of the DotNet.exec and DotNet.restore functions with different configurations for build and restore operations. ```fsharp #r "paket: nuget Fake.DotNet.Cli //" open Fake.DotNet // Lazily install DotNet SDK in the correct version if not available let install = lazy DotNet.install DotNet.Versions.Release_2_1_4 // Alternative: Read from global json let install = lazy DotNet.install DotNet.Versions.FromGlobalJson // Define general properties across various commands (with arguments) let inline withWorkDir wd = DotNet.Options.lift install.Value >> DotNet.Options.withWorkingDirectory wd // Set general properties without arguments let inline dotnetSimple arg = DotNet.Options.lift install.Value arg // Use defined properties on "DotNet.Exec" DotNet.exec (withWorkDir "./test") "build" "" DotNet.exec dotnetSimple "build" "myproject.fsproj" DotNet.exec dotnetSimple "build" "mysolution.sln" // Use defined properties on more generalized functions like "DotNet.Restore" DotNet.restore dotnetSimple "mysolution.sln" // Define more general properties in addition to the general ones DotNet.restore (fun args -> { args with NoCache = true } |> dotnetSimple) "mysolution.sln" // Define more general properties in addition to the general ones, with arugments DotNet.restore (fun args -> { args with Runtime = Some "win-x86" } |> withWorkDir "./test" ) "mysolution.sln" ``` -------------------------------- ### Install Build Server Support and Trace Output Source: https://fake.build/guide/buildserver.html Installs support for TeamCity and Team Foundation build servers and ensures console output is visible. This snippet demonstrates general API usage for build servers. ```fsharp #r "paket: nuget Fake.BuildServer.TeamCity nuget Fake.BuildServer.TeamFoundation nuget Fake.Core.Target //" open System.IO open Fake.Core open Fake.BuildServer BuildServer.install [ TeamCity.Installer TeamFoundation.Installer ] // If you additionally want output in the console, even on the build-server (otherwise remove this line). CoreTracing.ensureConsoleListener () Target.create "Test" (fun _ -> File.WriteAllText("myfile.txt", "some content") // traceTag can be used to open scopes/blocks. They will be shown in the build-server visualization if supported. ( use testsuite = Trace.traceTag (KnownTags.TestSuite "some-testsuite") "Starting unit test" ( use _ = Trace.traceTag (KnownTags.Test "some-test") "Starting unit test 1" // Scope of the test Trace.testOutput "some-test" "standard output" "standard error") ( use _ = Trace.traceTag (KnownTags.Test "some-test2") "Starting unit test 2" // Scope of test2 Trace.testOutput "some-test2" "standard output" "standard error")) // Uploads an artifact no matter the build-server Trace.publish ImportData.BuildArtifact "myfile.txt" // Uploads test results no matter the build-server // Note: There might be limitations on some system with some imports. // Please help by testing, submitting issues and pull requests. Trace.publish (ImportData.Nunit NunitDataVersion.Nunit) "Fake_Core_CommandLine_UnitTests.TestResults.xml" Trace.setBuildNumber "my-build-number" Trace.traceImportant "tries to write in yellow" Trace.trace "tries to write in green" Trace.log "tries to write in white (normal color)" ) ``` -------------------------------- ### Initial FAKE Build Script Setup Source: https://fake.build/guide/getting-started.html This snippet sets up the initial build.fsx file, including necessary Paket dependencies and enabling IntelliSense. ```fsharp #r "paket: nuget Fake.Core.Target //" #load "./.fake/build.fsx/intellisense.fsx" ``` -------------------------------- ### Install FAKE as Local .NET Tool Source: https://fake.build/guide/getting-started.html Install the FAKE CLI as a local tool within your project. This ensures that the correct version of FAKE is used for your project's builds. ```bash dotnet tool install fake-cli ``` -------------------------------- ### Get Registry Value Example Source: https://fake.build/reference/fake-windows-registry.html An example demonstrating how to retrieve a registry value and use it in a trace statement. The value is fetched using HKEY_CURRENT_USER and a specific subkey. ```powershell let AppType = Registry.getRegistryValue Registry.HKEYCurrentUser subkey values.[0] Trace.trace (sprintf "You are running the %s version" AppType) ``` -------------------------------- ### Serve DocFx Documentation Source: https://fake.build/reference/fake-documentation-docfx.html This example demonstrates how to serve DocFx documentation locally. It shows how to set the host, port, and the folder containing the documentation. ```fsharp DocFx.serve (fun p -> { p with Host = "localhost" Port = Some 80 Folder = "docs" }) ``` -------------------------------- ### Build Documentation from Scratch Source: https://fake.build/guide/contributing.html Execute this command to build the entire documentation from scratch, including styles and API references. ```bash dotnet fake build target GenerateDocs ``` -------------------------------- ### Install FAKE to Specific Tool Path Source: https://fake.build/guide/getting-started.html Install the FAKE CLI to a designated tool path. This is useful for managing tools in specific locations or for custom setups. ```bash dotnet tool install fake-cli --tool-path your_tool_path ``` -------------------------------- ### Get Default CMake Build Parameters Source: https://fake.build/reference/fake-build-cmake.html Retrieves the default parameters for CMake build operations. Use this to start customizing build settings. ```fsharp let defaults = CMake.CMakeBuildDefaults ``` -------------------------------- ### Generate Custom Action Execution Source: https://fake.build/reference/fake-installer-wix.html Creates a WiX custom action execution configuration. The 'Condition' can be used to control when the action runs, for example, only during installation. ```fsharp let actionExecution = generateCustomActionExecution (fun f -> { f with ActionId = action.Id Verb = "After" Target = "InstallFiles" Condition = "(&" + feature.Id + " = 3) AND NOT (!" + feature.Id + " = 3)" }) ``` -------------------------------- ### BuildServer.install servers Source: https://fake.build/reference/fake-core-buildservermodule.html Installs a list of build servers. ```APIDOC ## BuildServer.install servers ### Description Installs the specified list of build servers. ### Method POST (assumed, as it performs an action) ### Endpoint N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **servers** (BuildServerInstaller list) - Required - The list of build servers to install. ``` -------------------------------- ### Get Default Cloud Service Parameters Source: https://fake.build/reference/fake-azure-cloudservices.html Retrieves the default parameters for packaging cloud services. Use this as a starting point for configuring cloud service packaging. ```fsharp CloudServices.DefaultCloudServiceParams ``` -------------------------------- ### Execute Rsync with Basic Options Source: https://fake.build/reference/fake-tools-rsync.html This example demonstrates a simpler rsync execution, focusing on compression, a single source directory, and a destination. It's useful for basic synchronization tasks where advanced options are not required. Verify rsync's availability on your system. ```fsharp let result = Rsync.exec (Rsync.Options.WithActions [ Rsync.Compress ] >> Rsync.Options.WithSources [ FleetMapping.server "build" ] >> Rsync.Options.WithDestination "remote@myserver.com:deploy") "" if not result.OK then failwithf "Rsync failed with code %i" result.ExitCode ``` -------------------------------- ### Get OpenCover Version Example Source: https://fake.build/articles/dotnet-testing-opencover.html This script shows how to retrieve the version of the OpenCover tool using the getVersion API. It includes an option to specify the executable path. ```fsharp #r "paket: nuget Fake.DotNet.Testing.OpenCover //" open Fake.DotNet.Testing OpenCover.getVersion None ``` -------------------------------- ### SonarQube.start Source: https://fake.build/reference/fake-testing-sonarqube.html Runs the begin command of SonarQube on a project. This initializes the SonarQube analysis process. ```APIDOC ## SonarQube.start ### Description Runs the begin command of SonarQube on a project. This function initializes the SonarQube analysis process. ### Method `start` ### Parameters #### setParams - **setParams** (`SonarQubeParams -> SonarQubeParams`) - Function used to overwrite the SonarQube default parameters. ### Request Example ``` open Fake.Testing SonarQube.start (fun p -> { p with Key = "MyProject" Name = "MainTool" Version = "1.0" }) ``` ``` -------------------------------- ### Generate C# and F# AssemblyInfo Files Source: https://fake.build/articles/dotnet-assemblyinfo.html Use AssemblyInfoFile.createCSharp and AssemblyInfoFile.createFSharp to generate assembly information files. This example demonstrates setting title, description, GUID, product, version, and file version. ```fsharp #r "paket: nuget Fake.DotNet.AssemblyInfoFile nuget Fake.DotNet.MSBuild nuget Fake.Core.Target //" open Fake.Core open Fake.DotNet Target.create "BuildApp" (fun _ -> AssemblyInfoFile.createCSharp "./src/app/Calculator/Properties/AssemblyInfo.cs" [ AssemblyInfo.Title "Calculator Command line tool" AssemblyInfo.Description "Sample project for FAKE - F# MAKE" AssemblyInfo.Guid "A539B42C-CB9F-4a23-8E57-AF4E7CEE5BAA" AssemblyInfo.Product "Calculator" AssemblyInfo.Version version AssemblyInfo.FileVersion version] AssemblyInfoFile.createFSharp "./src/app/CalculatorLib/Properties/AssemblyInfo.fs" [ AssemblyInfo.Title "Calculator library" AssemblyInfo.Description "Sample project for FAKE - F# MAKE" AssemblyInfo.Guid "EE5621DB-B86B-44eb-987F-9C94BCC98441" AssemblyInfo.Product "Calculator" AssemblyInfo.Version version AssemblyInfo.FileVersion version] MSBuild.runRelease id buildDir "Build" appReferences |> Trace.logItems "AppBuild-Output: " ) ``` -------------------------------- ### Minimal Gherkin to HTML Conversion with Pickles Source: https://fake.build/articles/tools-pickles.html This snippet demonstrates the basic setup for using the Pickles tool in FAKE to convert Gherkin feature files into HTML documentation. Ensure you have the necessary NuGet packages installed via Paket. ```fsharp #r "paket: nuget Fake.Core.Target nuget Fake.IO.FileSystem nuget Fake.Tools.Pickles //" open Fake.Core open Fake.IO.FileSystemOperators open Fake.IO.Globbing open Fake.Tools open System.IO let currentDirectory = Directory.GetCurrentDirectory() Target.create "BuildDoc" (fun _ -> Pickles.convert (fun p -> { p with FeatureDirectory = currentDirectory "Specs" OutputDirectory = currentDirectory "SpecDocs" OutputFileFormat = Pickles.DocumentationFormat.DHTML }) ) Target.runOrDefault "BuildDoc" ``` -------------------------------- ### SonarQube with Additional Settings Source: https://fake.build/articles/testing-sonarqube.html This example shows how to pass additional global settings to the SonarQube server using the 'Settings' parameter within the SonarQube.start function. This is equivalent to using the /d: parameter with the SonarQube runner. ```fsharp SonarQube.start (fun p -> {p with Key = "MyProject" Name = "Main solution" Version = "1.0.0" Settings = ["sonar.debug"; "sonar.newversion"] } ) ``` -------------------------------- ### SonarQube with Configuration File Source: https://fake.build/articles/testing-sonarqube.html This example demonstrates how to configure SonarQube analysis by reading settings from a configuration file using the 'Config' parameter. This is equivalent to using the /s: parameter with the SonarQube runner. ```fsharp SonarQube.start (fun p -> {p with Key = "MyProject" Name = "Main solution" Version = "1.0.0" Config = Some("myconfig.cfg") } ) ``` -------------------------------- ### Generate Service Install Source: https://fake.build/reference/fake-installer-wix.html Generates a service install configuration for WiX installers. Use this function to override the default service install parameters. ```fsharp Wix.generateServiceInstall setParams ``` -------------------------------- ### Emulators.startStorageEmulator Source: https://fake.build/reference/fake-azure-emulators.html Starts the Azure storage emulator. ```APIDOC ## Emulators.startStorageEmulator ### Description Starts the storage emulator. ### Parameters #### Path Parameters - **_arg1** (`'a`) - Description not available in source. ### Returns `'b` - Description not available in source. ``` -------------------------------- ### Install Npm Package Source: https://fake.build/reference/fake-javascript-npm.html Use this snippet to install npm packages. It allows specifying the working directory for the installation. ```fsharp Npm.install (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Install Chocolatey Package Source: https://fake.build/reference/fake-windows-choco.html Installs a specified package using Chocolatey. Allows customization of installation parameters like version. ```fsharp Target "ChocoInstall" (fun _ -> "pretzel" |> Choco.Install (fun p -> { p with Version = "0.4.0" }) ) ``` -------------------------------- ### Host Documentation Locally Source: https://fake.build/guide/contributing.html This command builds the documentation and spins up a local webserver to view the generated docs in a browser. ```bash dotnet fake build target HostDocs ``` -------------------------------- ### Emulators.startComputeEmulator Source: https://fake.build/reference/fake-azure-emulators.html Starts the Azure compute emulator. ```APIDOC ## Emulators.startComputeEmulator ### Description Starts the compute emulator. ### Parameters #### Path Parameters - **_arg1** (`'a`) - Description not available in source. ### Returns `'b` - Description not available in source. ``` -------------------------------- ### YarnCommand Install Union Case Source: https://fake.build/reference/fake-javascript-yarn-yarncommand.html Represents the Yarn install command. Requires an InstallArgs parameter to specify installation details. ```fsharp Install InstallArgs ``` -------------------------------- ### Yarn.installProduction Source: https://fake.build/reference/fake-javascript-yarn.html Runs `yarn install --production` with customizable parameters. ```APIDOC ## Yarn.installProduction ### Description Runs `yarn install --production` with customizable parameters. ### Method `Yarn.installProduction setParams` ### Parameters - **setParams** (`YarnParams -> YarnParams`) - A function to set or modify Yarn command parameters. ### Example ``` Yarn.installProduction (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` ``` -------------------------------- ### Configure and Pack .NET Project Source: https://fake.build/reference/fake-dotnet-dotnet.html Configures pack options such as build configuration, output path, and symbol inclusion, then executes the dotnet pack command. ```fsharp let packConfiguration (defaults:DotNet.PackOptions) = { defaults with Configuration = DotNet.Debug OutputPath = Some "./packages" IncludeSymbols = true } DotNet.pack packConfiguration "./MyProject.csproj" ``` -------------------------------- ### Fake CLI Usage Examples Source: https://fake.build/guide/commandline.html Demonstrates the basic usage patterns for the Fake CLI, including listing targets, checking the version, and accessing help. ```bash fake-run --list fake-run --version fake-run --help | -h ``` -------------------------------- ### Yarn.install Source: https://fake.build/reference/fake-javascript-yarn.html Runs the `yarn install` command with customizable parameters. ```APIDOC ## Yarn.install ### Description Runs the `yarn install` command with customizable parameters. ### Method `Yarn.install setParams` ### Parameters - **setParams** (`YarnParams -> YarnParams`) - A function to set or modify Yarn command parameters. ### Example ``` Yarn.install (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` ``` -------------------------------- ### install Source: https://fake.build/reference/fake-windows-choco.html Installs Chocolatey packages using the specified parameters. ```APIDOC ## Choco.install ### Description Calls Chocolatey to install one or more packages. ### Parameters - **setParams** (`ChocoInstallParams -> ChocoInstallParams`) - A function to configure the installation parameters. See `ChocoInstallParams` for available options. - **packages** (`string`) - The names of the packages to install, or paths to package files (.nuspec, .nupkg) or a packages.config file. ### Example ``` Target "ChocoInstall" (fun _ -> "pretzel" |> Choco.Install (fun p -> { p with Version = "0.4.0" }) ) ``` ``` -------------------------------- ### Attach Service Installs to a Component Source: https://fake.build/reference/fake-installer-wix.html Use this function to attach service installs to your WiX components. It takes a directory component, a file filter, and a sequence of service installs. ```fsharp Wix.attachServiceInstallToComponent comp fileFilter serviceInstalls ``` -------------------------------- ### Yarn.installFlat Source: https://fake.build/reference/fake-javascript-yarn.html Runs `yarn install --flat` with customizable parameters. ```APIDOC ## Yarn.installFlat ### Description Runs `yarn install --flat` with customizable parameters. ### Method `Yarn.installFlat setParams` ### Parameters - **setParams** (`YarnParams -> YarnParams`) - A function to set or modify Yarn command parameters. ### Example ``` Yarn.installFlat (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` ``` -------------------------------- ### get Source: https://fake.build/reference/fake-net-http.html Executes an HTTP GET command to retrieve information from a URL. ```APIDOC ## get userName password url ### Description Executes an HTTP GET command and retrieves the information. It returns the response of the request, or null if we got 404 or nothing. ### Parameters #### Path Parameters - **userName** (string) - Required - The username to use with the request. - **password** (string) - Required - The password to use with the request. - **url** (string) - Required - The URL to perform the GET operation. ### Returns - **string** - The response of the request, or null if we got 404 or nothing. ``` -------------------------------- ### DotNet.setupEnv Source: https://fake.build/reference/fake-dotnet-dotnet.html Sets up the environment (PATH and DOTNET_ROOT) to use a specific .NET SDK installation. Useful for ensuring processes use a particular SDK version. ```APIDOC ## DotNet.setupEnv ### Description Sets up the environment (`PATH` and `DOTNET_ROOT`) in such a way that started processes use the given dotnet SDK installation. This is useful for example when using fable, see issue #2405. ### Method (Not specified, likely a function call in F#) ### Endpoint (Not applicable, F# function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable, F# function) ### Response #### Success Response (Not specified, likely returns unit or status) #### Response Example (Not applicable, F# function) ### Parameters - **install** (`Options -> Options`) - The SDK to use (result of `DotNet.install`) ``` -------------------------------- ### Run Echo Command Source: https://fake.build/reference/fake-core-createprocess.html This example shows how to run a simple 'echo' command using CreateProcess.fromRawCommand. It's useful for basic command execution. ```fake CreateProcess.fromRawCommand "cmd" [ "/C"; "echo test" ] |> Proc.run |> ignore ``` -------------------------------- ### WithFileName Source: https://fake.build/reference/fake-core-procstartinfoextensions.html Sets the application or document to start. ```APIDOC ## WithFileName ### Description Sets the application or document to start. ### Method Extension Method ### Parameters #### Path Parameters - **name** (string) - Description: The name of the application or document. ### Returns `ProcStartInfo` ``` -------------------------------- ### Install Npm Package (Forced) Source: https://fake.build/reference/fake-javascript-npm.html Run 'npm install --force' to install packages, potentially overwriting existing ones or ignoring certain issues. Specify the working directory for the operation. ```fsharp Npm.installForced (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Release_2_1_300_RC1 option Source: https://fake.build/reference/fake-dotnet-dotnet-versions.html Installs .NET SDK version 2.1.300-RC1. It takes CliInstallOptions and returns modified options. ```APIDOC ## Release_2_1_300_RC1 option ### Description Installs a specific .NET SDK version (2.1.300-RC1). ### Method Not applicable (function call) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **option** : `CliInstallOptions` - The current installation options. ### Returns * `CliInstallOptions` - The modified installation options. ``` -------------------------------- ### Clean Install Npm Packages Source: https://fake.build/reference/fake-javascript-npm.html Run 'npm ci' for a clean installation. This is useful for ensuring a consistent environment by installing exact versions from the lock file. Specify the working directory as needed. ```fsharp Npm.cleanInstall (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Build Documentation Directly Source: https://fake.build/guide/contributing.html Use this command to skip prerequisite build steps and directly run the 'GenerateDocs' target, assuming binaries are already built. ```bash dotnet fake build -s target GenerateDocs ``` -------------------------------- ### Install Fake Template Source: https://fake.build/guide/fake-template.html Run this command to install or update the fake-template NuGet package. ```bash dotnet new -i "fake-template::*" ``` -------------------------------- ### Basic MSBuild Build with Custom Parameters Source: https://fake.build/reference/fake-dotnet-msbuild.html Demonstrates how to build a solution file with custom MSBuild parameters like verbosity, targets, and properties. It reads the build mode from an environment variable. ```fsharp open Fake.DotNet let buildMode = Environment.environVarOrDefault "buildMode" "Release" let setParams (defaults: MSBuildParams) = { defaults with Verbosity = Some(Quiet) Targets = ["Build"] Properties = [ "Optimize", "True" "DebugSymbols", "True" "Configuration", buildMode ] } MSBuild.build setParams "./MySolution.sln" ``` -------------------------------- ### Proc.startRawSync Source: https://fake.build/reference/fake-core-proc.html Starts a process and waits synchronously until it has started, returning the process result information. ```APIDOC ## Proc.startRawSync c ### Description Similar to `startRaw` but waits until the process has been started. ### Parameters #### Parameters - **c** (`CreateProcess<'a>`) - The create process instance ### Returns - `AsyncProcessResult<'a>` - The result information of the process after it has started. ``` -------------------------------- ### Report Progress Start to TeamCity Source: https://fake.build/reference/fake-buildserver-teamcity.html Signals the start of a progress reporting section in TeamCity with an initial message. ```fsharp TeamCity.reportProgressStart "Starting file processing." ``` -------------------------------- ### Release_1_0_4 options Source: https://fake.build/reference/fake-dotnet-dotnet-versions.html Installs .NET SDK version 1.0.4. It takes CliInstallOptions and returns modified options. ```APIDOC ## Release_1_0_4 options ### Description Installs a specific .NET SDK version (1.0.4). ### Method Not applicable (function call) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **options** : `CliInstallOptions` - The current installation options. ### Returns * `CliInstallOptions` - The modified installation options. ``` -------------------------------- ### Release_2_0_3 options Source: https://fake.build/reference/fake-dotnet-dotnet-versions.html Installs .NET SDK version 2.0.3. It takes CliInstallOptions and returns modified options. ```APIDOC ## Release_2_0_3 options ### Description Installs a specific .NET SDK version (2.0.3). ### Method Not applicable (function call) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **options** : `CliInstallOptions` - The current installation options. ### Returns * `CliInstallOptions` - The modified installation options. ``` -------------------------------- ### XML Documentation Block Example Source: https://fake.build/articles/fake-v6-release-announcement.html The converted example of documentation comments in XML syntax, used by FSDocs. ```fsharp /// /// Creates a draft GitHub Release for the specified repository and tag name /// /// /// The repository's owner /// The repository's name /// The name of the tag to use for this release /// Indicates whether the release will be created as a prerelease /// Collection of release notes that will be inserted into the body of the release /// GitHub API v3 client /// /// /// Target.create "GitHubRelease" (fun _ -> /// let token = /// match Environment.environVarOrDefault "github_token" "" with /// | s when not (System.String.IsNullOrWhiteSpace s) -> s /// | _ -> failwith "please set the github_token environment variable to a github personal access token with repro access." /// /// let files = /// runtimes @ [ "portable"; "packages" ] /// |> List.map (fun n -> sprintf "release/dotnetcore/Fake.netcore/fake-dotnetcore-%s.zip" n) /// /// GitHub.createClientWithToken token /// |> GitHub.draftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes /// |> GitHub.uploadFiles files /// |> GitHub.publishDraft /// |> Async.RunSynchronously) /// /// ``` -------------------------------- ### Markdown Documentation Block Example Source: https://fake.build/articles/fake-v6-release-announcement.html An example of documentation comments in Markdown syntax used in FAKE codebase. ```fsharp /// Creates a GitHub Release for the specified repository and tag name /// Creates a draft GitHub Release for the specified repository and tag name /// ## Parameters /// - `owner` - the repository's owner /// - `repoName` - the repository's name /// - `tagName` - the name of the tag to use for this release /// - `prerelease` - indicates whether the release will be created as a prerelease /// - `notes` - collection of release notes that will be inserted into the body of the release /// - `client` - GitHub API v3 client /// /// # Sample /// Target.create "GitHubRelease" (fun _ -> /// let token = /// match Environment.environVarOrDefault "github_token" "" with /// | s when not (System.String.IsNullOrWhiteSpace s) -> s /// | _ -> failwith "please set the github_token environment variable to a github personal access token with repro access." /// /// let files = /// runtimes @ [ "portable"; "packages" ] /// |> List.map (fun n -> sprintf "release/dotnetcore/Fake.netcore/fake-dotnetcore-%s.zip" n) /// /// GitHub.createClientWithToken token /// |> GitHub.draftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes /// |> GitHub.uploadFiles files /// |> GitHub.publishDraft /// |> Async.RunSynchronously) ``` -------------------------------- ### Start Process with List of Arguments Source: https://fake.build/guide/core-process.html Use `CreateProcess.fromRawCommand` with a list of arguments to define and run a process. The exit code can be ignored. ```fsharp CreateProcess.fromRawCommand "./folder/mytool.exe" ["arg1"; "arg2"] |> Proc.run // start with the above configuration |> ignore // ignore exit code ``` ```fsharp [ "arg1"; "arg2" "arg3" ] |> CreateProcess.fromRawCommand "./folder/mytool.exe" |> CreateProcess.withWorkingDirectory "./folder" |> Proc.run |> ignore ``` -------------------------------- ### Run Yarn Install Source: https://fake.build/reference/fake-javascript-yarn.html Use this snippet to run the `yarn install` command. You can specify the working directory for the operation. ```fake Yarn.install (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` -------------------------------- ### Run SonarQube Begin Command Source: https://fake.build/reference/fake-testing-sonarqube.html This task initiates the begin command for SonarQube analysis on a project. It allows configuration of project key, name, and version. ```fsharp open Fake.Testing SonarQube.start (fun p -> { p with Key = "MyProject" Name = "MainTool" Version = "1.0 }) ``` -------------------------------- ### Npm.installForced Source: https://fake.build/reference/fake-javascript-npm.html Runs 'npm install --force' to install dependencies with forced options. Allows customization of parameters. ```APIDOC ## Npm.installForced ### Description Runs `npm install --force` to install dependencies with forced options. Allows customization of parameters. ### Method (Not specified, likely a function call in F#) ### Parameters #### Path Parameters (None specified) #### Query Parameters (None specified) #### Request Body (None specified) ### Parameters - **setParams** (`NpmParams -> NpmParams`) - Set command parameters ### Request Example ```fsharp Npm.installForced (fun o -> { o with WorkingDirectory = "./src/FAKESimple.Web/" }) ``` ### Response (Not specified) #### Success Response (200) (Not specified) #### Response Example (Not specified) ``` -------------------------------- ### Basic Script with Command Line Arguments Source: https://fake.build/guide/core-commandlineparsing.html Demonstrates how to define a CLI usage string, parse arguments using Fake's context, and access parsed arguments. Ensure the 'Fake.Core.CommandLineParsing' NuGet package is referenced. ```fsharp #r "paket: nuget Fake.Core.CommandLineParsing //" open Fake.Core let cli = "" usage: prog [options] options: -a Add -r Remote -m Message " // retrieve the fake 5 and above context information let ctx = Context.forceFakeContext () // get the arguments let args = ctx.Arguments let parser = Docopt(cli) let parsedArguments = parser.Parse(args) if DocoptResult.hasFlag "-a" parsedArguments then printfn "Got -a" match DocoptResult.tryGetArgument "-m" results with | None -> printfn "Printing generic message" | Some arg -> printfn "%s" arg ``` -------------------------------- ### Build Command Line with BlackFox.CommandLine Source: https://fake.build/guide/core-process.html Use the `BlackFox.CommandLine` library to construct command line arguments for a process, then convert it to a string for execution. ```fsharp open BlackFox.CommandLine CmdLine.empty |> CmdLine.append "build" |> CmdLine.appendIf noRestore "--no-restore" |> CmdLine.appendPrefixIfSome "--framework" framework |> CmdLine.appendPrefixf "--configuration" "%A" configuration |> CmdLine.toString |> CreateProcess.fromRawCommandLine "dotnet.exe" |> Proc.run |> ignore ``` -------------------------------- ### DotNet.installTemplate templateName setParams Source: https://fake.build/reference/fake-dotnet-dotnet.html Installs a new .NET template using the `dotnet new --install` command. ```APIDOC ## DotNet.installTemplate templateName setParams ### Description Executes the `dotnet new --install ` command to install a new template. Requires the template name and allows setting installation parameters. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Method * Not applicable (SDK function) ### Endpoint * Not applicable (SDK function) ### Request Example * Not applicable (SDK function) ### Response * Not applicable (documented return type is a function) ### Parameters * **templateName** (`string`) - template short name to install * **setParams** (`TemplateInstallOptions -> TemplateInstallOptions`) - set version command parameters ``` -------------------------------- ### addOnSetup Source: https://fake.build/reference/fake-core-createprocess.html Attaches a function to be executed before the process is started. ```APIDOC ## addOnSetup f c ### Description Executes the given function before the process is started. ### Parameters #### Path Parameters - **f** (unit -> 'a) - Required - Function to add on setup - **c** (CreateProcess) - Required - The create process instance ### Returns CreateProcess ``` -------------------------------- ### Wix.attachServiceInstallToComponent Source: https://fake.build/reference/fake-installer-wix.html Use this to attach service installs to your components. It takes a directory component, a file filter, and a sequence of service installs as input. ```APIDOC ## Wix.attachServiceInstallToComponent ### Description Attaches service installs to a given directory component based on a file filter. ### Method Wix.attachServiceInstallToComponent ### Parameters #### Path Parameters - **comp** (DirectoryComponent) - Required - The directory component instance. - **fileFilter** (Component -> bool) - Required - The file filter. - **serviceInstalls** (seq) - Required - The service installs instance to attach. ### Returns DirectoryComponent - The updated directory component instance. ``` -------------------------------- ### Argument Ordering Examples Source: https://fake.build/guide/commandline.html Illustrates the importance of argument order in FAKE CLI commands, showing how incorrect ordering can lead to unexpected behavior. ```text fake run -v build.fsx fake run build.fsx --fsiargs "--define:BOOTSTRAP" fake build -s ```