From bcf74d838cd87f8e5ce780120279831283f5fb35 Mon Sep 17 00:00:00 2001
From: kolja <38011792+kblohm@users.noreply.github.com>
Date: Fri, 8 Jun 2018 23:16:38 +0200
Subject: [PATCH 1/3] Dotnet new template
---
build.fsx | 11 ++
.../Content/.template.config/template.json | 116 ++++++++++++++++++
src/app/fake-template/Content/build.fsx | 33 +++++
src/app/fake-template/Content/build.proj | 8 ++
src/app/fake-template/Content/buildProj.cmd | 2 +
src/app/fake-template/Content/buildProj.sh | 7 ++
src/app/fake-template/Content/buildTool.cmd | 7 ++
src/app/fake-template/Content/buildTool.sh | 12 ++
.../fake-template/Content/paket.dependencies | 6 +
src/app/fake-template/fake-template.proj | 25 ++++
10 files changed, 227 insertions(+)
create mode 100644 src/app/fake-template/Content/.template.config/template.json
create mode 100644 src/app/fake-template/Content/build.fsx
create mode 100644 src/app/fake-template/Content/build.proj
create mode 100644 src/app/fake-template/Content/buildProj.cmd
create mode 100644 src/app/fake-template/Content/buildProj.sh
create mode 100644 src/app/fake-template/Content/buildTool.cmd
create mode 100644 src/app/fake-template/Content/buildTool.sh
create mode 100644 src/app/fake-template/Content/paket.dependencies
create mode 100644 src/app/fake-template/fake-template.proj
diff --git a/build.fsx b/build.fsx
index 156f60b4099..527bb5ccbe7 100644
--- a/build.fsx
+++ b/build.fsx
@@ -1099,6 +1099,17 @@ Target.create "_DotNetPackage" (fun _ ->
else c.Common
} |> dtntSmpl) "Fake.sln"
+ // pack template
+ let templateProj = appDir @@ "fake-template"
+ DotNet.pack (fun c ->
+ { c with
+ Configuration = DotNet.Release
+ OutputPath = Some nugetDir
+ Common =
+ if CircleCi.isCircleCi then
+ { c.Common with CustomParams = Some "/m:1" }
+ else c.Common
+ } |> dtntSmpl) templateProj
// TODO: Check if we run the test in the current build!
Directory.ensure "temp"
let testZip = "temp/tests.zip"
diff --git a/src/app/fake-template/Content/.template.config/template.json b/src/app/fake-template/Content/.template.config/template.json
new file mode 100644
index 00000000000..d4b85450e19
--- /dev/null
+++ b/src/app/fake-template/Content/.template.config/template.json
@@ -0,0 +1,116 @@
+{
+ "identity": "Fake.Template",
+ "shortName": "fake",
+ "name": "FAKE - Template",
+ "classifications": ["Fake", "build"],
+ "symbols": {
+ "scriptname": {
+ "type": "parameter",
+ "description": "Name of the generated build-script",
+ "dataType": "string",
+ "defaultValue": "build.fsx",
+ "FileRename": "build.fsx"
+ },
+ "version": {
+ "type": "parameter",
+ "description": "Version of fake to install. This parameter is only applicable when either 'tool' or 'project' is used for bootstrapping",
+ "dataType": "string",
+ "defaultValue": "5.0.0",
+ "replaces": "(version)"
+ },
+ "dependencies": {
+ "type": "parameter",
+ "dataType": "choice",
+ "defaultValue": "file",
+ "choices": [{
+ "choice": "file",
+ "description": "Use paket.dependencies file to define build dependencies"
+ },
+ {
+ "choice": "inline",
+ "description": "Define build dependencies inside the build script"
+ },
+ {
+ "choice": "none",
+ "description": "No dependencies are created"
+ }
+ ]
+ },
+ "bootstrap": {
+ "type": "parameter",
+ "dataType": "choice",
+ "defaultValue": "tool",
+ "choices": [{
+ "choice": "project",
+ "description": "Creates a build.proj file to bootstrap fake"
+ },
+ {
+ "choice": "tool",
+ "description": "Uses the global dotnet fake tool to bootstrap fake. The tool is downloaded into 'tool--path'"
+ },
+ {
+ "choice": "none",
+ "description": "Does not bootstrap fake"
+ }
+ ]
+ },
+ "tool-path": {
+ "type": "parameter",
+ "description": "Folder for the fake-cli tool. This parameter is only applicable when 'tool' is used for bootstrapping",
+ "dataType": "string",
+ "defaultValue": ".fake",
+ "replaces": "(ToolPath)"
+ }
+ },
+ "sources": [{
+ "exclude": "**/.template.config/**/*",
+ "modifiers": [{
+ "exclude": "**/buildTool.*",
+ "condition": "(bootstrap != \"tool\")"
+ },
+ {
+ "rename": {
+ "buildTool.sh": "build.sh",
+ "buildTool.cmd": "build.cmd"
+ }
+ },
+ {
+ "exclude": ["**/buildProj.*", "**/build.proj"],
+ "condition": "(bootstrap != \"project\")"
+ },
+ {
+ "rename": {
+ "buildProj.sh": "build.sh",
+ "buildProj.cmd": "build.cmd"
+ }
+ },
+ {
+ "exclude": "**/paket.dependencies",
+ "condition": "(dependencies != \"file\")"
+ }
+ ]
+ }],
+ "SpecialCustomOperations": {
+ "**/*.fsx*": {
+ "operations": [{
+ "type": "conditional",
+ "configuration": {
+ "if": [
+ "#if"
+ ],
+ "else": [
+ "#else"
+ ],
+ "elseif": [
+ "#elseif"
+ ],
+ "endif": [
+ "#endif"
+ ],
+ "trim": "true",
+ "wholeLine": "true"
+ }
+ }]
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/fake-template/Content/build.fsx b/src/app/fake-template/Content/build.fsx
new file mode 100644
index 00000000000..00f517c6157
--- /dev/null
+++ b/src/app/fake-template/Content/build.fsx
@@ -0,0 +1,33 @@
+//#if (dependencies == "inline")
+#r "paket:
+ source https://api.nuget.org/v3/index.json
+ nuget Fake.DotNet.Cli
+ nuget Fake.IO.FileSystem
+ nuget Fake.Core.Target //"
+//#endif
+#load ".fake/build.fsx/intellisense.fsx"
+open Fake.Core
+open Fake.DotNet
+open Fake.IO
+open Fake.IO.FileSystemOperators
+open Fake.IO.Globbing.Operators
+open Fake.Core.TargetOperators
+
+Target.create "Clean" (fun _ ->
+ !! "src/**/bin"
+ ++ "src/**/obj"
+ |> Shell.cleanDirs
+)
+
+Target.create "Build" (fun _ ->
+ !! "src/**/*.*proj"
+ |> Seq.iter (DotNet.build id)
+)
+
+Target.create "All" ignore
+
+"Clean"
+ ==> "Build"
+ ==> "All"
+
+Target.runOrDefault "All"
diff --git a/src/app/fake-template/Content/build.proj b/src/app/fake-template/Content/build.proj
new file mode 100644
index 00000000000..0db5604e9bf
--- /dev/null
+++ b/src/app/fake-template/Content/build.proj
@@ -0,0 +1,8 @@
+
- dotnet tool install fake-cli -g --version=5.0.0-*
+ dotnet tool install fake-cli -g --version=5.*
@@ -50,6 +50,21 @@ now you can use
This is basically it. You can now execute fake commands. Follow the [minimal example below](fake-dotnetcore.html#Minimal-example) for a quick start.
+## FAKE Template
+Use the FAKE `dotnet new` template. See [FAKE template]("fake-template.html") for more information.
+
+- Install the template:
+
+
+ dotnet new -i "fake-template::*"
+
+ dotnet new fake
+
+
## CLI
See [Fake command line](fake-commandline.html)
@@ -146,7 +161,3 @@ Get the latest binaries from chocolatey: https://chocolatey.org/packages/fake
Get the latest dotnet-fake cli tool by adding `Note that `Version="5.*"` is working only after we released the first stable release. For now use `Version="5.0.0-*"` to get the latest non-stable release
-
+ dotnet tool install fake-cli -g
+
+ * To install FAKE into `your_tool_path`, run:
+
+ dotnet tool install fake-cli --tool-path your_tool_path
+
+
+ Use `--version` to specify the version of FAKE. See the [`global_tool` branch of `fake-bootstrap`](https://github.com/FakeBuild/fake-bootstrap/tree/global_tool) for ideas to bootstrap in your CI process.
+
+* Bootstrap via the [fake dotnet new template](fake-template.html). The template bootstraps FAKE and sets up a basic build-script.
+ * To install the template run:
+
+ dotnet new -i "fake-template::*"
+
+ * Then run the template with:
+
+ dotnet new fake
+
+
+ See the [template](fake-template.html) page for more information.
+
+* Install the 'fake' or 'fake-netcore' package for you system (currenty chocolatey).
Example `choco install fake -pre`
-* Use it as dotnet tool: Add `As FAKE 5 is still in pre-release, you have to specify the --version
parameter.
+dotnet new -i "fake-template::*"
+
+to install or update the template.
+
+## Usage
+After you installed the template you can setup FAKE by running:
+
+dotnet new fake
+
+This will create a default `build.fsx` file, a `paket.dependencies` file used to mangage your build dependencies and two shell scripts `build.sh` and `build.cmd`. The shell scripts are used to bootstrap and run FAKE. All of the arguments are passed direcly to FAKE so you can run:
+
+.\build.cmd build
+
+to run your build. Have a look [this](fake-commandline.html) for the available command-line options. [This page](fake-gettingstarted.html#Example-Compiling-and-building-your-NET-application) additional information on how to use a build script.
+
+## Options
+
+### --scriptname
+Specifies the name of the generated build-script. Defaults to `build.fsx`.
+
+### --bootstrap
+Specifies your prefered way to bootstrap FAKE.
+
+- `tool` (default) - Installs the FAKE dotnet sdk global tool into the `tool--path` folder
+- `project` - Creates a `build.proj` and uses `DotNetCliToolReference` to bootstrap FAKE
+- `none` - Does not bootstrap FAKE. Use this if you want to use a global installation of FAKE
+
+### --dependencies
+Specifies your prefered way to define the nuget packages used in your build:
+
+- `file` (default) - Creates a `paket.dependencies` file to define build dependencies
+- `inline` - Defines build dependencies inside the build script
+- `none` - Use this if you already have a `paket.dependencies` in your folder
+
+### --tool-path
+Specifies the folder for the fake-cli tool. This parameter is only applicable when `tool` is used for bootstrapping. Defaults to `.fake`.
+
+### --version
+Specifies the version of FAKE to install. Defaults to `5.*`. This parameter is only applicable when either `tool` or `project` is used for bootstrapping.
+
+
diff --git a/help/templates/template.cshtml b/help/templates/template.cshtml
index 2dec8b1422e..e9f8f73cf37 100644
--- a/help/templates/template.cshtml
+++ b/help/templates/template.cshtml
@@ -54,6 +54,7 @@
dotnet new fake
-This will create a default `build.fsx` file, a `paket.dependencies` file used to mangage your build dependencies and two shell scripts `build.sh` and `build.cmd`. The shell scripts are used to bootstrap and run FAKE. All of the arguments are passed direcly to FAKE so you can run:
+This will create a default `build.fsx` file, a `paket.dependencies` file used to mangage your build dependencies and two shell scripts `fake.sh` and `fake.cmd`. The shell scripts are used to bootstrap and run FAKE. All of the arguments are passed direcly to FAKE so you can run:
-.\build.cmd build
+.\fake.cmd build
to run your build. Have a look [this](fake-commandline.html) for the available command-line options. [This page](fake-gettingstarted.html#Example-Compiling-and-building-your-NET-application) additional information on how to use a build script.
## Options
-### --scriptname
+### --script-name
Specifies the name of the generated build-script. Defaults to `build.fsx`.
### --bootstrap
diff --git a/src/app/fake-template/Content/.template.config/template.json b/src/app/fake-template/Content/.template.config/template.json
index e626f4a8e93..a553ec8e042 100644
--- a/src/app/fake-template/Content/.template.config/template.json
+++ b/src/app/fake-template/Content/.template.config/template.json
@@ -4,12 +4,13 @@
"name": "FAKE - Template",
"classifications": ["build", "FAKE"],
"symbols": {
- "scriptname": {
+ "script-name": {
"type": "parameter",
"description": "Name of the generated build-script",
"dataType": "string",
"defaultValue": "build.fsx",
- "FileRename": "build.fsx"
+ "FileRename": "build.fsx",
+ "replaces": "(build.fsx)"
},
"bootstrap": {
"type": "parameter",
@@ -65,23 +66,23 @@
"sources": [{
"exclude": "**/.template.config/**/*",
"modifiers": [{
- "exclude": "**/buildTool.*",
+ "exclude": "**/fake.tool.*",
"condition": "(bootstrap != \"tool\")"
},
{
"rename": {
- "buildTool.sh": "build.sh",
- "buildTool.cmd": "build.cmd"
+ "fake.tool.sh": "fake.sh",
+ "fake.tool.cmd": "fake.cmd"
}
},
{
- "exclude": ["**/buildProj.*", "**/build.proj"],
+ "exclude": ["**/fake.proj.*", "**/build.proj"],
"condition": "(bootstrap != \"project\")"
},
{
"rename": {
- "buildProj.sh": "build.sh",
- "buildProj.cmd": "build.cmd"
+ "fake.proj.sh": "fake.sh",
+ "fake.proj.cmd": "fake.cmd"
}
},
{
diff --git a/src/app/fake-template/Content/build.fsx b/src/app/fake-template/Content/build.fsx
index 00f517c6157..1874462815b 100644
--- a/src/app/fake-template/Content/build.fsx
+++ b/src/app/fake-template/Content/build.fsx
@@ -5,7 +5,7 @@
nuget Fake.IO.FileSystem
nuget Fake.Core.Target //"
//#endif
-#load ".fake/build.fsx/intellisense.fsx"
+#load ".fake/(build.fsx)/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
diff --git a/src/app/fake-template/Content/buildProj.cmd b/src/app/fake-template/Content/fake.proj.cmd
similarity index 100%
rename from src/app/fake-template/Content/buildProj.cmd
rename to src/app/fake-template/Content/fake.proj.cmd
diff --git a/src/app/fake-template/Content/buildProj.sh b/src/app/fake-template/Content/fake.proj.sh
similarity index 100%
rename from src/app/fake-template/Content/buildProj.sh
rename to src/app/fake-template/Content/fake.proj.sh
diff --git a/src/app/fake-template/Content/buildTool.cmd b/src/app/fake-template/Content/fake.tool.cmd
similarity index 100%
rename from src/app/fake-template/Content/buildTool.cmd
rename to src/app/fake-template/Content/fake.tool.cmd
diff --git a/src/app/fake-template/Content/buildTool.sh b/src/app/fake-template/Content/fake.tool.sh
similarity index 100%
rename from src/app/fake-template/Content/buildTool.sh
rename to src/app/fake-template/Content/fake.tool.sh