Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Mar 28, 2015
2 parents 22efa25 + 17db394 commit 97fbb8d
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 66 deletions.
96 changes: 52 additions & 44 deletions build.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// --------------------------------------------------------------------------------------

#r @"packages/FAKE/tools/FakeLib.dll"

open Fake
open Fake.Git
open Fake.AssemblyInfoFile
Expand Down Expand Up @@ -68,36 +67,48 @@ let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/##GitHome##"
// Read additional information from the release notes document
let release = LoadReleaseNotes "RELEASE_NOTES.md"

let genFSAssemblyInfo (projectPath) =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
let folderName = System.IO.Path.GetDirectoryName(projectPath)
let basePath = "src" @@ folderName
let fileName = basePath @@ "AssemblyInfo.fs"
CreateFSharpAssemblyInfo fileName
[ Attribute.Title (projectName)
Attribute.Product project
Attribute.Description summary
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion ]

let genCSAssemblyInfo (projectPath) =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
let folderName = System.IO.Path.GetDirectoryName(projectPath)
let basePath = folderName @@ "Properties"
let fileName = basePath @@ "AssemblyInfo.cs"
CreateCSharpAssemblyInfo fileName
[ Attribute.Title (projectName)
Attribute.Product project
Attribute.Description summary
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion ]
// Helper active pattern for project types
let (|Fsproj|Csproj|Vbproj|) (projFileName:string) =
match projFileName with
| f when f.EndsWith("fsproj") -> Fsproj
| f when f.EndsWith("csproj") -> Csproj
| f when f.EndsWith("vbproj") -> Vbproj
| _ -> failwith (sprintf "Project file %s not supported. Unknown project type." projFileName)

// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" (fun _ ->
let fsProjs = !! "src/**/*.fsproj"
let csProjs = !! "src/**/*.csproj"
fsProjs |> Seq.iter genFSAssemblyInfo
csProjs |> Seq.iter genCSAssemblyInfo
let getAssemblyInfoAttributes projectName =
[ Attribute.Title (projectName)
Attribute.Product project
Attribute.Description summary
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion ]

let getProjectDetails projectPath =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
( projectPath,
projectName,
System.IO.Path.GetDirectoryName(projectPath),
(getAssemblyInfoAttributes projectName)
)

!! "src/**/*.??proj"
|> Seq.map getProjectDetails
|> Seq.iter (fun (projFileName, projectName, folderName, attributes) ->
match projFileName with
| Fsproj -> CreateFSharpAssemblyInfo (folderName @@ "AssemblyInfo.fs") attributes
| Csproj -> CreateCSharpAssemblyInfo ((folderName @@ "Properties") @@ "AssemblyInfo.cs") attributes
| Vbproj -> CreateVisualBasicAssemblyInfo ((folderName @@ "My Project") @@ "AssemblyInfo.vb") attributes
)
)

// Copies binaries from default VS location to exepcted bin folder
// But keeps a subdirectory structure for each project in the
// src folder to support multiple project outputs
Target "CopyBinaries" (fun _ ->
!! "src/**/*.??proj"
|> Seq.map (fun f -> ((System.IO.Path.GetDirectoryName f) @@ "bin/Release", "bin" @@ (System.IO.Path.GetFileNameWithoutExtension f)))
|> Seq.iter (fun (fromDir, toDir) -> CopyDir toDir fromDir (fun _ -> true))
)

