From c6efb14349efdffe801135094716621d6f66da62 Mon Sep 17 00:00:00 2001 From: kolja <38011792+kblohm@users.noreply.github.com> Date: Sun, 5 Aug 2018 22:18:23 +0200 Subject: [PATCH 01/14] Fix the template version * only add a version constraint if the user specified one * use * for DotNetCliToolReference if no version was specified * do not add --version for the global tool if no version was specified --- build.fsx | 14 -------------- .../Content/.template.config/template.json | 4 ++-- src/template/fake-template/Content/build.proj | 4 ++++ src/template/fake-template/Content/fake.tool.cmd | 4 ++++ src/template/fake-template/Content/fake.tool.sh | 4 ++++ 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/build.fsx b/build.fsx index 6de1a991ecf..680a34703b5 100644 --- a/build.fsx +++ b/build.fsx @@ -694,17 +694,6 @@ Target.create "_DotNetPackage" (fun _ -> Environment.setEnvironVar "PackageProjectUrl" "https://github.com/fsharp/Fake" Environment.setEnvironVar "PackageLicenseUrl" "https://github.com/fsharp/FAKE/blob/d86e9b5b8e7ebbb5a3d81c08d2e59518cf9d6da9/License.txt" - // Update template - let templateFromVersion, templateToVersion = """"defaultValue": "5.*",""", sprintf """"defaultValue": "%s",""" nugetVersion - let templateConfigFile = "src/template/fake-template/Content/.template.config/template.json" - let replaceInTemplate fromDefault toDefault = - [ templateConfigFile ] - |> Shell.replaceInFiles [ fromDefault, toDefault ] - let configContents = File.ReadAllText(templateConfigFile) - if not <| configContents.Contains templateFromVersion then - failwithf "Make sure to revert your changes in '%s' or update the build script accordingly" templateConfigFile - replaceInTemplate templateFromVersion templateToVersion - // dotnet pack DotNet.pack (fun c -> { c with @@ -716,9 +705,6 @@ Target.create "_DotNetPackage" (fun _ -> else c.Common } |> dtntSmpl) "Fake.sln" - // Revert template - replaceInTemplate templateToVersion templateFromVersion - // TODO: Check if we run the test in the current build! Directory.ensure "temp" let testZip = "temp/tests.zip" diff --git a/src/template/fake-template/Content/.template.config/template.json b/src/template/fake-template/Content/.template.config/template.json index 6650b3a6964..fc9b52549ba 100644 --- a/src/template/fake-template/Content/.template.config/template.json +++ b/src/template/fake-template/Content/.template.config/template.json @@ -59,7 +59,7 @@ "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.*", + "defaultValue": "latest", "replaces": "(version)" } }, @@ -105,4 +105,4 @@ }, "continueOnError": false }] -} +} \ No newline at end of file diff --git a/src/template/fake-template/Content/build.proj b/src/template/fake-template/Content/build.proj index 0db5604e9bf..d725e65f0f8 100644 --- a/src/template/fake-template/Content/build.proj +++ b/src/template/fake-template/Content/build.proj @@ -3,6 +3,10 @@ netstandard2.0 + + + + \ No newline at end of file diff --git a/src/template/fake-template/Content/fake.tool.cmd b/src/template/fake-template/Content/fake.tool.cmd index c596b122b7a..9a4103bf6cf 100644 --- a/src/template/fake-template/Content/fake.tool.cmd +++ b/src/template/fake-template/Content/fake.tool.cmd @@ -1,7 +1,11 @@ SET TOOL_PATH=(ToolPath) IF NOT EXIST "%TOOL_PATH%\fake.exe" ( + rem #if (version == "latest") + dotnet tool install fake-cli --tool-path ./%TOOL_PATH% + rem #else dotnet tool install fake-cli --tool-path ./%TOOL_PATH% --version (version) + rem #endif ) "%TOOL_PATH%/fake.exe" %* \ No newline at end of file diff --git a/src/template/fake-template/Content/fake.tool.sh b/src/template/fake-template/Content/fake.tool.sh index 342bc559a01..4cd1c0b88d2 100644 --- a/src/template/fake-template/Content/fake.tool.sh +++ b/src/template/fake-template/Content/fake.tool.sh @@ -22,6 +22,10 @@ FAKE="$TOOL_PATH"/fake if ! [ -e "$FAKE" ] then +#if (version == "latest") + dotnet tool install fake-cli --tool-path "$TOOL_PATH" +#else dotnet tool install fake-cli --tool-path "$TOOL_PATH" --version (version) +#endif fi "$FAKE" "$@" From 5c7069b1cbfa90565cf6395edb94c1b1752b8d6d Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sun, 5 Aug 2018 22:28:04 +0200 Subject: [PATCH 02/14] release notes --- RELEASE_NOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a7e6a4344c0..c2ef91bca55 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,9 @@ # Release Notes +## 5/3.2 - vnext + +* TBD. + ## 5.3.1 - 2018-08-06 * BUGFIX: Minor code improvements - https://github.com/fsharp/FAKE/pull/2045 From ca0b3e6934437537fa2a6c11cce6fdf4e6f65c9c Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sun, 5 Aug 2018 22:28:48 +0200 Subject: [PATCH 03/14] release notes --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c2ef91bca55..b1f569b2aa8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,6 @@ # Release Notes -## 5/3.2 - vnext +## 5.3.2 - vnext * TBD. From a9b5c980cc85ef079b8f9d3fdd7743309cf21e5a Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sun, 5 Aug 2018 22:29:10 +0200 Subject: [PATCH 04/14] alpha --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b1f569b2aa8..4168c3e016a 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,6 @@ # Release Notes -## 5.3.2 - vnext +## 5.3.2-alpha - vnext * TBD. From 484cd222e756d4ad27a9bc2ae2dbfe2ab5600851 Mon Sep 17 00:00:00 2001 From: Lukas Rieger <0x53A@users.noreply.github.com> Date: Mon, 6 Aug 2018 14:01:43 +0200 Subject: [PATCH 05/14] [GITLAB] Add all environment variables see https://docs.gitlab.com/ee/ci/variables/ --- src/app/Fake.BuildServer.GitLab/GitLab.fs | 121 +++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/src/app/Fake.BuildServer.GitLab/GitLab.fs b/src/app/Fake.BuildServer.GitLab/GitLab.fs index 873d89b7435..a354d80e0a8 100644 --- a/src/app/Fake.BuildServer.GitLab/GitLab.fs +++ b/src/app/Fake.BuildServer.GitLab/GitLab.fs @@ -39,10 +39,129 @@ module GitLabImportExtensions = [] module GitLab = + /// https://docs.gitlab.com/ee/ci/variables/ type Environment = - static member CommitSha = Environment.environVar "CI_COMMIT_SHA" + + /// The branch or tag name for which project is built static member CommitRefName = Environment.environVar "CI_COMMIT_REF_NAME" + /// $CI_COMMIT_REF_NAME lowercased, shortened to 63 bytes, and with everything except 0-9 and a-z replaced with -. + /// No leading / trailing -. + /// Use in URLs, host names and domain names. + static member CommitRefSlug = Environment.environVar "CI_COMMIT_REF_SLUG" + /// The commit revision for which project is built + static member CommitSha = Environment.environVar "CI_COMMIT_SHA" + /// The previous latest commit present on a branch before a push request. + static member CommitBeforeSha = Environment.environVar "CI_COMMIT_BEFORE_SHA" + /// The commit tag name. Present only when building tags. + static member CommitTag = Environment.environVar "CI_COMMIT_TAG" + /// The full commit message. + static member CommitMessage = Environment.environVar "CI_COMMIT_MESSAGE" + /// The title of the commit - the full first line of the message + static member CommitTitle = Environment.environVar "CI_COMMIT_TITLE" + /// The description of the commit: the message without first line, if the title is shorter than 100 characters; full message in other case. + static member CommitDescription = Environment.environVar "CI_COMMIT_DESCRIPTION" + /// The path to CI config file. Defaults to .gitlab-ci.yml + static member ConfigPath = Environment.environVar "CI_CONFIG_PATH" + /// Whether debug tracing is enabled + static member DebugTrace = Environment.hasEnvironVar "CI_DEBUG_TRACE" + /// Authentication username of the GitLab Deploy Token, only present if the Project has one related. + static member DeployUser = Environment.environVar "CI_DEPLOY_USER" + /// Authentication password of the GitLab Deploy Token, only present if the Project has one related. + static member DeployPassword = Environment.environVar "CI_DEPLOY_PASSWORD" + /// Marks that the job is executed in a disposable environment (something that is created only for this job and disposed of/destroyed after the execution - all executors except shell and ssh). If the environment is disposable, it is set to true, otherwise it is not defined at all. + static member DisposableEnvironment = Environment.hasEnvironVar "CI_DISPOSABLE_ENVIRONMENT" + /// The name of the environment for this job + static member EnvironmentName = Environment.environVar "CI_ENVIRONMENT_NAME" + /// A simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, etc. + static member EnvironmentSlug = Environment.environVar "CI_ENVIRONMENT_SLUG" + /// The URL of the environment for this job + static member EnvironmentUrl = Environment.environVar "CI_ENVIRONMENT_URL" + /// The unique id of the current job that GitLab CI uses internally + static member JobId = Environment.environVar "CI_JOB_ID" + /// The flag to indicate that job was manually started + static member JobManual = Environment.environVar "CI_JOB_MANUAL" + /// The name of the job as defined in .gitlab-ci.yml + static member JobName = Environment.environVar "CI_JOB_NAME" + /// The name of the stage as defined in .gitlab-ci.yml + static member JobStage = Environment.environVar "CI_JOB_STAGE" + /// Token used for authenticating with GitLab Container Registry, downloading dependent repositories, authenticate with multi-project pipelines when triggers are involved, and for downloading job artifacts + static member JobToken = Environment.environVar "CI_JOB_TOKEN" + /// Job details URL + static member JobUrl = Environment.environVar "CI_JOB_URL" + /// The URL to clone the Git repository + static member RepositoryUrl = Environment.environVar "CI_REPOSITORY_URL" + /// The description of the runner as saved in GitLab + static member RunnerDescription = Environment.environVar "CI_RUNNER_DESCRIPTION" + /// The unique id of runner being used + static member RunnerId = Environment.environVar "CI_RUNNER_ID" + /// The defined runner tags + static member RunnerTags = Environment.environVar "CI_RUNNER_TAGS" + /// GitLab Runner version that is executing the current job + static member RunnerVersion = Environment.environVar "CI_RUNNER_VERSION" + /// GitLab Runner revision that is executing the current job + static member RunnerRevision = Environment.environVar "CI_RUNNER_REVISION" + /// The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor) + static member RunnerExecutableArch = Environment.environVar "CI_RUNNER_EXECUTABLE_ARCH" + /// The unique id of the current pipeline that GitLab CI uses internally static member PipelineId = Environment.environVar "CI_PIPELINE_ID" + /// The unique id of the current pipeline scoped to project + static member PipelineIID = Environment.environVar "CI_PIPELINE_IID" + /// The flag to indicate that job was triggered + static member PipelineTriggered = Environment.hasEnvironVar "CI_PIPELINE_TRIGGERED" + /// Indicates how the pipeline was triggered. Possible options are: push, web, trigger, schedule, api, and pipeline. For pipelines created before GitLab 9.5, this will show as unknown + static member PipelineSource = Environment.environVar "CI_PIPELINE_SOURCE" + /// The full path where the repository is cloned and where the job is run + static member ProjectDir = Environment.environVar "CI_PROJECT_DIR" + /// The unique id of the current project that GitLab CI uses internally + static member ProjectId = Environment.environVar "CI_PROJECT_ID" + /// The project name that is currently being built (actually it is project folder name) + static member ProjectName = Environment.environVar "CI_PROJECT_NAME" + /// The project namespace (username or groupname) that is currently being built + static member ProjectNamespace = Environment.environVar "CI_PROJECT_NAMESPACE" + /// The namespace with project name + static member ProjectPath = Environment.environVar "CI_PROJECT_PATH" + /// $CI_PROJECT_PATH lowercased and with everything except 0-9 and a-z replaced with -. Use in URLs and domain names. + static member ProjectPathSlug = Environment.environVar "CI_PROJECT_PATH_SLUG" + /// Pipeline details URL + static member PipelineUrl = Environment.environVar "CI_PIPELINE_URL" + /// The HTTP address to access project + static member ProjectUrl = Environment.environVar "CI_PROJECT_URL" + /// The project visibility (internal, private, public) + static member ProjectVisibility = Environment.environVar "CI_PROJECT_VISIBILITY" + /// If the Container Registry is enabled it returns the address of GitLab's Container Registry + static member Registry = Environment.environVar "CI_REGISTRY" + /// If the Container Registry is enabled for the project it returns the address of the registry tied to the specific project + static member RegistryImage = Environment.environVar "CI_REGISTRY_IMAGE" + /// The password to use to push containers to the GitLab Container Registry + static member RegistryPassword = Environment.environVar "CI_REGISTRY_PASSWORD" + /// The username to use to push containers to the GitLab Container Registry + static member RegistryUser = Environment.environVar "CI_REGISTRY_USER" + /// Mark that job is executed in CI environment + static member Server = Environment.hasEnvironVar "CI_SERVER" + /// The name of CI server that is used to coordinate jobs + static member ServerName = Environment.environVar "CI_SERVER_NAME" + /// GitLab revision that is used to schedule jobs + static member ServerRevision = Environment.environVar "CI_SERVER_REVISION" + /// GitLab version that is used to schedule jobs + static member ServerVersion = Environment.environVar "CI_SERVER_VERSION" + /// Marks that the job is executed in a shared environment (something that is persisted across CI invocations like shell or ssh executor). If the environment is shared, it is set to true, otherwise it is not defined at all. + static member SharedEnvironment = Environment.hasEnvironVar "CI_SHARED_ENVIRONMENT" + /// Number of attempts to fetch sources running a job + static member GetSourcesAttempts = Environment.environVar "GET_SOURCES_ATTEMPTS" + /// Mark that job is executed in GitLab CI environment + static member GitlabCI = Environment.environVar "GITLAB_CI" + /// The email of the user who started the job + static member GitlabUserEmail = Environment.environVar "GITLAB_USER_EMAIL" + /// The id of the user who started the job + static member GitlabUserId = Environment.environVar "GITLAB_USER_ID" + /// The login username of the user who started the job + static member GitlabUserLogin = Environment.environVar "GITLAB_USER_LOGIN" + /// The real name of the user who started the job + static member GitlabUserName = Environment.environVar "GITLAB_USER_NAME" + /// The comma separated list of licensed features available for your instance and plan + static member GitlabFeatures = Environment.environVar "GITLAB_FEATURES" + /// Number of attempts to restore the cache running a job + static member RestoreCacheAttempts = Environment.environVar "RESTORE_CACHE_ATTEMPTS" /// Implements a TraceListener for TeamCity build servers. /// ## Parameters From 2237a6fc98dec94175ade594cff7506a595435f9 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 13:14:43 +0200 Subject: [PATCH 06/14] Add support for artifacts with custom names (in particular TFS/VSTS) --- help/markdown/buildserver.md | 2 +- src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs | 2 ++ src/app/Fake.BuildServer.GitLab/GitLab.fs | 1 + src/app/Fake.BuildServer.TeamCity/TeamCity.fs | 2 ++ .../TeamFoundation.fs | 2 ++ src/app/Fake.Core.Trace/TraceListener.fs | 19 +++++++++++++++++++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/help/markdown/buildserver.md b/help/markdown/buildserver.md index 097d534cf81..ded7199a497 100644 --- a/help/markdown/buildserver.md +++ b/help/markdown/buildserver.md @@ -63,4 +63,4 @@ Target.create "Test" (fun _ -> ## Implementing support for a build-server -Please look at the existing implementations. +Please look at the existing implementations. Please contribute new implementations to the repository. Some changes like adding new cases to the `TraceListener` module are not considered breaking changes. Using these types (using `match` on these types to be exact) outside the fake repository is not considered good practice. diff --git a/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs b/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs index 63ff944c113..e8a028f9949 100644 --- a/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs +++ b/src/app/Fake.BuildServer.AppVeyor/AppVeyor.fs @@ -19,6 +19,7 @@ module AppVeyorImportExtensions = type ImportData with member x.AppVeyorName = match x with + | ImportData.BuildArtifactWithName _ | ImportData.BuildArtifact -> "buildArtifact" | ImportData.DotNetCoverage _ -> "dotNetCoverage" | ImportData.DotNetDupFinder -> "DotNetDupFinder" @@ -292,6 +293,7 @@ module AppVeyor = AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.Xunit path | TraceData.ImportData (ImportData.Junit, path) -> AppVeyorInternal.UploadTestResultsFile AppVeyorInternal.TestResultsType.JUnit path + | TraceData.ImportData (ImportData.BuildArtifactWithName _, path) | TraceData.ImportData (ImportData.BuildArtifact, path) -> AppVeyorInternal.PushArtifact (fun parms -> { parms with Path = path; FileName = Path.GetFileName path }) | TraceData.ImportData (typ, path) -> diff --git a/src/app/Fake.BuildServer.GitLab/GitLab.fs b/src/app/Fake.BuildServer.GitLab/GitLab.fs index 873d89b7435..a8fcb19971a 100644 --- a/src/app/Fake.BuildServer.GitLab/GitLab.fs +++ b/src/app/Fake.BuildServer.GitLab/GitLab.fs @@ -18,6 +18,7 @@ module GitLabImportExtensions = type ImportData with member x.GitLabName = match x with + | ImportData.BuildArtifactWithName _ | ImportData.BuildArtifact -> "buildArtifact" | ImportData.DotNetCoverage _ -> "dotNetCoverage" | ImportData.DotNetDupFinder -> "DotNetDupFinder" diff --git a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs index 436155a1b54..4f64a9a648c 100644 --- a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs +++ b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs @@ -17,6 +17,7 @@ module TeamCityImportExtensions = type ImportData with member x.TeamCityName = match x with + | ImportData.BuildArtifactWithName _ | ImportData.BuildArtifact -> "buildArtifact" | ImportData.DotNetCoverage _ -> "dotNetCoverage" | ImportData.DotNetDupFinder -> "DotNetDupFinder" @@ -275,6 +276,7 @@ module TeamCity = ConsoleWriter.write false color true text | TraceData.LogMessage(text, newLine) | TraceData.TraceMessage(text, newLine) -> ConsoleWriter.write false color newLine text + | TraceData.ImportData (ImportData.BuildArtifactWithName _, path) | TraceData.ImportData (ImportData.BuildArtifact, path) -> publishArtifact path | TraceData.ImportData (ImportData.DotNetCoverage tool, path) -> diff --git a/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs b/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs index d87666d2cc8..0635a90d42d 100644 --- a/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs +++ b/src/app/Fake.BuildServer.TeamFoundation/TeamFoundation.fs @@ -140,6 +140,8 @@ module TeamFoundation = | TagStatus.Warning -> "SucceededWithIssues", "WARN" | TagStatus.Failed -> "Failed", "ERROR" setBuildState vsoState msg + | TraceData.ImportData (ImportData.BuildArtifactWithName name as typ, path) -> + publishArtifact typ.Name (Some name) path | TraceData.ImportData (typ, path) -> publishArtifact typ.Name (Some "fake-artifacts") path | TraceData.TestOutput (test, out, err) -> diff --git a/src/app/Fake.Core.Trace/TraceListener.fs b/src/app/Fake.Core.Trace/TraceListener.fs index fb2f1d252cf..678b86f0a78 100644 --- a/src/app/Fake.Core.Trace/TraceListener.fs +++ b/src/app/Fake.Core.Trace/TraceListener.fs @@ -3,6 +3,8 @@ namespace Fake.Core open System +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type KnownTags = | Task of name:string @@ -34,6 +36,8 @@ type KnownTags = | Test _ -> "test" | Other (t, _) -> t +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type DotNetCoverageTool = | DotCover @@ -47,14 +51,19 @@ type DotNetCoverageTool = | NCover -> "ncover" | NCover3 -> "ncover3" +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type NunitDataVersion = | Nunit | Nunit3 +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type ImportData = | BuildArtifact + | BuildArtifactWithName of artifactName:string | DotNetCoverage of DotNetCoverageTool | DotNetDupFinder | PmdCpd @@ -73,6 +82,8 @@ type ImportData = member x.Name = match x with | BuildArtifact -> "buildArtifact" + // Some build servers like TFS allow to group artifacts by name. + | BuildArtifactWithName _ -> "buildArtifactWithName" | DotNetCoverage _ -> "dotNetCoverage" | DotNetDupFinder -> "DotNetDupFinder" | PmdCpd -> "pmdCpd" @@ -91,9 +102,12 @@ type ImportData = | Nunit NunitDataVersion.Nunit3 -> "nunit3" override x.ToString() = match x with + | BuildArtifactWithName name -> sprintf "buildArtifact (%s)" name | DotNetCoverage tool -> sprintf "dotNetCoverage (%O)" tool | _ -> x.Name +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type TestStatus = | Ignored of message:string @@ -108,6 +122,8 @@ module TestStatus = TestStatus.Failed (f message, f details, None) | _ -> t +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type TagStatus = | Success @@ -115,6 +131,8 @@ type TagStatus = | Failed /// Defines Tracing information for TraceListeners +/// Note: Adding new cases to this type is not considered a breaking change! +/// Please consider not using a match on this type in code external to the fake repository. [] type TraceData = | ImportData of typ:ImportData * path:string @@ -173,6 +191,7 @@ module TraceData = mapMessage (repl oldString replacement) t /// Defines a TraceListener interface +/// Note: Please contribute implementations to the fake repository, as external implementations are not supported. type ITraceListener = abstract Write : TraceData -> unit From 4beb14807ce21c3004e5b113e4daa15a27d28ec5 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 14:02:56 +0200 Subject: [PATCH 07/14] read encoding and default to writing without bom, fixes https://github.com/fsharp/FAKE/issues/2032 --- src/app/Fake.IO.FileSystem/File.fs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/Fake.IO.FileSystem/File.fs b/src/app/Fake.IO.FileSystem/File.fs index 405901dd1d2..fd1ce805af1 100644 --- a/src/app/Fake.IO.FileSystem/File.fs +++ b/src/app/Fake.IO.FileSystem/File.fs @@ -12,6 +12,8 @@ module FileFilter = [] module File = + /// see https://stackoverflow.com/questions/2502990/create-text-file-without-bom + let internal utf8WithoutBom = new UTF8Encoding(false) // Detect the encoding, from https://stackoverflow.com/questions/3825390/effective-way-to-find-any-files-encoding let getEncoding def filename = @@ -41,6 +43,9 @@ module File = if not (exists filename) then def else getEncoding def filename + /// Get the encoding from the file or utf8 without BOM if unknown or the file doesn't exist + let getEncodingOrUtf8WithoutBom = getEncodingOrDefault utf8WithoutBom + /// Raises an exception if the file doesn't exist on disk. let checkExists fileName = if not <| exists fileName then @@ -86,7 +91,7 @@ module File = while not textReader.EndOfStream do yield textReader.ReadLine() } - let read (file : string) = readWithEncoding (getEncodingOrDefault Encoding.UTF8 file) file + let read (file : string) = readWithEncoding (getEncodingOrUtf8WithoutBom file) file /// Reads the first line of a file. This can be helpful to read a password from file. let readLineWithEncoding (encoding:Encoding) (file : string) = @@ -95,7 +100,7 @@ module File = sr.ReadLine() /// Reads the first line of a file. This can be helpful to read a password from file. - let readLine(file : string) = readLineWithEncoding (getEncodingOrDefault Encoding.UTF8 file) file + let readLine(file : string) = readLineWithEncoding (getEncodingOrUtf8WithoutBom file) file /// Writes a file line by line let writeWithEncoding (encoding:Encoding) append fileName (lines : seq) = @@ -104,7 +109,7 @@ module File = use writer = new StreamWriter(file, encoding) lines |> Seq.iter writer.WriteLine - let write append fileName (lines : seq) = writeWithEncoding (getEncodingOrDefault Encoding.UTF8 fileName) append fileName lines + let write append fileName (lines : seq) = writeWithEncoding (getEncodingOrUtf8WithoutBom fileName) append fileName lines /// Writes a byte array to a file let writeBytes file bytes = File.WriteAllBytes(file, bytes) @@ -116,7 +121,7 @@ module File = use writer = new StreamWriter(file, encoding) writer.Write text - let writeString append fileName (text : string) = writeStringWithEncoding (getEncodingOrDefault Encoding.UTF8 fileName) append fileName text + let writeString append fileName (text : string) = writeStringWithEncoding (getEncodingOrUtf8WithoutBom fileName) append fileName text /// Replaces the file with the given string let replaceContent fileName text = @@ -134,7 +139,7 @@ module File = /// Reads a file as one text let inline readAsStringWithEncoding encoding file = File.ReadAllText(file, encoding) - let inline readAsString file = File.ReadAllText(file, (getEncodingOrDefault Encoding.UTF8 file)) + let inline readAsString file = File.ReadAllText(file, (getEncodingOrUtf8WithoutBom file)) /// Reads a file as one array of bytes let readAsBytes file = File.ReadAllBytes file From 54e90c8b2949e70212666d8082233d596ac2a0e5 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 14:14:14 +0200 Subject: [PATCH 08/14] update to 302 --- .travis.yml | 2 +- build.fsx | 2 +- global.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fdbdaf5ef7c..cff7af3f724 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required dist: trusty # Ubuntu 14.04 -dotnet : 2.1.300 +dotnet : 2.1.302 env: - HOME=/home/travis APPDATA=/home/travis LocalAppData=/home/travis diff --git a/build.fsx b/build.fsx index 680a34703b5..73b277f6c78 100644 --- a/build.fsx +++ b/build.fsx @@ -149,7 +149,7 @@ Trace.setBuildNumber nugetVersion // CoreTracing.setTraceListeners (CoreTracing.defaultConsoleTraceListener :: current) -let dotnetSdk = lazy DotNet.install DotNet.Versions.Release_2_1_300 +let dotnetSdk = lazy DotNet.install DotNet.Versions.Release_2_1_302 let inline dtntWorkDir wd = DotNet.Options.lift dotnetSdk.Value >> DotNet.Options.withWorkingDirectory wd diff --git a/global.json b/global.json index b3740b016b1..56154ef0a9f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk" : { - "version": "2.1.300" + "version": "2.1.302" } } From 6682b4fbf2c7f8a0a77c0cfc627de25aedf19573 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 14:48:09 +0200 Subject: [PATCH 09/14] Releasenotes and fix https://github.com/fsharp/FAKE/issues/2046 --- RELEASE_NOTES.md | 7 +++++-- src/app/Fake.Core.Process/Process.fs | 6 ++++-- src/app/Fake.DotNet.Cli/DotNet.fs | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4168c3e016a..08e6761a447 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,8 +1,11 @@ # Release Notes -## 5.3.2-alpha - vnext +## 5.4.0-alpha - vnext -* TBD. +* ENHANCEMENT: Template always uses latest version now - https://github.com/fsharp/FAKE/pull/2055 +* ENHANCEMENT: Add all environment variables - https://github.com/fsharp/FAKE/pull/2059 +* BUGFIX: Use UTF8 without BOM by default - https://github.com/fsharp/FAKE/issues/2032 +* BUGFIX: Improve error message when starting dotnet-cli with incorrect working directory - https://github.com/fsharp/FAKE/issues/2046 ## 5.3.1 - 2018-08-06 diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 2dd95d97d86..c0429f5a16d 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -428,9 +428,11 @@ module Process = //platformInfoAction proc.StartInfo if String.isNullOrEmpty proc.StartInfo.WorkingDirectory |> not then - if Directory.Exists proc.StartInfo.WorkingDirectory |> not then - failwithf "Start of process %s failed. WorkingDir %s does not exist." proc.StartInfo.FileName + if Directory.Exists proc.StartInfo.WorkingDirectory |> not then + sprintf "Start of process '%s' failed. WorkingDir '%s' does not exist." proc.StartInfo.FileName proc.StartInfo.WorkingDirectory + |> DirectoryNotFoundException + |> raise if silent then proc.StartInfo.RedirectStandardOutput <- true proc.StartInfo.RedirectStandardError <- true diff --git a/src/app/Fake.DotNet.Cli/DotNet.fs b/src/app/Fake.DotNet.Cli/DotNet.fs index 315a35435b2..bb8bd309e1f 100644 --- a/src/app/Fake.DotNet.Cli/DotNet.fs +++ b/src/app/Fake.DotNet.Cli/DotNet.fs @@ -544,7 +544,7 @@ module DotNet = else workDir "global.json" let writtenJson = match version with - | Some version -> + | Some version when Directory.Exists workDir -> // make sure to write global.json if we did not read the version from it // We need to do this as the SDK will use this file to select the actual version // See https://github.com/fsharp/FAKE/pull/1963 and related discussions @@ -556,7 +556,7 @@ module DotNet = let template = sprintf """{ "sdk": { "version": "%s" } }""" version File.WriteAllText(globalJsonPath, template) true - | None -> false + | _ -> false try f () finally if writtenJson then File.delete globalJsonPath From 0f7afe668945dcea3f8c0f3b4411859d61cfccb6 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 14:58:36 +0200 Subject: [PATCH 10/14] docs --- help/markdown/fake-dotnetcore.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/help/markdown/fake-dotnetcore.md b/help/markdown/fake-dotnetcore.md index 09a89ff19bf..5dd83e1b4ce 100644 --- a/help/markdown/fake-dotnetcore.md +++ b/help/markdown/fake-dotnetcore.md @@ -22,7 +22,7 @@ Just install the corresponding package for your system:
         
-        choco install fake -pre
+        choco install fake
         
     
@@ -35,10 +35,14 @@ Just install the corresponding package for your system:
         
-        dotnet tool install fake-cli -g --version=5.*
+        dotnet tool install fake-cli -g
         
     
+- Debian package + + - the .deb file can be downloaded from the [releases-page](https://github.com/fsharp/FAKE/releases) + - Others We currently do not have packages for the various distributions, look for [other ways to install fake](fake-gettingstarted.html#Install-FAKE). From 4135c3ba072e6d2b5b55f6f786c6db8bc1e47f9a Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 15:06:53 +0200 Subject: [PATCH 11/14] oO --- build.fsx | 1 + 1 file changed, 1 insertion(+) diff --git a/build.fsx b/build.fsx index 73b277f6c78..d7710e3b534 100644 --- a/build.fsx +++ b/build.fsx @@ -808,6 +808,7 @@ Target.create "DotNetCoreCreateDebianPackage" (fun _ -> sprintf "/p:TargetFramework=%s" targetFramework sprintf "/p:CustomTarget=%s" "CreateDeb" sprintf "/p:RuntimeIdentifier=%s" runtime + sprintf "/p:RuntimeIdentifiers=%s" runtime sprintf "/p:Configuration=%s" "Release" sprintf "/p:PackageVersion=%s" simpleVersion ] |> String.concat " " From 951d89ef9a34fe25e8e5706563b66f2e2a94982d Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 16:02:16 +0200 Subject: [PATCH 12/14] add restore to the same msbuild call :/ --- build.fsx | 8 +------- src/app/fake-cli/fake-cli.fsproj | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/build.fsx b/build.fsx index d7710e3b534..6b13fedd5f0 100644 --- a/build.fsx +++ b/build.fsx @@ -795,20 +795,14 @@ Target.create "CheckReleaseSecrets" (fun _ -> Target.create "DotNetCoreCreateDebianPackage" (fun _ -> - DotNet.restore (fun opt -> - { opt with - Common = { opt.Common with WorkingDirectory = "src/app/fake-cli/" } |> dtntSmpl - Runtime = Some "linux-x64"}) "fake-cli.fsproj" - let runtime = "linux-x64" let targetFramework = "netcoreapp2.1" let args = [ - sprintf "/t:%s" "CreateDeb" + sprintf "/t:%s" "Restore;CreateDeb" sprintf "/p:TargetFramework=%s" targetFramework sprintf "/p:CustomTarget=%s" "CreateDeb" sprintf "/p:RuntimeIdentifier=%s" runtime - sprintf "/p:RuntimeIdentifiers=%s" runtime sprintf "/p:Configuration=%s" "Release" sprintf "/p:PackageVersion=%s" simpleVersion ] |> String.concat " " diff --git a/src/app/fake-cli/fake-cli.fsproj b/src/app/fake-cli/fake-cli.fsproj index 725bc6139df..83009af59a7 100644 --- a/src/app/fake-cli/fake-cli.fsproj +++ b/src/app/fake-cli/fake-cli.fsproj @@ -11,7 +11,7 @@ - win7-x86;win7-x64;osx.10.11-x64;linux-x64 + linux-x64 /opt/fake From ab10ea6d928dfc3431adc6554a25debda06e13f2 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 18:00:01 +0200 Subject: [PATCH 13/14] fix docs. --- help/markdown/dotnet-cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help/markdown/dotnet-cli.md b/help/markdown/dotnet-cli.md index 050f8663552..c64d0171c57 100644 --- a/help/markdown/dotnet-cli.md +++ b/help/markdown/dotnet-cli.md @@ -10,7 +10,7 @@ nuget Fake.DotNet.Cli //" open Fake.DotNet // Lazily install DotNet SDK in the correct version if not available -let install = lazy DotNet.Install DotNet.Release_2_1_4 +let install = lazy DotNet.install DotNet.Versions.Release_2_1_4 // Define general properties across various commands (with arguments) let inline withWorkDir wd = From 66c6938c274ef949b6ce0672afe799806a0ac287 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Sat, 11 Aug 2018 18:18:43 +0200 Subject: [PATCH 14/14] release 5.4.0 --- RELEASE_NOTES.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 08e6761a447..b1c06e13796 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,9 +1,10 @@ # Release Notes -## 5.4.0-alpha - vnext +## 5.4.0 - 2018-08-11 * ENHANCEMENT: Template always uses latest version now - https://github.com/fsharp/FAKE/pull/2055 -* ENHANCEMENT: Add all environment variables - https://github.com/fsharp/FAKE/pull/2059 +* ENHANCEMENT: Add all GITLAB environment variables - https://github.com/fsharp/FAKE/pull/2059 +* ENHANCEMENT: Support naming of artifacts in TFS/VSTS - https://github.com/fsharp/FAKE/pull/2056 * BUGFIX: Use UTF8 without BOM by default - https://github.com/fsharp/FAKE/issues/2032 * BUGFIX: Improve error message when starting dotnet-cli with incorrect working directory - https://github.com/fsharp/FAKE/issues/2046