Skip to content

Commit 3c22ad3

Browse files
Merge pull request #296 from smoothdeveloper/fix-doc-build
Fixes to make the documentation generation work again
2 parents e582464 + 49e71d0 commit 3c22ad3

File tree

6 files changed

+147
-25
lines changed

6 files changed

+147
-25
lines changed

build.fsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#r @"packages/build/FAKE/tools/FakeLib.dll"
66
#load "tools/fakexunithelper.fsx" // helper for xunit 1 is gone, work around by having our own copy for now
7+
#load "tools/fakeiisexpress.fsx" // helper for iisexpress is not ready, work around by having our own copy for now
78

89
open System
910
open System.IO
@@ -191,6 +192,11 @@ Target.create "GenerateDocs" (fun _ ->
191192
Fake.FSIHelper.executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore
192193
)
193194

195+
Target.create "ServeDocs" (fun _ ->
196+
Fakeiisexpress.HostStaticWebsite id (__SOURCE_DIRECTORY__ @@ @"docs\output\") |> ignore
197+
Fakeiisexpress.OpenUrlInBrowser "http://localhost:8080"
198+
)
199+
194200
Target.create "ReleaseDocs" (fun _ ->
195201
Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/gh-pages"
196202
Branches.checkoutBranch "temp/gh-pages" "gh-pages"

docs/content/whatsnew.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ and accessing to built-in objects like stored procedures, functoins and tables.
3636
Connectivity information (connection string and/or config file name) is defined in one place
3737
and doesn't have be carried around like in SqlCommandProvider case.
3838
39-
```CreateCommand``` optionally accepts connection, transaction and command timeout parameters.
39+
`CreateCommand` optionally accepts connection, transaction and command timeout parameters.
4040
Any of these parameters can be ommited.
4141
*)
4242

@@ -62,8 +62,8 @@ do
6262
Access to command and record types
6363
-------------------------------------
6464
65-
```CreateMethod``` combines command type definition and constructor invocation.
66-
Compare it with usage of ```SqlCommandProvider``` where generated command type aliased explicitly.
65+
`CreateMethod` combines command type definition and constructor invocation.
66+
Compare it with usage of `SqlCommandProvider` where generated command type aliased explicitly.
6767
*)
6868

6969
let cmd1 = DB.CreateCommand<"SELECT name, create_date FROM sys.databases">(connectionString)

docs/tools/generate.fsx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,28 @@ let info =
1414
"project-github", githubLink
1515
"project-nuget", "http://www.nuget.org/packages/FSharp.Data.SqlClient" ]
1616

17-
#I "../../packages/FSharp.Formatting.2.4.1/lib/net40"
18-
#I "../../packages/RazorEngine.3.3.0/lib/net40"
19-
#I "../../packages/FSharp.Compiler.Service.0.0.36/lib/net40"
20-
#r "../../packages/Microsoft.AspNet.Razor.2.0.30506.0/lib/net40/System.Web.Razor.dll"
21-
#r "../../packages/FAKE/tools/FakeLib.dll"
22-
#r "RazorEngine.dll"
23-
#r "FSharp.Literate.dll"
24-
#r "FSharp.CodeFormat.dll"
25-
#r "FSharp.MetadataFormat.dll"
17+
#load "../../.paket/load/net46/Build/FSharp.Formatting.fsx"
18+
#load "../../.paket/load/net46/Build/FAKE.Lib.fsx"
19+
2620
open Fake
2721
open System.IO
28-
open Fake.FileHelper
22+
open Fake.IO.FileSystemOperators
2923
open FSharp.Literate
3024
open FSharp.MetadataFormat
3125

32-
#if RELEASE
33-
let root = website
34-
#else
35-
let root = "file://" + (__SOURCE_DIRECTORY__ @@ "../output")
36-
#endif
26+
// see https://github.com/fsharp/FAKE/issues/1579#issuecomment-306580820
27+
let execContext = Fake.Core.Context.FakeExecutionContext.Create false (Path.Combine(__SOURCE_DIRECTORY__, __SOURCE_FILE__)) []
28+
Fake.Core.Context.setExecutionContext (Fake.Core.Context.RuntimeContext.Fake execContext)
29+
30+
let root = "."
3731