// --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -141,23 +152,19 @@ Target "RunTests" (fun _ ->
Target "SourceLink" (fun _ ->
let baseUrl = sprintf "%s/%s/{0}/%%var2%%" gitRaw (project.ToLower())
use repo = new GitRepo(__SOURCE_DIRECTORY__)
//F# projects
!! "src/**/*.fsproj"
|> Seq.iter (fun f ->
let proj = VsProj.LoadRelease f
logfn "source linking %s" proj.OutputFilePdb
let files = proj.Compiles -- "**/AssemblyInfo.fs"
repo.VerifyChecksums files
proj.VerifyPdbChecksums files
proj.CreateSrcSrv baseUrl repo.Revision (repo.Paths files)
Pdbstr.exec proj.OutputFilePdb proj.OutputFilePdbSrcSrv
)
//C# projects
!! "src/**/*.csproj"
|> Seq.iter (fun f ->
let proj = VsProj.LoadRelease f

let addAssemblyInfo (projFileName:String) =
match projFileName with
| Fsproj -> (projFileName, "**/AssemblyInfo.fs")
| Csproj -> (projFileName, "**/AssemblyInfo.cs")
| Vbproj -> (projFileName, "**/AssemblyInfo.vb")

!! "src/**/*.??proj"
|> Seq.map addAssemblyInfo
|> Seq.iter (fun (projFile, assemblyInfo) ->
let proj = VsProj.LoadRelease projFile
logfn "source linking %s" proj.OutputFilePdb
let files = proj.Compiles -- "**/AssemblyInfo.cs"
let files = proj.Compiles -- assemblyInfo
repo.VerifyChecksums files
proj.VerifyPdbChecksums files
proj.CreateSrcSrv baseUrl repo.Revision (repo.Paths files)
Expand Down Expand Up @@ -333,6 +340,7 @@ Target "All" DoNothing
"Clean"
==> "AssemblyInfo"
==> "Build"
==> "CopyBinaries"
==> "RunTests"
=?> ("GenerateReferenceDocs",isLocalBuild)
=?> ("GenerateDocs",isLocalBuild)
Expand Down
12 changes: 6 additions & 6 deletions docs/content/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#I "../../bin"

(**
F# Project Scaffold
===================
FSharp.ProjectScaffold
======================
Documentation
<div class="row">
<div class="span1"></div>
<div class="span6">
<div class="well well-small" id="nuget">
The F# ProjectTemplate library can be <a href="https://nuget.org/packages/FSharp.ProjectTemplate">installed from NuGet</a>:
<pre>PM> Install-Package FSharp.ProjectTemplate</pre>
The FSharp.ProjectScaffold library can be <a href="https://nuget.org/packages/FSharp.ProjectScaffold">installed from NuGet</a>:
<pre>PM> Install-Package FSharp.ProjectScaffold</pre>
</div>
</div>
<div class="span1"></div>
Expand All @@ -26,8 +26,8 @@ Example
This example demonstrates using a function defined in this sample library.
*)
#r "FSharp.ProjectTemplate.dll"
open FSharp.ProjectTemplate
#r "FSharp.ProjectScaffold.dll"
open FSharp.ProjectScaffold

printfn "hello = %i" <| Library.hello 0

Expand Down
4 changes: 2 additions & 2 deletions docs/content/tutorial.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Introducing your project
Say more
*)
#r "FSharp.ProjectTemplate.dll"
open FSharp.ProjectTemplate
#r "FSharp.ProjectScaffold.dll"
open FSharp.ProjectScaffold

Library.hello 0
(**
Expand Down
21 changes: 14 additions & 7 deletions docs/tools/generate.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// (the generated documentation is stored in the 'docs/output' directory)
// --------------------------------------------------------------------------------------

// Binaries that have XML documentation (in a corresponding generated XML file)
let referenceBinaries = [ "##ProjectName##.dll" ]
// Web site location for the generated documentation
let website = "/##ProjectName##"

Expand Down Expand Up @@ -86,19 +84,28 @@ let references =
|> Some
else None

let binaries =
directoryInfo bin
|> subDirectories
|> Array.map (fun d -> d.FullName @@ (sprintf "%s.dll" d.Name))
|> List.ofArray

let libDirs =
directoryInfo bin
|> subDirectories
|> Array.map (fun d -> d.FullName)
|> List.ofArray

// Build API reference from XML comments
let buildReference () =
CleanDir (output @@ "reference")
let binaries =
referenceBinaries
|> List.map (fun lib-> bin @@ lib)
MetadataFormat.Generate
( binaries, output @@ "reference", layoutRootsAll.["en"],
parameters = ("root", root)::info,
sourceRepo = githubLink @@ "tree/master",
sourceFolder = __SOURCE_DIRECTORY__ @@ ".." @@ "..",
publicOnly = true, libDirs = [bin],
?assemblyReferences = references )
?assemblyReferences = references,
publicOnly = true,libDirs = libDirs )

// Build documentation from `fsx` and `md` files in `docs/content`
let buildDocumentation () =
Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ nuget NUnit.Runners
nuget FAKE
nuget SourceLink.Fake

github fsharp/FAKE modules/Octokit/Octokit.fsx
github fsharp/FAKE modules/Octokit/Octokit.fsx
10 changes: 5 additions & 5 deletions src/FSharp.ProjectTemplate/FSharp.ProjectTemplate.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>..\..\bin</OutputPath>
<OutputPath>.\bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>..\..\bin\FSharp.ProjectTemplate.xml</DocumentationFile>
<DocumentationFile>.\bin\Debug\FSharp.ProjectTemplate.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>..\..\bin</OutputPath>
<OutputPath>.\bin\Release</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>..\..\bin\FSharp.ProjectTemplate.xml</DocumentationFile>
<DocumentationFile>.\bin\Release\FSharp.ProjectTemplate.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
Expand Down Expand Up @@ -72,4 +72,4 @@
</Target>
-->
<Import Project="..\..\.paket\paket.targets" />
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/FSharp.ProjectTemplate/paket.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors
projectUrl
http://github.com/##GitHome##/FSharp.ProjectScaffold
iconUrl
https://raw.githubusercontent.com/fsprojects/ProjectScaffold/master/docs/files/img/logo.png
https://raw.githubusercontent.com/##GitHome##/FSharp.ProjectScaffold/master/docs/files/img/logo.png
licenseUrl
http://github.com/##GitHome##/FSharp.ProjectScaffold/blob/master/LICENSE.txt
requireLicenseAcceptance
Expand Down

0 comments on commit 97fbb8d

Please sign in to comment.