FAKE - F# Make - A DSL for build tasks and more FAKE
6.2.0

Lookig for older versions of the documentation, pre FAKE v6? See 

v5.fake.build

DotNet Module

.NET Core + CLI tools helpers

Types and nested modules

Type/Module Description

BuildConfiguration (Module)

THe build configuration for a DotNet application

CliChannel

Specifies the source channel for the installation.

Options (Module)

Versions

The a list of well-known versions to install

BuildConfiguration (Type)

build configuration

BuildOptions

dotnet build command options

CliArchitecture

.NET Core SDK architecture

CliInstallOptions

.NET Core SDK install options

CliVersion

.NET Core SDK version (used to specify version when installing .NET Core SDK)

FirstArgReplacement

InfoOptions

dotnet --info command options

InfoResult

dotnet info result

InstallerOptions

.NET Core SDK installer download options

MSBuildOptions

dotnet restore command options

MTPCodeCoverageOptions

Options of the code coverage extension of Microsoft.Testing.Platform. Coverage is collected by setting MTPTestOptions.CodeCoverage (--coverage). The extension is not a part of the platform: a test application that does not reference the Microsoft.Testing.Extensions.CodeCoverage package, directly or through a test framework package that brings it, rejects these options as an invalid command line (its exit code is 5), and the test run fails.

MTPCoverageFormat

The format of the file that the code coverage extension of Microsoft.Testing.Platform writes (--coverage-output-format)

MTPCrashDumpOptions

Options of the crash dump extension of Microsoft.Testing.Platform. A dump of a crashed test application is requested by setting MTPTestOptions.CrashDump (--crashdump). The extension is not a part of the platform: a test application that does not reference the Microsoft.Testing.Extensions.CrashDump package rejects these options as an invalid command line (its exit code is 5), and the test run fails.

MTPDiagnosticOptions

The diagnostic log that every Microsoft.Testing.Platform test application can write. It is turned on by setting MTPTestOptions.Diagnostic (--diagnostic); the test applications reject the other diagnostic options without it.

MTPDiagnosticVerbosity

The level of the diagnostic log of a Microsoft.Testing.Platform test application (--diagnostic-verbosity)

MTPDumpType

The kind of the memory dump that the crash dump and the hang dump extensions of Microsoft.Testing.Platform write (--crashdump-type, --hangdump-type)

MTPHangDumpOptions

Options of the hang dump extension of Microsoft.Testing.Platform. A dump of a test application that stopped making progress is requested by setting MTPTestOptions.HangDump (--hangdump). The extension is not a part of the platform: a test application that does not reference the Microsoft.Testing.Extensions.HangDump package rejects these options as an invalid command line (its exit code is 5), and the test run fails.

MTPOutputVerbosity

How much of the test results dotnet test prints with the Microsoft.Testing.Platform runner (--output)

MTPTestOptions

dotnet test command options for the Microsoft.Testing.Platform runner, see DotNet.testMTP. With that runner dotnet test understands only a part of the options itself and passes the others to the test applications. Every test application understands the options of the platform. An option of a test framework or of an extension is rejected as an invalid command line by a test application that does not reference that framework or extension, and the test run fails; the documentation of each such field names what is needed.

MTPTestTarget

Selects what dotnet test runs when global.json selects the Microsoft.Testing.Platform runner, see DotNet.testMTP. That runner takes the target through an option: the .NET SDK 10.0.100 rejects a project that is passed as the first argument. Only one of these targets can be given for a run.

MTPTrxReportOptions

Options of the TRX report extension of Microsoft.Testing.Platform. The report is requested by setting MTPTestOptions.TrxReport (--report-trx). The extension is not a part of the platform: a test application that does not reference the Microsoft.Testing.Extensions.TrxReport package, directly or through a test framework package that brings it, rejects these options as an invalid command line (its exit code is 5), and the test run fails.

NewLanguage

The languages supported by new command

NewOptions

dotnet new command options

NuGetPushOptions

nuget push parameters for dotnet nuget push

Options (Type)

dotnet cli command execution options

PackOptions

dotnet pack command options

PublishOptions

dotnet publish command options

RestoreOptions

dotnet restore command options

TemplateInstallOptions

dotnet new --install options

TemplateUninstallOptions

dotnet new --install options

TestOptions

dotnet test command options of the VSTest runner. The options of the Microsoft.Testing.Platform runner are in MTPTestOptions.

Verbosity

dotnet restore verbosity

