Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

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

Target.create "ServeDocs" (fun _ ->
Fakeiisexpress.HostStaticWebsite id (__SOURCE_DIRECTORY__ @@ @"docs\output\") |> ignore
Fakeiisexpress.OpenUrlInBrowser "http://localhost:8080"
)

Target.create "ReleaseDocs" (fun _ ->
Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/gh-pages"
Branches.checkoutBranch "temp/gh-pages" "gh-pages"
Expand Down
6 changes: 3 additions & 3 deletions docs/content/whatsnew.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ and accessing to built-in objects like stored procedures, functoins and tables.
Connectivity information (connection string and/or config file name) is defined in one place
and doesn't have be carried around like in SqlCommandProvider case.

```CreateCommand``` optionally accepts connection, transaction and command timeout parameters.
`CreateCommand` optionally accepts connection, transaction and command timeout parameters.
Any of these parameters can be ommited.
*)

Expand All @@ -62,8 +62,8 @@ do
Access to command and record types
-------------------------------------

```CreateMethod``` combines command type definition and constructor invocation.
Compare it with usage of ```SqlCommandProvider``` where generated command type aliased explicitly.
`CreateMethod` combines command type definition and constructor invocation.
Compare it with usage of `SqlCommandProvider` where generated command type aliased explicitly.
*)

let cmd1 = DB.CreateCommand<"SELECT name, create_date FROM sys.databases">(connectionString)
Expand Down
36 changes: 15 additions & 21 deletions docs/tools/generate.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,28 @@ let info =
"project-github", githubLink
"project-nuget", "http://www.nuget.org/packages/FSharp.Data.SqlClient" ]

#I "../../packages/FSharp.Formatting.2.4.1/lib/net40"
#I "../../packages/RazorEngine.3.3.0/lib/net40"
#I "../../packages/FSharp.Compiler.Service.0.0.36/lib/net40"
#r "../../packages/Microsoft.AspNet.Razor.2.0.30506.0/lib/net40/System.Web.Razor.dll"
#r "../../packages/FAKE/tools/FakeLib.dll"
#r "RazorEngine.dll"
#r "FSharp.Literate.dll"
#r "FSharp.CodeFormat.dll"
#r "FSharp.MetadataFormat.dll"
#load "../../.paket/load/net46/Build/FSharp.Formatting.fsx"
#load "../../.paket/load/net46/Build/FAKE.Lib.fsx"

open Fake
open System.IO
open Fake.FileHelper
open Fake.IO.FileSystemOperators
open FSharp.Literate
open FSharp.MetadataFormat

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

let root = "."

// Paths with template/source/output locations
let bin = __SOURCE_DIRECTORY__ @@ "../../bin"
let content = __SOURCE_DIRECTORY__ @@ "../content"
let output = __SOURCE_DIRECTORY__ @@ "../output"
let files = __SOURCE_DIRECTORY__ @@ "../files"
let templates = __SOURCE_DIRECTORY__ @@ "templates"
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting.2.4.1/"
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/Build/FSharp.Formatting/"
let docTemplate = formatting @@ "templates/docpage.cshtml"

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

// Copy static files and CSS + JS from F# Formatting
let copyFiles () =
CopyRecursive files output true |> Log "Copying file: "
ensureDirectory (output @@ "content")
CopyRecursive (formatting @@ "styles") (output @@ "content") true
|> Log "Copying styles and scripts: "
Fake.IO.Shell.copyRecursive files output true |> Fake.Core.Trace.logItems "Copying file: "
Fake.IO.Directory.ensure (output @@ "content")
Fake.IO.Shell.copyRecursive (formatting @@ "styles") (output @@ "content") true
|> Fake.Core.Trace.logItems "Copying styles and scripts: "

