diff --git a/Fake.sln b/Fake.sln index 74d6c0d12c1..be03269ca1d 100644 --- a/Fake.sln +++ b/Fake.sln @@ -172,8 +172,6 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Vault", "src\app\ EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Installer.Squirrel", "src\app\Fake.Installer.Squirrel\Fake.Installer.Squirrel.fsproj", "{3DEF2E95-4BF8-413F-930E-32103A39364A}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Sql.SqlServer", "src\app\Fake.Sql.SqlServer\Fake.Sql.SqlServer.fsproj", "{2EEAD673-45BE-4836-90B4-CF545877ACB9}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1072,18 +1070,6 @@ Global {3DEF2E95-4BF8-413F-930E-32103A39364A}.Release|x64.Build.0 = Release|Any CPU {3DEF2E95-4BF8-413F-930E-32103A39364A}.Release|x86.ActiveCfg = Release|Any CPU {3DEF2E95-4BF8-413F-930E-32103A39364A}.Release|x86.Build.0 = Release|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Debug|x64.ActiveCfg = Debug|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Debug|x64.Build.0 = Debug|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Debug|x86.ActiveCfg = Debug|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Debug|x86.Build.0 = Debug|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Release|Any CPU.Build.0 = Release|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Release|x64.ActiveCfg = Release|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Release|x64.Build.0 = Release|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Release|x86.ActiveCfg = Release|Any CPU - {2EEAD673-45BE-4836-90B4-CF545877ACB9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1165,7 +1151,6 @@ Global {F1641150-B89D-40B7-A3BE-9DC357410FDA} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} {AAAF92C5-C40D-40B8-84BA-137DF0E98B56} = {901F162F-8925-4390-89C5-9EE2C343F744} {3DEF2E95-4BF8-413F-930E-32103A39364A} = {901F162F-8925-4390-89C5-9EE2C343F744} - {2EEAD673-45BE-4836-90B4-CF545877ACB9} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {058A0C5E-2216-4306-8AFB-0AE28320C26A} diff --git a/README.markdown b/README.markdown index daf765f65c3..a1be2e4686a 100644 --- a/README.markdown +++ b/README.markdown @@ -24,7 +24,7 @@ See the [project home page](https://fake.build/) for tutorials and [API document > - when you are on linux and do not have mono installed > - when you are on windows and do not have Visual Studio installed > -> Either build only the `netcore` parts via `fake build target FullDotNetCore` or install the requirements accoding to the [contributing page](http://fsharp.github.com/FAKE/contributing.html) +> Either build only the `netcore` parts via `fake build target FullDotNetCore` or install the requirements according to the [contributing page](http://fsharp.github.com/FAKE/contributing.html) Make sure to have long path enabled: https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing Otherwise the test-suite will fail (However, the compilation should work) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e14d7ffd375..b45010e11d2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,12 +1,18 @@ # Release Notes -## 5.8.0 - 2018-09-27 +## 5.8.4 - 2018-10-08 -* NEW: Fake.Sql.SqlServer module - https://github.com/fsharp/FAKE/pull/2074 * ENHANCEMENT: Some modules are now usable without FAKE context (ie. in your regular projects) * ENHANCEMENT: Inform when the `target` environment variable is used - https://github.com/fsharp/FAKE/issues/2107 +* ENHANCEMENT: Improve TeamCity support - https://github.com/fsharp/FAKE/pull/2111 +* ENHANCEMENT: Update Netstandard.Library package to `2.0.3` - https://github.com/fsharp/FAKE/pull/2106 +* ENHANCEMENT: Add `Process.getFileName` api to retrieve the full-path of a given process +* ENHANCEMENT: Kill existing running `dotnet.exe` processes before running the dotnet-cli installer * BUGFIX: Environment variables are case insensitive on windows, fake will now throw exceptions if it detects invalid environment maps * BUGFIX: MSBuild properties containing special characters lead to errors - https://github.com/fsharp/FAKE/issues/2112 +* BUGFIX: Improve error message when release notes are invalid - https://github.com/fsharp/FAKE/issues/2085 +* BUGFIX: Improve error message when globbing pattern is invalid - https://github.com/fsharp/FAKE/issues/2073 +* BUGFIX: Do no longer provide the `--parallel` argument by default when running expecto - https://github.com/fsharp/FAKE/issues/2039 * DOCS: Fix syntax errors in dacpac docs - https://github.com/fsharp/FAKE/pull/2115 ## 5.7.2 - 2018-09-24 @@ -109,7 +115,7 @@ * NEW: module Fake.Tools.GitVersion to interact with gitversion.exe - https://github.com/fsharp/FAKE/pull/1988 * ENHANCEMENT: Add `traceImportantf` and `traceErrorf` - https://github.com/fsharp/FAKE/pull/1986 * ENHANCEMENT: Minimalize dependencies between FAKE packages - https://github.com/fsharp/FAKE/pull/1980 -* ENHANCEMENT: Change chocolatey package accoding to feedback - https://github.com/fsharp/FAKE/pull/1983 +* ENHANCEMENT: Change chocolatey package according to feedback - https://github.com/fsharp/FAKE/pull/1983 * BUGFIX: Fix locating kudusync.cmd in Fake.Azure.Kudu - https://github.com/fsharp/FAKE/pull/1995 * NEW: module Fake.Core.UserInput - https://github.com/fsharp/FAKE/pull/1997 @@ -144,7 +150,7 @@ ## 5.0.0-rc017 - 2018-05-22 -* BREAKING: Add some `[]` attributes accoding to API-Guidelines (Target, Globbing, AssemblyInfoFile) +* BREAKING: Add some `[]` attributes according to API-Guidelines (Target, Globbing, AssemblyInfoFile) * ENHANCEMENT: Mark `Target.DoNothing` as obsolete * ENHANCEMENT: Mark `Target.Description` as obsolete and add `Target.description` * BUGFIX: Includes fixes from 4.64.12 diff --git a/build.fsx b/build.fsx index cf0aec50600..916459e8c1e 100644 --- a/build.fsx +++ b/build.fsx @@ -59,6 +59,56 @@ open Fake.Windows open Fake.DotNet open Fake.DotNet.Testing +// WORKAROUND TEAMCITY +#if !BOOTSTRAP +module Kernel32 = + open System + open System.Text + open System.Diagnostics + open System.Runtime.InteropServices + [] + extern UInt32 QueryFullProcessImageName(IntPtr hProcess, UInt32 flags, StringBuilder text, [] UInt32& size) + + let getPathToApp (proc:Process) = + let mutable nChars = 256u + let Buff = new StringBuilder(int nChars); + + let success = QueryFullProcessImageName(proc.Handle, 0u, Buff, &nChars) + + if (0u <> success) then + Buff.ToString() + else + let hresult = Marshal.GetHRForLastWin32Error() + Marshal.ThrowExceptionForHR hresult + "Error = " + string hresult + " when calling GetProcessImageFileName" + +do + let dir = + if Environment.isUnix + then Environment.environVar "HOME" @@ ".dotnet" + else Environment.environVar "LocalAppData" @@ "Microsoft" @@ "dotnet" + + let getProcessFileName (p:System.Diagnostics.Process) = + if Environment.isWindows then + Kernel32.getPathToApp p + else + p.MainModule.FileName + + let dotnetExe = Path.Combine(dir, if Environment.isUnix then "dotnet" else "dotnet.exe") + if File.Exists(dotnetExe) then + System.Diagnostics.Process.GetProcesses() + |> Seq.filter (fun p -> + try + not p.HasExited + with _ -> false) + |> Seq.filter (fun p -> + try + Path.GetFullPath(getProcessFileName p).ToLowerInvariant() = + Path.GetFullPath(dotnetExe) + with _ -> false) + |> Seq.iter Process.kill +#endif + // Set this to true if you have lots of breaking changes, for small breaking changes use #if BOOTSTRAP, setting this flag will not be accepted let disableBootstrap = false @@ -95,15 +145,10 @@ let legacyDir = srcDir"legacy" let nuget_exe = Directory.GetCurrentDirectory() "packages" "build" "NuGet.CommandLine" "tools" "NuGet.exe" -let vault = - match Vault.fromFakeEnvironmentOrNone() with - | Some v -> v - | None -> TeamFoundation.variables -let getVarOrDefault name def = - match vault.TryGet name with - | Some v -> v - | None -> Environment.environVarOrDefault name def +let vault = ``Legacy-build``.vault +let getVarOrDefault name def = ``Legacy-build``.getVarOrDefault name def +let releaseSecret replacement name = ``Legacy-build``.releaseSecret replacement name let github_release_user = getVarOrDefault "github_release_user" "fsharp" let nugetsource = getVarOrDefault "nugetsource" "https://www.nuget.org/api/v2/package" @@ -113,20 +158,6 @@ let docsDomain = getVarOrDefault "docs_domain" "fake.build" let buildLegacy = System.Boolean.Parse(getVarOrDefault "BuildLegacy" "false") let fromArtifacts = not <| String.isNullOrEmpty artifactsDir -let mutable secrets = [] -let releaseSecret replacement name = - let secret = - lazy - let env = - match getVarOrDefault name "default_unset" with - | "default_unset" -> failwithf "variable '%s' is not set" name - | s -> s - if BuildServer.buildServer <> BuildServer.TeamFoundation then - // on TFS/VSTS the build will take care of this. - TraceSecrets.register replacement env - env - secrets <- secret :: secrets - secret let apikey = releaseSecret "" "nugetkey" let chocoKey = releaseSecret "" "CHOCOLATEY_API_KEY" @@ -140,6 +171,8 @@ BuildServer.install [ GitLab.Installer ] + + let version = ``Legacy-build``.version let simpleVersion = ``Legacy-build``.simpleVersion let nugetVersion = ``Legacy-build``.nugetVersion @@ -809,7 +842,7 @@ Target.create "DotNetCorePushChocolateyPackage" (fun _ -> ) Target.create "CheckReleaseSecrets" (fun _ -> - for secret in secrets do + for secret in ``Legacy-build``.secrets do secret.Force() |> ignore ) diff --git a/help/markdown/core-commandlineparsing.md b/help/markdown/core-commandlineparsing.md index 34d5a2040d1..87cdb298651 100644 --- a/help/markdown/core-commandlineparsing.md +++ b/help/markdown/core-commandlineparsing.md @@ -55,33 +55,35 @@ You can also take a look at the test-suite: - We return the arguments in the user given order in the result map (difference to `docopt.fs`) - We parse arguments starting with `-` as positional arguments. For example consider: -```bash -usage: prog (NAME | --foo NAME) + ```bash + usage: prog (NAME | --foo NAME) + + options: --foo + ``` + +
+
INFO
+

Note that --foo has no argument because it was not specified in the options section!

+
+ + In this scenario `prog --foo 10` is parsed as `--foo` and `NAME` argument because that is the only option. However `prog --foo=10` is parsed as `NAME` argument without any `--foo` option. Usually to prefer `--foo` you should put it first in the usage string: + + ```bash + usage: prog (--foo NAME | NAME) + + options: --foo + ``` + + However, in this particular case it doesn't make any difference (as the options section is missing to indicate that `--foo` has an argument). -options: --foo -``` -
-
INFO
-

Note that --foo has no argument because it was not specified in the options section!

-
- -In this scenario `prog --foo 10` is parsed as `--foo` and `NAME` argument because that is the only option. However `prog --foo=10` is parsed as `NAME` argument without any `--foo` option. Usually to prefer `--foo` you should put it first in the usage string: - -```bash -usage: prog (--foo NAME | NAME) - -options: --foo -``` - - However, in this particular case it doesn't make any difference. - `[]` is not inherited for all items, only for the group. To have all items optional use `[]` on every item. For example `usage: prog [go go]` means to have either two `go` or none. A single one is not allowed. - We do not merge external "options" in the usage string with `[options]`. For example: -```bash -usage: prog [options] [-a] - -options: -a - -b -``` - -Means that `-a` is actually allowed twice. + ```bash + usage: prog [options] [-a] + + options: -a + -b + ``` + + Means that `-a` is actually allowed twice. diff --git a/integrationtests/core-context-exists/before/context.exists.fsx b/integrationtests/core-context-exists/before/context.exists.fsx index 8011ef293a8..171599d8338 100644 --- a/integrationtests/core-context-exists/before/context.exists.fsx +++ b/integrationtests/core-context-exists/before/context.exists.fsx @@ -1,7 +1,7 @@ #if FAKE_DEPENDENCIES #r "paket: storage: none -source https://nuget.org/api/v2 +source https://api.nuget.org/v3/index.json source ../../../release/dotnetcore //source https://ci.appveyor.com/nuget/paket diff --git a/integrationtests/core-no-dependencies-hello-world/before/paket.dependencies b/integrationtests/core-no-dependencies-hello-world/before/paket.dependencies index 3c787c5f828..b713a9271bb 100644 --- a/integrationtests/core-no-dependencies-hello-world/before/paket.dependencies +++ b/integrationtests/core-no-dependencies-hello-world/before/paket.dependencies @@ -1,7 +1,7 @@ // [ FAKE GROUP ] group netcore storage: none -source https://nuget.org/api/v2 +source https://api.nuget.org/v3/index.json //source https://ci.appveyor.com/nuget/paket source https://ci.appveyor.com/nuget/fake diff --git a/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx b/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx index 8faa0340a99..1f7cb84fe43 100644 --- a/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx +++ b/integrationtests/core-reference-fake-core-targets/before/reference_fake-targets.fsx @@ -1,6 +1,6 @@ #if FAKE_DEPENDENCIES #r "paket: -source https://nuget.org/api/v2 +source https://api.nuget.org/v3/index.json source ../../../release/dotnetcore nuget Fake.Core.Target prerelease diff --git a/integrationtests/core-reference-fake-runtime/before/reference_fake-runtime.fsx b/integrationtests/core-reference-fake-runtime/before/reference_fake-runtime.fsx index 6311a68d6b6..33da4aa46d2 100644 --- a/integrationtests/core-reference-fake-runtime/before/reference_fake-runtime.fsx +++ b/integrationtests/core-reference-fake-runtime/before/reference_fake-runtime.fsx @@ -1,7 +1,7 @@ #if FAKE_DEPENDENCIES #r "paket: storage: none -source https://nuget.org/api/v2 +source https://api.nuget.org/v3/index.json source ../../../release/dotnetcore //source https://ci.appveyor.com/nuget/paket diff --git a/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx b/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx index d65c4f8cf7c..16aa7195542 100644 --- a/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx +++ b/integrationtests/core-simple-failed-to-compile/before/fail-to-compile.fsx @@ -1,6 +1,6 @@ #if FAKE_DEPENDENCIES #r "paket: -source https://nuget.org/api/v2 +source https://api.nuget.org/v3/index.json source ../../../release/dotnetcore //source https://ci.appveyor.com/nuget/paket diff --git a/integrationtests/core-simple-runtime-error/before/mydir/_._ b/integrationtests/core-simple-runtime-error/before/mydir/_._ new file mode 100644 index 00000000000..e69de29bb2d diff --git a/integrationtests/core-simple-runtime-error/before/runtime-error.fsx b/integrationtests/core-simple-runtime-error/before/runtime-error.fsx index b9f9b166004..146db82f730 100644 --- a/integrationtests/core-simple-runtime-error/before/runtime-error.fsx +++ b/integrationtests/core-simple-runtime-error/before/runtime-error.fsx @@ -1,9 +1,12 @@ #if FAKE_DEPENDENCIES #r "paket: storage: none" -#r "paket: source https://nuget.org/api/v2" +#r "paket: source https://api.nuget.org/v3/index.json" #r "paket: source ../../../release/dotnetcore" #r "paket: //source https://ci.appveyor.com/nuget/paket" #r "paket: nuget Fake.Runtime prerelease" #r "paket: nuget FSharp.Core prerelease" #endif + +// Issue https://github.com/fsharp/FAKE/issues/2121 +System.Environment.CurrentDirectory <- System.IO.Path.GetFullPath "mydir" failwith "runtime error" \ No newline at end of file diff --git a/integrationtests/core-use-external-paket-dependencies/before/paket.dependencies b/integrationtests/core-use-external-paket-dependencies/before/paket.dependencies index a809e5804d3..5d056b308f9 100644 --- a/integrationtests/core-use-external-paket-dependencies/before/paket.dependencies +++ b/integrationtests/core-use-external-paket-dependencies/before/paket.dependencies @@ -1,4 +1,4 @@ -source https://nuget.org/api/v2 +source https://api.nuget.org/v3/index.json storage: none //source https://ci.appveyor.com/nuget/paket source ../../../release/dotnetcore diff --git a/legacy-build.fsx b/legacy-build.fsx index a31d29c6693..8d3a3935c8f 100644 --- a/legacy-build.fsx +++ b/legacy-build.fsx @@ -17,7 +17,6 @@ let projectName = "FAKE" let projectSummary = "FAKE - F# Make - Get rid of the noise in your build scripts." let projectDescription = "FAKE - F# Make - is a build automation tool for .NET. Tasks and dependencies are specified in a DSL which is integrated in F#." let authors = ["Steffen Forkmann"; "Mauricio Scheffer"; "Colin Bull"; "Matthias Dittrich"] -let github_release_user = Environment.environVarOrDefault "github_release_user" "fsharp" // The name of the project on GitHub let gitName = "FAKE" @@ -62,8 +61,33 @@ let additionalFiles = [ "./packages/FSharp.Core/lib/net45/FSharp.Core.sigdata" "./packages/FSharp.Core/lib/net45/FSharp.Core.optdata"] - -let nugetsource = Environment.environVarOrDefault "nugetsource" "https://www.nuget.org/api/v2/package" +let vault = + match Vault.fromFakeEnvironmentOrNone() with + | Some v -> v + | None -> TeamFoundation.variables + +let getVarOrDefault name def = + match vault.TryGet name with + | Some v -> v + | None -> Environment.environVarOrDefault name def + +let mutable secrets = [] +let releaseSecret replacement name = + let secret = + lazy + let env = + match getVarOrDefault name "default_unset" with + | "default_unset" -> failwithf "variable '%s' is not set" name + | s -> s + if BuildServer.buildServer <> BuildServer.TeamFoundation then + // on TFS/VSTS the build will take care of this. + TraceSecrets.register replacement env + env + secrets <- secret :: secrets + secret +let github_release_user = getVarOrDefault "github_release_user" "fsharp" +let nugetsource = getVarOrDefault "nugetsource" "https://www.nuget.org/api/v2/package" +let apikey = releaseSecret "" "nugetkey" let version = let segToString = function | PreReleaseSegment.AlphaNumeric n -> n @@ -369,11 +393,13 @@ Target.create "Legacy_CreateNuGet" (fun _ -> Target.create "Legacy_PublishNuget" (fun _ -> // uses NugetKey environment variable. // Timeout atm + Environment.setEnvironVar "nugetkey" apikey.Value Paket.push(fun p -> { p with PublishUrl = nugetsource DegreeOfParallelism = 2 WorkingDir = nugetLegacyDir }) + Environment.setEnvironVar "nugetkey" "" //!! (nugetLegacyDir "**/*.nupkg") //|> Seq.iter nugetPush ) diff --git a/paket.lock b/paket.lock index ac3a6916d44..163387ed3b2 100644 --- a/paket.lock +++ b/paket.lock @@ -4299,7 +4299,7 @@ NUGET System.Xml.ReaderWriter (>= 4.3) - restriction: || (== net46) (&& (== net462) (== netcoreapp2.0)) (&& (== net462) (== netcoreapp2.1)) (&& (== net462) (== netstandard2.0)) (&& (== net462) (< net45)) (&& (== net462) (< netstandard1.4)) (&& (== net462) (< netstandard1.5) (>= uap10.0)) (&& (== net462) (< portable-net45+win8+wpa81)) (&& (== netcoreapp2.0) (< netstandard1.2)) (&& (== netcoreapp2.0) (< netstandard1.3)) (&& (== netcoreapp2.0) (< netstandard1.4)) (&& (== netcoreapp2.0) (< netstandard1.5)) (&& (== netcoreapp2.0) (< netstandard1.6)) (&& (== netcoreapp2.0) (< netstandard2.0)) (&& (== netcoreapp2.0) (< portable-net45+win8+wpa81)) (&& (== netcoreapp2.1) (< netstandard1.2)) (&& (== netcoreapp2.1) (< netstandard1.3)) (&& (== netcoreapp2.1) (< netstandard1.4)) (&& (== netcoreapp2.1) (< netstandard1.5)) (&& (== netcoreapp2.1) (< netstandard1.6)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (< portable-net45+win8+wpa81)) (== netstandard1.6) (&& (== netstandard2.0) (< netstandard1.2)) (&& (== netstandard2.0) (< netstandard1.3)) (&& (== netstandard2.0) (< netstandard1.4)) (&& (== netstandard2.0) (< netstandard1.5)) (&& (== netstandard2.0) (< netstandard1.6)) (&& (== netstandard2.0) (< portable-net45+win8+wpa81)) System.Xml.XDocument (>= 4.3) - restriction: || (&& (== net46) (== netcoreapp2.0)) (&& (== net46) (== netcoreapp2.1)) (&& (== net46) (== netstandard2.0)) (&& (== net46) (< net45)) (&& (== net46) (< portable-net45+win8+wpa81)) (&& (== net46) (>= uap10.0)) (&& (== net462) (== netcoreapp2.0)) (&& (== net462) (== netcoreapp2.1)) (&& (== net462) (== netstandard2.0)) (&& (== net462) (< net45)) (&& (== net462) (< netstandard1.5) (>= uap10.0)) (&& (== net462) (< portable-net45+win8+wpa81)) (&& (== netcoreapp2.0) (< netstandard1.2)) (&& (== netcoreapp2.0) (< netstandard1.3)) (&& (== netcoreapp2.0) (< netstandard1.4)) (&& (== netcoreapp2.0) (< netstandard1.5)) (&& (== netcoreapp2.0) (< netstandard1.6)) (&& (== netcoreapp2.0) (< netstandard2.0)) (&& (== netcoreapp2.0) (< portable-net45+win8+wpa81)) (&& (== netcoreapp2.1) (< netstandard1.2)) (&& (== netcoreapp2.1) (< netstandard1.3)) (&& (== netcoreapp2.1) (< netstandard1.4)) (&& (== netcoreapp2.1) (< netstandard1.5)) (&& (== netcoreapp2.1) (< netstandard1.6)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (< portable-net45+win8+wpa81)) (== netstandard1.6) (&& (== netstandard2.0) (< netstandard1.2)) (&& (== netstandard2.0) (< netstandard1.3)) (&& (== netstandard2.0) (< netstandard1.4)) (&& (== netstandard2.0) (< netstandard1.5)) (&& (== netstandard2.0) (< netstandard1.6)) (&& (== netstandard2.0) (< portable-net45+win8+wpa81)) Newtonsoft.Json (11.0.2) - restriction: || (== net46) (== net462) (== netcoreapp2.0) (== netcoreapp2.1) (&& (== netstandard1.6) (>= net45)) (&& (== netstandard1.6) (>= netstandard2.0)) (== netstandard2.0) - Packaging.Targets (0.1.46) + Packaging.Targets (0.1.48) NETStandard.Library (>= 1.6.1) - restriction: || (&& (== net46) (== netcoreapp2.0)) (&& (== net46) (== netcoreapp2.1)) (&& (== net46) (== netstandard2.0)) (&& (== net46) (>= netstandard1.5)) (== net462) (&& (== netcoreapp2.0) (< netstandard2.0)) (&& (== netcoreapp2.1) (< netstandard2.0)) (== netstandard1.6) System.Globalization.Extensions (>= 4.3) - restriction: || (&& (== net46) (== netcoreapp2.0)) (&& (== net46) (== netcoreapp2.1)) (&& (== net46) (== netstandard2.0)) (&& (== net46) (>= netstandard1.5)) (== net462) (&& (== netcoreapp2.0) (< netstandard2.0)) (&& (== netcoreapp2.1) (< netstandard2.0)) (== netstandard1.6) System.Runtime.InteropServices (>= 4.3) - restriction: || (&& (== net46) (== netcoreapp2.0)) (&& (== net46) (== netcoreapp2.1)) (&& (== net46) (== netstandard2.0)) (&& (== net46) (>= netstandard1.5)) (== net462) (&& (== netcoreapp2.0) (< netstandard2.0)) (&& (== netcoreapp2.1) (< netstandard2.0)) (== netstandard1.6) diff --git a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs index 3e25b82b1c5..b912bf8c46d 100644 --- a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs +++ b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs @@ -39,11 +39,13 @@ module TeamCityImportExtensions = /// The general documentation on how to use CI server integration can be found [here](/buildserver.html). /// This module does not provide any special APIs please use FAKE APIs and they should integrate into this CI server. /// If some integration is not working as expected or you have features you would like to use directly please open an issue. +/// +/// For more information on TeamCity interaction from build scripts [see here](https://confluence.jetbrains.com/display/TCD18/Build+Script+Interaction+with+TeamCity) [] module TeamCity = open Fake.IO - // See https://confluence.jetbrains.com/display/TCD18/Build+Script+Interaction+with+TeamCity + /// Open Named Block that will be closed when the block is disposed /// Usage: `use __ = TeamCity.block "My Block"` @@ -222,6 +224,14 @@ module TeamCity = (TeamCityWriter.encapsulateSpecialChars name) (TeamCityWriter.encapsulateSpecialChars message) (TeamCityWriter.encapsulateSpecialChars details) (TeamCityWriter.encapsulateSpecialChars expected) (TeamCityWriter.encapsulateSpecialChars actual) |> TeamCityWriter.sendStrToTeamCity + /// Sends a warning message. + let internal warning message = + TeamCityWriter.sendToTeamCity "##teamcity[message text='%s' status='WARNING']" message + + /// Sends an error message. + let internal error message = + TeamCityWriter.sendToTeamCity "##teamcity[message text='%s' status='ERROR']" message + /// TeamCity build parameters /// /// See [Predefined Build Parameters documentation](https://confluence.jetbrains.com/display/TCD18/Predefined+Build+Parameters) for more information @@ -365,9 +375,8 @@ module TeamCity = with get() = RecentlyFailedTests.cache.Value /// Implements a TraceListener for TeamCity build servers. - /// ## Parameters - /// - `importantMessagesToStdErr` - Defines whether to trace important messages to StdErr. - /// - `colorMap` - A function which maps TracePriorities to ConsoleColors. + /// + /// See [the documentation](https://confluence.jetbrains.com/display/TCD18/Build+Script+Interaction+with+TeamCity) for more information type internal TeamCityTraceListener() = interface ITraceListener with @@ -386,8 +395,13 @@ module TeamCity = testFailed testName message detail | TraceData.TestStatus (testName,TestStatus.Failed(message, detail, Some (expected, actual))) -> comparisonFailure testName message detail expected actual - | TraceData.BuildState state -> - ConsoleWriter.write false color true (sprintf "Changing BuildState to: %A" state) + | TraceData.BuildState TagStatus.Success -> + reportBuildStatus "SUCCESS" "{build.status.text}" + | TraceData.BuildState TagStatus.Warning -> + warning "Setting build state to warning." + //reportBuildStatus "SUCCESS" "{build.status.text}" + | TraceData.BuildState TagStatus.Failed -> + reportBuildStatus "FAILURE" (sprintf "%s - {build.status.text}" ("Failed")) | TraceData.CloseTag (KnownTags.Test name, time, _) -> finishTestCase name time | TraceData.OpenTag (KnownTags.TestSuite name, _) -> @@ -398,10 +412,15 @@ module TeamCity = match description with | Some d -> TeamCityWriter.sendOpenBlock tag.Name (sprintf "%s: %s" tag.Type d) | _ -> TeamCityWriter.sendOpenBlock tag.Name tag.Type + | TraceData.CloseTag (tag, _, TagStatus.Failed) -> + TeamCityWriter.sendCloseBlock tag.Name + //reportBuildStatus "FAILURE" (sprintf "Failure in %s" tag.Name) | TraceData.CloseTag (tag, _, _) -> TeamCityWriter.sendCloseBlock tag.Name - | TraceData.ImportantMessage text | TraceData.ErrorMessage text -> - ConsoleWriter.write false color true text + | TraceData.ImportantMessage text -> + warning text + | TraceData.ErrorMessage text -> + error text | TraceData.LogMessage(text, newLine) | TraceData.TraceMessage(text, newLine) -> ConsoleWriter.write false color newLine text | TraceData.ImportData (ImportData.BuildArtifactWithName _, path) diff --git a/src/app/Fake.Core.Process/Fake.Core.Process.fsproj b/src/app/Fake.Core.Process/Fake.Core.Process.fsproj index a96254bc1e4..d783a2d7a91 100644 --- a/src/app/Fake.Core.Process/Fake.Core.Process.fsproj +++ b/src/app/Fake.Core.Process/Fake.Core.Process.fsproj @@ -14,7 +14,7 @@ $(DefineConstants);FX_PASSWORD;FX_WINDOWSTLE;FX_VERB;FX_CONFIGURATION_MANAGER;FX_ERROR_DIALOG - $(DefineConstants);FX_PASSWORD_CLEAR_TEXT + $(DefineConstants);FX_PASSWORD_CLEAR_TEXT;FX_NO_HANDLE diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 45829a3e02c..15fa53c2965 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -224,6 +224,30 @@ open Fake.IO open Fake.IO.FileSystemOperators open Fake.Core.GuardedAwaitObservable + +#if !FX_NO_HANDLE +module internal Kernel32 = + open System + open System.Text + open System.Diagnostics + open System.Runtime.InteropServices + [] + extern UInt32 QueryFullProcessImageName(IntPtr hProcess, UInt32 flags, StringBuilder text, [] UInt32& size) + + let getPathToApp (proc:Process) = + let mutable nChars = 256u + let Buff = new StringBuilder(int nChars); + + let success = QueryFullProcessImageName(proc.Handle, 0u, Buff, &nChars) + + if (0u <> success) then + Buff.ToString() + else + let hresult = Marshal.GetHRForLastWin32Error() + Marshal.ThrowExceptionForHR hresult + "Error = " + string hresult + " when calling GetProcessImageFileName" +#endif + [] module Process = @@ -362,10 +386,7 @@ module Process = match getEnableProcessTracing() with | Some v -> v | None -> - let shouldEnable = Fake.Core.Context.isFakeContext() - setEnableProcessTracing shouldEnable - shouldEnable - + Fake.Core.Context.isFakeContext() let defaultEnvVar = ProcStartInfoData.defaultEnvVar let createEnvironmentMap () = ProcStartInfoData.createEnvironmentMap() @@ -755,6 +776,15 @@ module Process = [] let killProcessById id = killById id + /// Retrieve the file-path of the running executable of the given process. + let getFileName (p:Process) = +#if !FX_NO_HANDLE + if Environment.isWindows then + Kernel32.getPathToApp p + else +#endif + p.MainModule.FileName + /// Returns all processes with the given name let getAllByName (name : string) = Process.GetProcesses() diff --git a/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs b/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs index 56e752591af..7b9dece09d4 100644 --- a/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs +++ b/src/app/Fake.Core.ReleaseNotes/ReleaseNotes.fs @@ -126,7 +126,10 @@ let private parseAllComplex (text: seq) = loop (newReleaseNotes::releaseNotes) rest | None -> releaseNotes - loop [] (text |> Seq.map (String.trimStartChars [|' '; '*'|] >> String.trimEndChars [|' '|]) |> Seq.toList) + let result = loop [] (text |> Seq.map (String.trimStartChars [|' '; '*'|] >> String.trimEndChars [|' '|]) |> Seq.toList) + if List.isEmpty result then + failwithf "release note files containing only top level headers are not allowed" + else result /// Parses a Release Notes text and returns all release notes. @@ -156,9 +159,12 @@ let parseAll (data: seq) = /// ## Parameters /// - `data` - Release notes text let parse (data: seq) = - data - |> parseAll - |> Seq.head + match + data + |> parseAll + |> Seq.tryHead with + | Some head -> head + | None -> failwithf "The release notes document was not valid, see https://fake.build/apidocs/v5/fake-core-releasenotes.html for the allowed formats" /// Parses a Release Notes text file and returns the lastest release notes. /// diff --git a/src/app/Fake.Core.Target/Target.fs b/src/app/Fake.Core.Target/Target.fs index dd412d73c00..5431c5c0418 100644 --- a/src/app/Fake.Core.Target/Target.fs +++ b/src/app/Fake.Core.Target/Target.fs @@ -444,11 +444,15 @@ module Target = | Some e -> alignedError name time e.Message) aligned "Total:" total null - if not context.HasError then aligned "Status:" "Ok" null + if not context.HasError then + aligned "Status:" "Ok" null + //Trace.setBuildState TagStatus.Success else alignedError "Status:" "Failure" null + //Trace.setBuildState TagStatus.Failed else Trace.traceError "No target was successfully completed" + //Trace.setBuildState TagStatus.Warning Trace.traceLine() diff --git a/src/app/Fake.DotNet.Cli/DotNet.fs b/src/app/Fake.DotNet.Cli/DotNet.fs index 099c8025d6d..386a4f3df6c 100644 --- a/src/app/Fake.DotNet.Cli/DotNet.fs +++ b/src/app/Fake.DotNet.Cli/DotNet.fs @@ -794,6 +794,21 @@ module DotNet = let passVersion = if fromGlobalJson then None else checkVersion let installScript = downloadInstaller param.InstallerOptions + // check if existing processes exists: + let dotnetExe = Path.Combine(dir, if Environment.isUnix then "dotnet" else "dotnet.exe") + if Environment.isWindows && File.Exists(dotnetExe) then + System.Diagnostics.Process.GetProcesses() + |> Seq.filter (fun p -> + try + not p.HasExited + with _ -> false) + |> Seq.filter (fun p -> + try + Path.GetFullPath(Process.getFileName p).ToLowerInvariant() = + Path.GetFullPath(dotnetExe) + with _ -> false) + |> Seq.iter Process.kill + () let exitCode = let args, fileName = if Environment.isUnix then @@ -853,6 +868,10 @@ module DotNet = /// Changes the "Common" properties according to the given function member inline x.WithCommon f = { x with Common = f x.Common } + + /// Changes the "MSBuildParams" properties according to the given function + member inline x.WithMSBuildParams f = + { x with MSBuildParams = f x.MSBuildParams } let internal addBinaryLogger disableFakeBinLog args (common:Options) = // used for detection @@ -878,6 +897,15 @@ module DotNet = let result = exec (fun _ -> common) command args MSBuild.handleAfterRun (sprintf "dotnet %s" command) binLogPath result.ExitCode project + let internal tryExecWithBinLog project common command args msBuildArgs = + let argString = MSBuild.fromCliArguments msBuildArgs + let binLogPath, args = addBinaryLogger msBuildArgs.DisableInternalBinLog (args + " " + argString) common + let result = exec (fun _ -> common) command args + try + MSBuild.handleAfterRun (sprintf "dotnet %s" command) binLogPath result.ExitCode project + Choice1Of2 result + with e -> Choice2Of2 (e, result) + /// Runs a MSBuild project /// ## Parameters /// - `setParams` - A function that overwrites the default MSBuildOptions @@ -912,6 +940,18 @@ module DotNet = execWithBinLog project param.Common "msbuild" args param.MSBuildParams __.MarkSuccess() + // TODO: Make this API public? change return code? + let internal msbuildWithResult setParams project = + //use __ = Trace.traceTask "DotNet:msbuild" project + + let param = MSBuildOptions.Create() |> setParams + let args = [project] + let args = Args.toWindowsCommandLine args + let r = tryExecWithBinLog project param.Common "msbuild" args param.MSBuildParams + //__.MarkSuccess() + r + + /// dotnet restore command options type RestoreOptions = { diff --git a/src/app/Fake.DotNet.Cli/Fake.DotNet.Cli.fsproj b/src/app/Fake.DotNet.Cli/Fake.DotNet.Cli.fsproj index 9aa5144e51b..c7e118067d3 100644 --- a/src/app/Fake.DotNet.Cli/Fake.DotNet.Cli.fsproj +++ b/src/app/Fake.DotNet.Cli/Fake.DotNet.Cli.fsproj @@ -13,6 +13,7 @@ + diff --git a/src/app/Fake.DotNet.Cli/VisibleTo.fs b/src/app/Fake.DotNet.Cli/VisibleTo.fs new file mode 100644 index 00000000000..21d9c08a2b0 --- /dev/null +++ b/src/app/Fake.DotNet.Cli/VisibleTo.fs @@ -0,0 +1,6 @@ + +namespace System +open System.Runtime.CompilerServices + +[] +do () \ No newline at end of file diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index d82c450f1d1..823ead0e2fa 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -498,6 +498,8 @@ module MSBuild = let escapePropertyValue (v:string) = // https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-special-characters?view=vs-2017 v.Replace("%", "%25") + .Replace("\\", "%5C") + .Replace("\"", "%22") .Replace(";", "%3B") .Replace(",", "%2C") .Replace("$", "%24") @@ -741,6 +743,43 @@ module MSBuild = let errorMessage = sprintf "'%s %s' failed with exitcode %d." command project exitCode raise (MSBuildException(errorMessage, errors)) + // TODO: Make this API public? Remove "Choice" return value + let internal buildWithRedirect setParams project = + let msBuildParams, argsString = buildArgs setParams + + let args = Process.toParam project + " " + argsString + + // used for detection + let callMsBuildExe args = + let result = + Process.execWithResult (fun info -> + { info with + FileName = msBuildParams.ToolPath + Arguments = args } + |> Process.setEnvironment msBuildParams.Environment) TimeSpan.MaxValue + if not result.OK then + failwithf "msbuild failed with exitcode '%d'" result.ExitCode + String.Join("\n", result.Messages) + + let binlogPath, args = addBinaryLogger msBuildParams.ToolPath callMsBuildExe args msBuildParams.DisableInternalBinLog + let wd = + if msBuildParams.WorkingDirectory = System.IO.Directory.GetCurrentDirectory() + then "" + else sprintf "%s>" msBuildParams.WorkingDirectory + Trace.tracefn "%s%s %s" wd msBuildParams.ToolPath args + + let result = + Process.execWithResult (fun info -> + { info with + FileName = msBuildParams.ToolPath + WorkingDirectory = msBuildParams.WorkingDirectory + Arguments = args } + |> Process.setEnvironment msBuildParams.Environment) TimeSpan.MaxValue + try + handleAfterRun "msbuild" binlogPath result.ExitCode project + Choice1Of2 result + with e -> Choice2Of2 (e, result) + /// Runs a MSBuild project /// ## Parameters diff --git a/src/app/Fake.DotNet.Testing.Expecto/Expecto.fs b/src/app/Fake.DotNet.Testing.Expecto/Expecto.fs index cd0378ba77a..245de9e685b 100644 --- a/src/app/Fake.DotNet.Testing.Expecto/Expecto.fs +++ b/src/app/Fake.DotNet.Testing.Expecto/Expecto.fs @@ -76,7 +76,7 @@ type Params = static member DefaultParams = { Debug = false - Parallel = true + Parallel = false ParallelWorkers = 0 Filter = "" FilterTestCase = "" diff --git a/src/app/Fake.IO.FileSystem/Globbing.fs b/src/app/Fake.IO.FileSystem/Globbing.fs index f434908e315..59769c8514d 100644 --- a/src/app/Fake.IO.FileSystem/Globbing.fs +++ b/src/app/Fake.IO.FileSystem/Globbing.fs @@ -98,9 +98,9 @@ let internal getRoot (baseDirectory : string) (pattern : string) = if Path.IsPathRooted globRoot then globRoot else Path.Combine(baseDirectory, globRoot) -let internal search (baseDir : string) (input : string) = +let internal search (baseDir : string) (originalInput : string) = let baseDir = normalizePath baseDir - let input = normalizePath input + let input = normalizePath originalInput let input = if String.IsNullOrEmpty baseDir then input @@ -126,7 +126,11 @@ let internal search (baseDir : string) (input : string) = elif splits.Length >= 2 && Path.IsPathRooted input && input.StartsWith "/" then [ Directory("/") ], splits |> Array.toSeq else - if Path.IsPathRooted input then failwithf "Unknown globbing input '%s', try to use a relative path and report an issue!" input + if Path.IsPathRooted input then + if input.StartsWith "\\" + then // https://github.com/fsharp/FAKE/issues/2073 + failwithf "Please remove the leading '\\' or '/' and replace them with '.\\' or './' if you want to use a relative path. Leading slashes are considered an absolute path (input was '%s')!" originalInput + else failwithf "Unknown globbing input '%s', try to use a relative path and report an issue!" originalInput [], splits |> Array.toSeq let restList = rest diff --git a/src/app/Fake.Runtime/FakeRuntime.fs b/src/app/Fake.Runtime/FakeRuntime.fs index 80410485a8e..14dfe5186c1 100644 --- a/src/app/Fake.Runtime/FakeRuntime.fs +++ b/src/app/Fake.Runtime/FakeRuntime.fs @@ -187,7 +187,7 @@ let paketCachingProvider (config:FakeConfig) cacheDir (paketApi:Paket.Dependenci // be compatible with the runtime we are currently running on. let rootDir = Directory.GetCurrentDirectory() let packageName = Domain.PackageName("NETStandard.Library") - let version = SemVer.Parse("2.0.2") + let version = SemVer.Parse("2.0.3") let existingpkg = NuGetCache.GetTargetUserNupkg packageName version let extractedFolder = if File.Exists existingpkg then @@ -602,7 +602,7 @@ let createConfig (logLevel:Trace.VerboseLevel) (fsiOptions:string list) scriptPa let tokenized = lazy (File.ReadLines scriptPath |> FSharpParser.getTokenized scriptPath ("FAKE_DEPENDENCIES" :: newFsiOptions.Defines)) { Runners.FakeConfig.VerboseLevel = logLevel - Runners.FakeConfig.ScriptFilePath = scriptPath + Runners.FakeConfig.ScriptFilePath = Path.GetFullPath scriptPath Runners.FakeConfig.ScriptTokens = tokenized Runners.FakeConfig.CompileOptions = { FsiOptions = newFsiOptions; RuntimeDependencies = [] } diff --git a/src/app/Fake.Sql.SqlServer/Fake.Sql.SqlServer.fsproj b/src/app/Fake.Sql.SqlServer/Fake.Sql.SqlServer.fsproj.old similarity index 100% rename from src/app/Fake.Sql.SqlServer/Fake.Sql.SqlServer.fsproj rename to src/app/Fake.Sql.SqlServer/Fake.Sql.SqlServer.fsproj.old diff --git a/src/test/Fake.Core.IntegrationTests/Fake.Core.IntegrationTests.fsproj b/src/test/Fake.Core.IntegrationTests/Fake.Core.IntegrationTests.fsproj index 3b30cc5df7c..4762a414436 100644 --- a/src/test/Fake.Core.IntegrationTests/Fake.Core.IntegrationTests.fsproj +++ b/src/test/Fake.Core.IntegrationTests/Fake.Core.IntegrationTests.fsproj @@ -6,6 +6,7 @@ + diff --git a/src/test/Fake.Core.IntegrationTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.IntegrationTests/Fake.DotNet.MSBuild.fs index 5df9bc4eca3..89a9f0bca6c 100644 --- a/src/test/Fake.Core.IntegrationTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.IntegrationTests/Fake.DotNet.MSBuild.fs @@ -5,60 +5,44 @@ open Fake.Core open Fake.DotNet open Expecto -let buildWithRedirect setParams project = - let msBuildParams, argsString = MSBuild.buildArgs setParams +// Use `dotnet msbuild` for now as it will be the same version across all CI servers +let dotnetSdk = lazy DotNet.install DotNet.Versions.FromGlobalJson - let args = Process.toParam project + " " + argsString +let inline opts () = DotNet.Options.lift dotnetSdk.Value - // used for detection - let callMsBuildExe args = - let result = - Process.execWithResult (fun info -> - { info with - FileName = msBuildParams.ToolPath - Arguments = args } - |> Process.setEnvironment msBuildParams.Environment) TimeSpan.MaxValue - if not result.OK then - failwithf "msbuild failed with exitcode '%d'" result.ExitCode - String.Join("\n", result.Messages) - - let binlogPath, args = MSBuild.addBinaryLogger msBuildParams.ToolPath callMsBuildExe args msBuildParams.DisableInternalBinLog - let wd = - if msBuildParams.WorkingDirectory = System.IO.Directory.GetCurrentDirectory() - then "" - else sprintf "%s>" msBuildParams.WorkingDirectory - Trace.tracefn "%s%s %s" wd msBuildParams.ToolPath args - - let result = - Process.execWithResult (fun info -> - { info with - FileName = msBuildParams.ToolPath - WorkingDirectory = msBuildParams.WorkingDirectory - Arguments = args } - |> Process.setEnvironment msBuildParams.Environment) TimeSpan.MaxValue - try - MSBuild.handleAfterRun "msbuild" binlogPath result.ExitCode project - Choice1Of2 result - with e -> Choice2Of2 (e, result) +let inline dtntWorkDir wd = + DotNet.Options.lift dotnetSdk.Value + >> DotNet.Options.withWorkingDirectory wd + >> DotNet.Options.withRedirectOutput true let simplePropertyTest propValue = let dllPath = System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly().Location) - let setParams (defaults:MSBuildParams) = + let setMSBuildParams (defaults:MSBuild.CliArguments) = { defaults with - Verbosity = Some(MSBuildVerbosity.Diagnostic) + Verbosity = Some(MSBuildVerbosity.Minimal) Targets = ["Test"] NoLogo = true Properties = [ "Property1", propValue ] - WorkingDirectory = dllPath } + let setParams (p:DotNet.MSBuildOptions) = + p.WithMSBuildParams setMSBuildParams + |> dtntWorkDir dllPath - match buildWithRedirect setParams "testdata/testProperty.proj" with + + match DotNet.msbuildWithResult setParams "testdata/testProperty.proj" with | Choice1Of2 result -> let lines = String.Join("\n", result.Results |> Seq.map (fun r -> r.Message)) Expect.stringContains lines (sprintf "$Property1: '%s'" propValue) "Expected to find property value in msbuild output" + + // This happens on xbuild? + //if Environment.isWindows then + //else + // // TODO: Report me as msbuild bug? + // let fixedPropValue = propValue.Replace("\\", "/") + // Expect.stringContains lines (sprintf "$Property1: '%s'" fixedPropValue) "Expected to find property value in msbuild output" Expect.stringContains lines "$Property2: ''" "Expected to find empty Property2" | Choice2Of2 (e, result) -> let lines = String.Join("\n", result.Results |> Seq.map (fun r -> sprintf "%s: %s" (if r.IsError then "stderr" else "stdout") r.Message)) @@ -68,10 +52,11 @@ let simplePropertyTest propValue = [] let tests = testList "Fake.DotNet.MSBuild.IntegrationTests" [ - testCase "#2112" <| fun _ -> + Process.setEnableProcessTracing true + yield testCase "#2112" <| fun _ -> let value = "Data Source=xxx,1433;Initial Catalog=xxx;User Id=xxx;Password=xxx;Integrated Security=False;Persist Security Info=True;Connect Timeout=30;Encrypt=True;MultipleActiveResultSets=True" simplePropertyTest value - testCase "#2112 (2)" <| fun _ -> + yield testCase "#2112 (2)" <| fun _ -> let value = "=asd?*&(($!&%%_^$#_+=-['}{|\';\\'\"\\\"ad" simplePropertyTest value ] diff --git a/src/test/Fake.Core.IntegrationTests/SimpleHelloWorldTests.fs b/src/test/Fake.Core.IntegrationTests/SimpleHelloWorldTests.fs index 04c3bc97ff8..1b53446b371 100644 --- a/src/test/Fake.Core.IntegrationTests/SimpleHelloWorldTests.fs +++ b/src/test/Fake.Core.IntegrationTests/SimpleHelloWorldTests.fs @@ -11,7 +11,7 @@ let fail s = Expect.isTrue s false [] let tests = - testList "Fake.Core.CommandLineParsing.Tests" [ + testList "Fake.Core.IntegrationTests" [ testCase "no dependencies hello world" <| fun _ -> let result = fakeRunAndCheck "hello_world.fsx" "hello_world.fsx" "core-no-dependencies-hello-world" let stdOut = String.Join("\n", result.Messages) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs b/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs index bd2b18eafdb..fa32b4aec39 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs @@ -3,7 +3,6 @@ module Fake.Core.ReleaseNotesTests open Fake.Core open Expecto - [] let tests = testList "Fake.Core.ReleaseNotes.Tests" [ @@ -86,4 +85,20 @@ let tests = { AssemblyVersion = "1.1.0"; NugetVersion = "1.1.0"; SemVer = SemVer.parse "1.1.0"; Date = Some (System.DateTime(2017,04,12)); Notes = ["- Some change 3"; "- Some change 4"] } Expect.equal expected releaseNotes "Simple parse failure" + + testCase "Test that we provide proper error #2085" <| fun _ -> + let releaseNotesLines = [ + "# 1.3.7" + "" + "* Bugfixes and public release" + "" + "# 1.3.2" + "" + "* Fix various bugs in the FAKE runner." + "" + ] + Expect.throwsC + (fun () -> ignore <| ReleaseNotes.parse releaseNotesLines) + (fun e -> + Expect.stringContains e.Message "files containing only top level headers are not allowed" "Expected nice error message") ] diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj index 5497572b258..7d33df4e58d 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj +++ b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj @@ -40,4 +40,4 @@ - + \ No newline at end of file diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index e1b7641d7d5..d87d7c527e5 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -14,7 +14,7 @@ let tests = ConsoleLogParameters = [] Properties = ["OutputPath", "C:\\Test\\"] }) let expected = - if Environment.isUnix then "\"/p:RestorePackages=False\" \"/p:OutputPath=C:\\Test\\\\\"" - else "\"/m\" \"/nodeReuse:False\" \"/p:RestorePackages=False\" \"/p:OutputPath=C:\\Test\\\\\"" + if Environment.isUnix then "\"/p:RestorePackages=False\" \"/p:OutputPath=C:%5CTest%5C\"" + else "\"/m\" \"/nodeReuse:False\" \"/p:RestorePackages=False\" \"/p:OutputPath=C:%5CTest%5C\"" Expect.equal cmdLine expected "Expected a given cmdline." ]