3832
// Paths with template/source/output locations
3933
let bin = __SOURCE_DIRECTORY__ @@ "../../bin"
4034
let content = __SOURCE_DIRECTORY__ @@ "../content"
4135
let output = __SOURCE_DIRECTORY__ @@ "../output"
4236
let files = __SOURCE_DIRECTORY__ @@ "../files"
4337
let templates = __SOURCE_DIRECTORY__ @@ "templates"
44-
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting.2.4.1/"
38+
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/Build/FSharp.Formatting/"
4539
let docTemplate = formatting @@ "templates/docpage.cshtml"
4640

4741
// Where to look for *.csproj templates (in this order)
@@ -51,14 +45,14 @@ let layoutRoots =
5145

5246
// Copy static files and CSS + JS from F# Formatting
5347
let copyFiles () =
54-
CopyRecursive files output true |> Log "Copying file: "
55-
ensureDirectory (output @@ "content")
56-
CopyRecursive (formatting @@ "styles") (output @@ "content") true
57-
|> Log "Copying styles and scripts: "
48+
Fake.IO.Shell.copyRecursive files output true |> Fake.Core.Trace.logItems "Copying file: "
49+
Fake.IO.Directory.ensure (output @@ "content")
50+
Fake.IO.Shell.copyRecursive (formatting @@ "styles") (output @@ "content") true
51+
|> Fake.Core.Trace.logItems "Copying styles and scripts: "
5852