// Build API reference from XML comments
let buildReference () =
CleanDir (output @@ "reference")
Fake.IO.Shell.cleanDir (output @@ "reference")
for lib in referenceBinaries do
MetadataFormat.Generate
( bin @@ lib, output @@ "reference", layoutRoots,
Expand Down
8 changes: 7 additions & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ group Build
framework: >= net40
redirects: force

nuget FAKE = 5.0.0-rc014.167
nuget Fake.Lib = 5.0.0-rc014.167

nuget FSharp.Formatting = 2.4.1
nuget FSharp.Compiler.Service = 0.0.36
nuget RazorEngine = 3.3.0

nuget NuGet.CommandLine
nuget FAKE = 5.0.0-rc014.167

group Test
source https://www.nuget.org/api/v2/
Expand Down
9 changes: 9 additions & 0 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ RESTRICTION: >= net40
NUGET
remote: https://www.nuget.org/api/v2
FAKE (5.0.0-rc014.167)
FAKE.Lib (5.0.0-rc014.167)
FSharp.Compiler.Service (0.0.36)
FSharp.Formatting (2.4.1)
FSharp.Compiler.Service (>= 0.0.32)
Microsoft.AspNet.Razor (>= 2.0.30506)
RazorEngine (>= 3.3)
Microsoft.AspNet.Razor (3.2.6)
NuGet.CommandLine (4.6.2)
RazorEngine (3.3)
Microsoft.AspNet.Razor (>= 2.0.30506)

GROUP Samples
REDIRECTS: FORCE
Expand Down
107 changes: 107 additions & 0 deletions tools/fakeiisexpress.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// https://github.com/fsharp/FAKE/blob/e1378887c41c37d425e134f83424424b76781228/src/legacy/Fake.IIS/IISExpress.fs
// added HostStaticWebsite
#r "System.Xml.Linq"
open Fake
/// Contains tasks to host webprojects in IIS Express.
//[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
//module Fake.IISExpress

open System.Diagnostics
open System
open System.IO
open System.Xml.Linq

/// Options for using IISExpress
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
type IISExpressOptions =
{ ToolPath : string }

/// IISExpress default parameters - tries to locate the iisexpress.exe
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
let IISExpressDefaults =
{ ToolPath =
let root =
if Environment.Is64BitOperatingSystem then
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)
else Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)

Path.Combine(root, "IIS Express", "iisexpress.exe") }

/// Create a IISExpress config file from a given template
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
let createConfigFile (name, siteId : int, templateFileName, path, hostName, port : int) =
let xname s = XName.Get(s)
let uniqueConfigFile = Path.Combine(Path.GetTempPath(), "iisexpress-" + Guid.NewGuid().ToString() + ".config")
use template = File.OpenRead(templateFileName)
let xml = XDocument.Load(template)
let sitesElement = xml.Root.Element(xname "system.applicationHost").Element(xname "sites")
let appElement =
XElement
(xname "site", XAttribute(xname "name", name), XAttribute(xname "id", siteId.ToString()),
XAttribute(xname "serverAutoStart", "true"),

XElement
(xname "application", XAttribute(xname "path", "/"),

XElement
(xname "virtualDirectory", XAttribute(xname "path", "/"), XAttribute(xname "physicalPath", DirectoryInfo(path).FullName))),

XElement
(xname "bindings",

XElement
(xname "binding", XAttribute(xname "protocol", "http"),
XAttribute(xname "bindingInformation", "*:" + port.ToString() + ":" + hostName)),

XElement
(xname "binding", XAttribute(xname "protocol", "http"),
XAttribute(xname "bindingInformation", "*:" + port.ToString() + ":*"))))
sitesElement.Add(appElement)
xml.Save(uniqueConfigFile)
uniqueConfigFile

/// This task starts the given site in IISExpress with the given ConfigFile.
/// ## Parameters
///
/// - `setParams` - Function used to overwrite the default parameters.
/// - `configFileName` - The file name of the IISExpress configfile.
/// - `siteId` - The id (in the config file) of the website to run.
///
/// ## Sample
///
/// HostWebsite (fun p -> { p with ToolPath = "iisexpress.exe" }) "configfile.config" 1
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
let HostWebsite setParams configFileName siteId =
let parameters = setParams IISExpressDefaults

use __ = traceStartTaskUsing "StartWebSite" configFileName
let args = sprintf "/config:\"%s\" /siteid:%d" configFileName siteId
tracefn "Starting WebSite with %s %s" parameters.ToolPath args

let proc =
ProcessStartInfo(FileName = parameters.ToolPath, Arguments = args, UseShellExecute = false)
|> Process.Start

proc

let HostStaticWebsite setParams folder =
// https://blogs.msdn.microsoft.com/rido/2015/09/30/serving-static-content-with-iisexpress/
let parameters = setParams IISExpressDefaults

use __ = traceStartTaskUsing "StartWebSite" folder
let args = sprintf @"/path:""%s\""" folder
tracefn "Starting WebSite with %s %s" parameters.ToolPath args

let proc =
ProcessStartInfo(FileName = parameters.ToolPath, Arguments = args, UseShellExecute = false)
|> Process.Start

proc

/// Opens the given url in the browser
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
let OpenUrlInBrowser url = Process.Start(url:string) |> ignore

/// Opens the given website in the browser
[<System.Obsolete("This API is obsolete. There is no alternative in FAKE 5 yet. You can help by porting this module.")>]
let OpenWebsiteInBrowser hostName port = sprintf "http://%s:%d/" hostName port |> OpenUrlInBrowser