Skip to content

Commit

Permalink
Merge pull request #1697 from fsharp/cleanup
Browse files Browse the repository at this point in the history
[Fix] We need to start some processes with mono on non-windows platforms.
  • Loading branch information
matthid authored Oct 22, 2017
2 parents ddf4544 + 6c16353 commit 09e25a3
Show file tree
Hide file tree
Showing 82 changed files with 3,365 additions and 2,005 deletions.
6 changes: 3 additions & 3 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
</PropertyGroup>

<Target Name="PaketRestore" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" >
<Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" >

<!-- Step 1 Check if lockfile is properly restored -->
<PropertyGroup>
Expand Down Expand Up @@ -84,11 +84,11 @@
</PropertyGroup>

<!-- Step 3 Restore project specific stuff if required -->
<Warning Condition=" '$(PaketRestoreRequired)' == 'true' " Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />

<!-- This shouldn't actually happen, but just to be sure. -->
<Error Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' " Text="A paket file for the framework '$(TargetFramework)' is missing. Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
<Error Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' AND '$(ResolveNuGetPackages)' != 'False' " Text="Paket file '$(PaketResolvedFilePath)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />

<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
<ReadLinesFromFile Condition="Exists('$(PaketResolvedFilePath)')" File="$(PaketResolvedFilePath)" >
Expand Down
3 changes: 2 additions & 1 deletion FAKE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "markdown", "markdown", "{B9222464-CAAC-4E5F-81A0-408C7BEFDBF3}"
ProjectSection(SolutionItems) = preProject
help\markdown\404.md = help\markdown\404.md
help\markdown\api-slack.md = help\markdown\api-slack.md
help\markdown\contributing.md = help\markdown\contributing.md
help\markdown\core-targets.md = help\markdown\core-targets.md
help\markdown\dotnet-assemblyinfo.md = help\markdown\dotnet-assemblyinfo.md
Expand Down Expand Up @@ -97,7 +98,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "markdown", "markdown", "{B9
help\markdown\todo-iis.md = help\markdown\todo-iis.md
help\markdown\todo-msteamsnotification.md = help\markdown\todo-msteamsnotification.md
help\markdown\todo-octopusdeploy.md = help\markdown\todo-octopusdeploy.md
help\markdown\todo-slacknotification.md = help\markdown\todo-slacknotification.md
help\markdown\legacy-slacknotification.md = help\markdown\legacy-slacknotification.md
help\markdown\todo-stylecop.md = help\markdown\todo-stylecop.md
help\markdown\todo-teamcity.md = help\markdown\todo-teamcity.md
help\markdown\todo-teamcityadvanced.md = help\markdown\todo-teamcityadvanced.md
Expand Down
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#### 5.0.0-beta006 - 2017-10-22
* BUGFIX: Add `Process.withFramework` to indicate that a process might need to be started with mono and use it in kown wrappers like test-runners - https://github.com/fsharp/FAKE/pull/1697
* DOCS: Typo (https://github.com/fsharp/FAKE/pull/1701), Canopy docs (https://github.com/fsharp/FAKE/pull/1704), some Urls (https://github.com/fsharp/FAKE/pull/1708)
* DOCS: Migrate Slack API documentation for FAKE 5 - (https://github.com/fsharp/FAKE/pull/1706)
* ENHANCEMENT: Provide full fidelity of build options in Xamarin helpers - (https://github.com/fsharp/FAKE/pull/1702)
* ENHANCEMENT: Added WarnAsError to MSBuild options - (https://github.com/fsharp/FAKE/pull/1691)

#### 5.0.0-beta005 - 2017-10-02
* ENHANCEMENT: Improve error messages of Fake.Core.Process - https://github.com/fsharp/FAKE/pull/1696
* BUGFIX: `fake --version` was printing the wrong version - https://github.com/fsharp/FAKE/pull/1696
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7' Or $(TargetFrameworkVersion) == 'v5.0')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7' Or $(TargetFrameworkVersion) == 'v4.7.1')">
<ItemGroup>
<Reference Include="Machine.Specifications">
<HintPath>..\..\..\..\..\packages\Machine.Specifications\lib\net45\Machine.Specifications.dll</HintPath>
Expand Down
7 changes: 6 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ image: Visual Studio 2017
install:
- cinst fake -pre
build_script:
- ps: Fake.exe -v run build.fsx
# See https://stackoverflow.com/a/12866669/1269722
# Problem is that colors are lost
# Don't blame me but powershell is the bigest crap on earth
- ps: |
cmd /c '(((fake.exe -v run build.fsx 1>&3) 2>&1)) 3>&1'
# - ps: .\build.cmd
on_failure:
- appveyor PushArtifact FAKE.svclog
Expand Down
100 changes: 83 additions & 17 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ let cleanForTests () =
then fileName, args else "cmd", ("/C " + fileName + " " + args)
let ok =
Process.execProcess (fun info ->
#if BOOTSTRAP
{ info with
FileName = fileName
WorkingDirectory = workingDir
Arguments = args }
#else
info.FileName <- fileName
info.WorkingDirectory <- workingDir
info.Arguments <- args) System.TimeSpan.MaxValue
info.Arguments <- args
#endif
) System.TimeSpan.MaxValue
if not ok then failwith (sprintf "'%s> %s %s' task failed" workingDir fileName args)

let rmdir dir =
Expand Down Expand Up @@ -202,6 +210,7 @@ let dotnetAssemblyInfos =
"Fake.DotNet.Testing.NUnit", "Running nunit test runner"
"Fake.DotNet.Testing.XUnit2", "Running xunit test runner"
"Fake.DotNet.Testing.MSTest", "Running mstest test runner"
"Fake.DotNet.Xamarin", "Running Xamarin builds"
"Fake.IO.FileSystem", "Core Filesystem utilities"
"Fake.IO.Zip", "Core Zip functionality"
"Fake.netcore", "Command line tool"
Expand All @@ -212,7 +221,7 @@ let dotnetAssemblyInfos =
"Fake.Windows.Chocolatey", "Running and packaging with Chocolatey"
"Fake.Testing.SonarQube", "Analyzing your project with SonarQube"
"Fake.DotNet.Testing.OpenCover", "Code coverage with OpenCover" ]

let assemblyInfos =
[ "./src/app/FAKE/AssemblyInfo.fs",
[ AssemblyInfo.Title "FAKE - F# Make Command line tool"
Expand Down Expand Up @@ -253,9 +262,16 @@ Target.Create "SetAssemblyInfo" (fun _ ->
)

Target.Create "DownloadPaket" (fun _ ->
if 0 <> Process.ExecProcess (fun info ->
if 0 <> Process.ExecProcess (fun info ->
#if BOOTSTRAP
{ info with
FileName = ".paket/paket.exe"
Arguments = "--version" }
#else
info.FileName <- ".paket/paket.exe"
info.Arguments <- "--version") (System.TimeSpan.FromMinutes 5.0) then
info.Arguments <- "--version"
#endif
) (System.TimeSpan.FromMinutes 5.0) then
failwith "paket failed to start"
)

Expand Down Expand Up @@ -330,14 +346,14 @@ Target.Create "GenerateDocs" (fun _ ->

Directory.ensure apidocsDir
dllFiles
|> FSFormatting.CreateDocsForDlls (fun s ->
{ s with
|> FSFormatting.CreateDocsForDlls (fun s ->
{ s with
OutputDirectory = apidocsDir
LayoutRoots = layoutroots
LayoutRoots = layoutroots
LibDirs = [ "./build" ]
// TODO: CurrentPage shouldn't be required as it's written in the template, but it is -> investigate
ProjectParameters = ("CurrentPage", "APIReference") :: projInfo
SourceRepository = githubLink + "/blob/master" })
SourceRepository = githubLink + "/blob/master" })

)

Expand Down Expand Up @@ -372,6 +388,9 @@ Target.Create "TestDotnetCore" (fun _ ->
Target.Create "BootstrapTest" (fun _ ->
let buildScript = "build.fsx"
let testScript = "testbuild.fsx"
#if !BOOTSTRAP
Environment.setEnvironVar "FAKE_DETAILED_ERRORS" "true"
#endif
// Check if we can build ourself with the new binaries.
let test clearCache (script:string) =
let clear () =
Expand All @@ -386,14 +405,31 @@ Target.Create "BootstrapTest" (fun _ ->
if Environment.isUnix then
let result =
Process.ExecProcess (fun info ->
#if BOOTSTRAP
{ info with
FileName = "chmod"
WorkingDirectory = "."
Arguments = "+x build/FAKE.exe" }
#else
info.FileName <- "chmod"
info.WorkingDirectory <- "."
info.Arguments <- "+x build/FAKE.exe") span
info.Arguments <- "+x build/FAKE.exe"
#endif
) span
if result <> 0 then failwith "'chmod +x build/FAKE.exe' failed on unix"
Process.ExecProcess (fun info ->
#if BOOTSTRAP
{ info with
FileName = "build/FAKE.exe"
WorkingDirectory = "."
Arguments = sprintf "%s %s --fsiargs \"--define:BOOTSTRAP\" -pd" script target }
|> Process.setEnvironmentVariable "FAKE_DETAILED_ERRORS" "true"
#else
info.FileName <- "build/FAKE.exe"
info.WorkingDirectory <- "."
info.Arguments <- sprintf "%s %s -pd" script target) span
info.Arguments <- sprintf "%s %s -pd -fa --define:BOOTSTRAP " script target
#endif
) span

let result = executeTarget (System.TimeSpan.FromMinutes 10.0) "PrintColors"
if result <> 0 then failwith "Bootstrapping failed"
Expand All @@ -418,6 +454,9 @@ Target.Create "BootstrapTest" (fun _ ->
Target.Create "BootstrapTestDotnetCore" (fun _ ->
let buildScript = "build.fsx"
let testScript = "testbuild.fsx"
#if !BOOTSTRAP
Environment.setEnvironVar "FAKE_DETAILED_ERRORS" "true"
#endif
// Check if we can build ourself with the new binaries.
let test timeout clearCache script =
let clear () =
Expand All @@ -437,9 +476,18 @@ Target.Create "BootstrapTestDotnetCore" (fun _ ->
if Environment.isUnix then "nuget/dotnetcore/Fake.netcore/current/fake"
else "nuget/dotnetcore/Fake.netcore/current/fake.exe"
Process.ExecProcessWithLambdas (fun info ->
#if BOOTSTRAP
{ info with
FileName = fileName
WorkingDirectory = "."
Arguments = sprintf "run %s --fsiargs \"--define:BOOTSTRAP\" --target %s" script target }
|> Process.setEnvironmentVariable "FAKE_DETAILED_ERRORS" "true"
#else
info.FileName <- fileName
info.WorkingDirectory <- "."
info.Arguments <- sprintf "run %s --target %s" script target)
info.Arguments <- sprintf "run %s --fsiargs \"--define:BOOTSTRAP\" --target %s" script target
#endif
)
timeout
true (Trace.traceFAKE "%s") Trace.trace

Expand Down Expand Up @@ -490,8 +538,15 @@ Target.Create "ILRepack" (fun _ ->

let result =
Process.ExecProcess (fun info ->
#if BOOTSTRAP
{ info with
FileName = Directory.GetCurrentDirectory() </> "packages" </> "build" </> "ILRepack" </> "tools" </> "ILRepack.exe"
Arguments = sprintf "/verbose /lib:%s /ver:%s /out:%s %s" buildDir release.AssemblyVersion targetFile toPack }
#else
info.FileName <- Directory.GetCurrentDirectory() </> "packages" </> "build" </> "ILRepack" </> "tools" </> "ILRepack.exe"
info.Arguments <- sprintf "/verbose /lib:%s /ver:%s /out:%s %s" buildDir release.AssemblyVersion targetFile toPack) (System.TimeSpan.FromMinutes 5.)
info.Arguments <- sprintf "/verbose /lib:%s /ver:%s /out:%s %s" buildDir release.AssemblyVersion targetFile toPack
#endif
) (System.TimeSpan.FromMinutes 5.)

if result <> 0 then failwithf "Error during ILRepack execution."

Expand All @@ -511,7 +566,11 @@ Target.Create "CreateNuGet" (fun _ ->
|> Seq.iter (fun file ->
let args =
{ Process.Program = "lib" @@ "corflags.exe"
#if BOOTSTRAP
Process.WorkingDir = Path.GetDirectoryName file
#else
Process.WorkingDirectory = Path.GetDirectoryName file
#endif
Process.CommandLine = "/32BIT- /32BITPREF- " + Process.quoteIfNeeded file
Process.Args = [] }
printfn "%A" args
Expand Down Expand Up @@ -720,7 +779,7 @@ Target.Create "DotnetPackage_" (fun _ ->
Framework = Some "netcoreapp2.0"
OutputPath = Some outDir
}) netcoreFsproj

)

Target.Create "DotnetCoreCreateZipPackages" (fun _ ->
Expand Down Expand Up @@ -839,8 +898,15 @@ let rec nugetPush tries nugetpackage =
try
if not <| System.String.IsNullOrEmpty apikey then
Process.ExecProcess (fun info ->
#if BOOTSTRAP
{ info with
FileName = nuget_exe
Arguments = sprintf "push %s %s -Source %s" (Process.toParam nugetpackage) (Process.toParam apikey) (Process.toParam nugetsource) }
#else
info.FileName <- nuget_exe
info.Arguments <- sprintf "push %s %s -Source %s" (Process.toParam nugetpackage) (Process.toParam apikey) (Process.toParam nugetsource))
info.Arguments <- sprintf "push %s %s -Source %s" (Process.toParam nugetpackage) (Process.toParam apikey) (Process.toParam nugetsource)
#endif
)
(System.TimeSpan.FromMinutes 10.)
|> (fun r -> if r <> 0 then failwithf "failed to push package %s" nugetpackage)
else Trace.traceFAKE "could not push '%s', because api key was not set" nugetpackage
Expand Down Expand Up @@ -884,20 +950,20 @@ Target.Create "ReleaseDocs" (fun _ ->
)

Target.Create "FastRelease" (fun _ ->

Git.Staging.StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
let branch = Git.Information.getBranchName ""
Git.Branches.pushBranch "" "origin" branch

Git.Branches.tag "" release.NugetVersion
Git.Branches.pushTag "" "origin" release.NugetVersion

let token =
match Environment.environVarOrDefault "github_token" "" with
| s when not (System.String.IsNullOrWhiteSpace s) -> s
| _ -> failwith "please set the github_token environment variable to a github personal access token with repro access."

let draft =
GitHub.createClientWithToken token
|> GitHub.createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
Expand Down
52 changes: 52 additions & 0 deletions help/markdown/api-slack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Sending Notifications to a Slack Webhook

In this article you will learn how to create a [Slack](https://slack.com) webhook integration and send a notification to it. This article assumes that you already have a Slack team setup.

**Note: This documentation is for FAKE 5. The old documentation can be found [here](legacy-slacknotification.html)! **

[API-Reference](apidocs/fake-api-slack.html)

## Adding a Webhook Integration to a Channel

Follow the [instructions](https://my.slack.com/services/new/incoming-webhook/) for setting up an incoming webhook integration. When finished, you should have a Webhook URL that looks like "https://hooks.slack.com/services/some/random/text".

## Sending a Notification to the Webhook

open Fake.Api

// The webhook URL from the integration you set up
let webhookUrl = "https://hooks.slack.com/services/some/random/text"

Slack.SendNotification webhookUrl (fun p ->
{p with
Text = "My Slack Notification!\n<https://google.com|Click Here>!"
Channel = "@SomeoneImportant"
IconEmoji = ":ghost:"
Attachments = [|
{Slack.NotificationAttachmentDefaults with
Fallback = "Attachment Plain"
Text = "Attachment Rich"
Pretext = "Attachment Pretext"
Color = "danger"
Fields = [|
{Slack.NotificationAttachmentFieldDefaults with
Title = "Field Title 1"
Value = "Field Value 2"}
{Slack.NotificationAttachmentFieldDefaults with
Title = "Field Title 1"
Value = "Field Value 2"}|]
}
{Slack.NotificationAttachmentDefaults with
Fallback = "Attachment 2 Plain"
Text = "Attachment 2 Rich"
Pretext = "Attachment 2 Pretext"
Color = "#FFCCDD"
}|]
})
|> printfn "Result: %s"

The result should look something like this:

![alt text](pics/slacknotification/slacknotification.png "Slack Notification Result")

For additional information on the parameters, check out Slack's [Webhook Documentation](https://api.slack.com/incoming-webhooks)
29 changes: 29 additions & 0 deletions help/markdown/core-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Starting processes in "FAKE - F# Make"

**Note: This documentation is for FAKE 5! **

[API-Reference](apidocs/fake-core-process.html)

## Running a command and analyse results

```fsharp
let fakeToolPath = "known/path/to/fake.exe"
let directFakeInPath command workingDir target =
let result =
Process.ExecProcessAndReturnMessages (fun (info:Process.ProcStartInfo) ->
{ info with
FileName = fakeToolPath
WorkingDirectory = workingDir
Arguments = command }
|> Process.setEnvironmentVariable "target" target) (System.TimeSpan.FromMinutes 15.)
if result.ExitCode <> 0 then
let errors = String.Join(Environment.NewLine,result.Errors)
printfn "%s" <| String.Join(Environment.NewLine,result.Messages)
failwithf "FAKE Process exited with %d: %s" result.ExitCode errors
String.Join(Environment.NewLine,result.Messages)
let output = directFakeInPath "--version" "." "All"
```

File renamed without changes.
4 changes: 2 additions & 2 deletions help/redirects/slacknotification.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

This page moved to:

- Not jet migrated to FAKE 5
- [here for FAKE 4](todo-slacknotification.html) (Final location not decided jet)
- [here for FAKE 5](api-slack.html)
- [here for FAKE 4](legacy-slacknotification.html) (Final location not decided yet)

Loading

0 comments on commit 09e25a3

Please sign in to comment.