5953
// Build API reference from XML comments
6054
let buildReference () =
61-
CleanDir (output @@ "reference")
55+
Fake.IO.Shell.cleanDir (output @@ "reference")
6256
for lib in referenceBinaries do
6357
MetadataFormat.Generate
6458
( bin @@ lib, output @@ "reference", layoutRoots,

paket.dependencies

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ group Build
1414
framework: >= net40
1515
redirects: force
1616

17+
nuget FAKE = 5.0.0-rc014.167
18+
nuget Fake.Lib = 5.0.0-rc014.167
19+
20+
nuget FSharp.Formatting = 2.4.1
21+
nuget FSharp.Compiler.Service = 0.0.36
22+
nuget RazorEngine = 3.3.0
23+
1724
nuget NuGet.CommandLine
18-
nuget FAKE = 5.0.0-rc014.167
1925

2026
group Test
2127
source https://www.nuget.org/api/v2/

paket.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ RESTRICTION: >= net40
103103
NUGET
104104
remote: https://www.nuget.org/api/v2
105105
FAKE (5.0.0-rc014.167)
106+
FAKE.Lib (5.0.0-rc014.167)
107+
FSharp.Compiler.Service (0.0.36)
108+
FSharp.Formatting (2.4.1)
109+
FSharp.Compiler.Service (>= 0.0.32)
110+
Microsoft.AspNet.Razor (>= 2.0.30506)
111+
RazorEngine (>= 3.3)
112+
Microsoft.AspNet.Razor (3.2.6)
106113
NuGet.CommandLine (4.6.2)
114+
RazorEngine (3.3)
115+
Microsoft.AspNet.Razor (>= 2.0.30506)
107116

108117
GROUP Samples
109118
REDIRECTS: FORCE

tools/fakeiisexpress.fsx

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// https://github.com/fsharp/FAKE/blob/e1378887c41c37d425e134f83424424b76781228/src/legacy/Fake.IIS/IISExpress.fs
2+
// added HostStaticWebsite
3+
#r "System.Xml.Linq"
4+
open Fake
5+
/// Contains tasks to host webprojects in IIS Express.
6+
//[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
7+
//module Fake.IISExpress
8+
9+
open System.Diagnostics
10+
open System
11+
open System.IO
12+
open System.Xml.Linq
13+
14+
/// Options for using IISExpress
15+
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
16+
type IISExpressOptions =
17+
{ ToolPath : string }
18+
19+
/// IISExpress default parameters - tries to locate the iisexpress.exe
20+
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
21+
let IISExpressDefaults =
22+
{ ToolPath =
23+
let root =
24+
if Environment.Is64BitOperatingSystem then
25+
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)
26+
else Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
27+
28+
Path.Combine(root, "IIS Express", "iisexpress.exe") }
29+
30+
/// Create a IISExpress config file from a given template
31+
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
32+
let createConfigFile (name, siteId : int, templateFileName, path, hostName, port : int) =
33+
let xname s = XName.Get(s)
34+
let uniqueConfigFile = Path.Combine(Path.GetTempPath(), "iisexpress-" + Guid.NewGuid().ToString() + ".config")
35+
use template = File.OpenRead(templateFileName)
36+
let xml = XDocument.Load(template)
37+
let sitesElement = xml.Root.Element(xname "system.applicationHost").Element(xname "sites")
38+
let appElement =
39+
XElement
40+
(xname "site", XAttribute(xname "name", name), XAttribute(xname "id", siteId.ToString()),
41+
XAttribute(xname "serverAutoStart", "true"),
42+
43+
XElement
44+
(xname "application", XAttribute(xname "path", "/"),
45+
46+
XElement
47+
(xname "virtualDirectory", XAttribute(xname "path", "/"), XAttribute(xname "physicalPath", DirectoryInfo(path).FullName))),
48+
49+
XElement
50+
(xname "bindings",
51+
52+
XElement
53+
(xname "binding", XAttribute(xname "protocol", "http"),
54+
XAttribute(xname "bindingInformation", "*:" + port.ToString() + ":" + hostName)),
55+
56+
XElement
57+
(xname "binding", XAttribute(xname "protocol", "http"),
58+
XAttribute(xname "bindingInformation", "*:" + port.ToString() + ":*"))))
59+
sitesElement.Add(appElement)
60+
xml.Save(uniqueConfigFile)
61+
uniqueConfigFile
62+
63+
/// This task starts the given site in IISExpress with the given ConfigFile.
64+
/// ## Parameters
65+
///
66+
/// - `setParams` - Function used to overwrite the default parameters.
67+
/// - `configFileName` - The file name of the IISExpress configfile.
68+
/// - `siteId` - The id (in the config file) of the website to run.
69+
///
70+
/// ## Sample
71+
///
72+
/// HostWebsite (fun p -> { p with ToolPath = "iisexpress.exe" }) "configfile.config" 1
73+
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
74+
let HostWebsite setParams configFileName siteId =
75+
let parameters = setParams IISExpressDefaults
76+
77+
use __ = traceStartTaskUsing "StartWebSite" configFileName
78+
let args = sprintf "/config:\"%s\" /siteid:%d" configFileName siteId
79+
tracefn "Starting WebSite with %s %s" parameters.ToolPath args
80+
81+
let proc =
82+
ProcessStartInfo(FileName = parameters.ToolPath, Arguments = args, UseShellExecute = false)
83+
|> Process.Start
84+
85+
proc
86+
87+
let HostStaticWebsite setParams folder =
88+
// https://blogs.msdn.microsoft.com/rido/2015/09/30/serving-static-content-with-iisexpress/
89+
let parameters = setParams IISExpressDefaults
90+
91+
use __ = traceStartTaskUsing "StartWebSite" folder
92+
let args = sprintf @"/path:""%s\""" folder
93+
tracefn "Starting WebSite with %s %s" parameters.ToolPath args
94+
95+
let proc =
96+
ProcessStartInfo(FileName = parameters.ToolPath, Arguments = args, UseShellExecute = false)
97+
|> Process.Start
98+
99+
proc
100+
101+
/// Opens the given url in the browser
102+
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
103+
let OpenUrlInBrowser url = Process.Start(url:string) |> ignore
104+
105+
/// Opens the given website in the browser
106+
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
107+
let OpenWebsiteInBrowser hostName port = sprintf "http://%s:%d/" hostName port |> OpenUrlInBrowser

0 commit comments

Comments
 (0)