VersionOptions

dotnet --version command options

VersionResult

dotnet info result

Functions and values

Function or value Description

DotNet.build setParams project

Full Usage: DotNet.build setParams project

Parameters:

Execute dotnet build command

setParams : BuildOptions -> BuildOptions

set compile command parameters

project : string

project to compile

DotNet.defaultSystemInstallDir

Full Usage: DotNet.defaultSystemInstallDir

Returns: string

.NET Core SDK default install directory (set to default SDK installer paths (/usr/local/share/dotnet or C:\Program Files\dotnet))

Returns: string

DotNet.defaultUserInstallDir

Full Usage: DotNet.defaultUserInstallDir

Returns: string

.NET Core SDK default install directory (set to default SDK installer paths (%HOME/.dotnet or %LOCALAPPDATA%/Microsoft/dotnet).

Returns: string

DotNet.downloadInstaller setParams

Full Usage: DotNet.downloadInstaller setParams

Parameters:
Returns: string

Download .NET Core SDK installer

setParams : InstallerOptions -> InstallerOptions

set download installer options

Returns: string

DotNet.exec buildOptions command args

Full Usage: DotNet.exec buildOptions command args

Parameters:
    buildOptions : Options -> Options - build common execution options
    command : string - the sdk command to execute test, new, build, ...
    args : string - command arguments

Returns: ProcessResult

Execute raw dotnet cli command

buildOptions : Options -> Options

build common execution options

command : string

the sdk command to execute test, new, build, ...

args : string

command arguments

Returns: ProcessResult

DotNet.findPossibleDotnetCliPaths dotnetCliDir

Full Usage: DotNet.findPossibleDotnetCliPaths dotnetCliDir

Parameters:
    dotnetCliDir : string option - the path to check else will probe system PATH

Returns: seq<string>

Get dotnet cli executable path. Probes the provided path first, then as a fallback tries the system PATH

dotnetCliDir : string option

the path to check else will probe system PATH

Returns: seq<string>

DotNet.getSDKVersionFromGlobalJson ()

Full Usage: DotNet.getSDKVersionFromGlobalJson ()

Parameters:
    () : unit

Returns: string

Gets the DotNet SDK from the global.json. This file can exist in the working directory or any of the parent directories

() : unit
Returns: string

DotNet.getVersion setParams

Full Usage: DotNet.getVersion setParams

Parameters:
Returns: string

Execute dotnet --version command

setParams : VersionOptions -> VersionOptions

set version command parameters

Returns: string

DotNet.info setParams

Full Usage: DotNet.info setParams

Parameters:
Returns: InfoResult

Execute dotnet --info command

setParams : InfoOptions -> InfoOptions

set info command parameters

Returns: InfoResult

DotNet.install setParams

Full Usage: DotNet.install setParams

Parameters:
Returns: Options -> Options

Install .NET Core SDK if required

setParams : CliInstallOptions -> CliInstallOptions

set installation options

Returns: Options -> Options

DotNet.installTemplate templateName setParams

Full Usage: DotNet.installTemplate templateName setParams

Parameters:

Execute dotnet new --install <PATH|NUGET_ID> command to install a new template

templateName : string

template short name to install

setParams : TemplateInstallOptions -> TemplateInstallOptions

set version command parameters

DotNet.msbuild setParams project

Full Usage: DotNet.msbuild setParams project

Parameters:
    setParams : MSBuildOptions -> MSBuildOptions - A function that overwrites the default MSBuildOptions
    project : string - A string with the path to the project file to build.

Runs a MSBuild project

setParams : MSBuildOptions -> MSBuildOptions

A function that overwrites the default MSBuildOptions

project : string

A string with the path to the project file to build.

Example


 open Fake.DotNet
     let setMsBuildParams (defaults:MSBuild.CliArguments) =
             { defaults with
                 Verbosity = Some(Quiet)
                 Targets = ["Build"]
                 Properties =
                     [
                         "Optimize", "True"
                         "DebugSymbols", "True"
                         "Configuration", "Release"
                     ]
              }
     let setParams (defaults:DotNet.MSBuildOptions) =
             { defaults with
                 MSBuildParams = setMsBuildParams defaults.MSBuildParams
              }

     DotNet.msbuild setParams "./MySolution.sln"

DotNet.newFromTemplate templateName setParams

Full Usage: DotNet.newFromTemplate templateName setParams

Parameters:
    templateName : 'a - template short name to create from
    setParams : NewOptions -> NewOptions - set version command parameters

Execute dotnet new command

templateName : 'a

template short name to create from

setParams : NewOptions -> NewOptions

set version command parameters

DotNet.nugetPush setParams nupkg

Full Usage: DotNet.nugetPush setParams nupkg

Parameters:

Execute dotnet nuget push command

setParams : NuGetPushOptions -> NuGetPushOptions

set nuget push command parameters

nupkg : string

nupkg to publish

Example


 open Fake.DotNet
     let setNugetPushParams (defaults:NuGet.NuGetPushParams) =
             { defaults with
                 DisableBuffering = true
                 ApiKey = Some "abc123"
              }
     let setParams (defaults:DotNet.NuGetPushOptions) =
             { defaults with
                 PushParams = setNugetPushParams defaults.PushParams
              }

     DotNet.nugetPush setParams "./My.Package.nupkg"

DotNet.pack setParams project

Full Usage: DotNet.pack setParams project

Parameters:

Execute dotnet pack command

setParams : PackOptions -> PackOptions

set pack command parameters

project : string

project to pack

Example


  let packConfiguration (defaults:DotNet.PackOptions) =
         { defaults with
               Configuration = DotNet.Debug
               OutputPath = Some "./packages"
               IncludeSymbols = true }

     DotNet.pack packConfiguration "./MyProject.csproj"

DotNet.prefixProcess buildOptions firstArgs c

Full Usage: DotNet.prefixProcess buildOptions firstArgs c

Parameters:
Returns: CreateProcess<'a>

Replace the current CreateProcess instance to run with dotnet.exe

buildOptions : Options -> Options

build common execution options

firstArgs : string list
c : CreateProcess<'a>
Returns: CreateProcess<'a>

DotNet.publish setParams project

Full Usage: DotNet.publish setParams project

Parameters:

Execute dotnet publish command

setParams : PublishOptions -> PublishOptions

set publish command parameters

project : string

project to publish

DotNet.restore setParams project

Full Usage: DotNet.restore setParams project

Parameters:

Execute dotnet restore command

setParams : RestoreOptions -> RestoreOptions

set restore command parameters

project : string

project to restore packages

DotNet.setupEnv install

Full Usage: DotNet.setupEnv install

Parameters:
    install : Options -> Options - The SDK to use (result of DotNet.install)

Setup 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

install : Options -> Options

The SDK to use (result of DotNet.install)

DotNet.test setParams project

Full Usage: DotNet.test setParams project

Parameters:

Execute dotnet test command. Its options are those of the VSTest runner. When global.json selects the Microsoft.Testing.Platform runner, use DotNet.testMTP instead.

setParams : TestOptions -> TestOptions

set test command parameters

project : string

project to test

DotNet.testMTP setParams target

Full Usage: DotNet.testMTP setParams target

Parameters:

Execute dotnet test command with the Microsoft.Testing.Platform runner, which dotnet test of the .NET SDK 10 and later uses when global.json contains "test": { "runner": "Microsoft.Testing.Platform" }. That runner has other options than the VSTest runner of DotNet.test, see MTPTestOptions. Fails when dotnet test exits with a code other than 0.

setParams : MTPTestOptions -> MTPTestOptions

set test command parameters

target : MTPTestTarget

the project, the solution or the test applications to test

Example


 DotNet.testMTP
     (fun options ->
         { options with
             NoBuild = true
             Configuration = Some DotNet.BuildConfiguration.Release
             ResultsDirectory = Some "TestResults"
             CodeCoverage =
                 Some
                     { DotNet.MTPCodeCoverageOptions.Create() with
                         OutputFormat = Some DotNet.MTPCoverageFormat.Cobertura } })
     (DotNet.MTPTestTarget.Project "tests/MyProject.Tests/MyProject.Tests.fsproj")

DotNet.tryGetSDKVersionFromGlobalJson ()

Full Usage: DotNet.tryGetSDKVersionFromGlobalJson ()

Parameters:
    () : unit

Returns: string option

Tries the DotNet SDK from the global.json. This file can exist in the working directory or any of the parent directories Returns None if global.json is not found

() : unit
Returns: string option

DotNet.uninstallTemplate templateName

Full Usage: DotNet.uninstallTemplate templateName

Parameters:
    templateName : string - template short name to uninstall

Execute dotnet new --uninstall <PATH|NUGET_ID> command to uninstall a new template

templateName : string

template short name to uninstall