diff --git a/build.template b/build.template index 938ae56fd2..f4197a1e0b 100644 --- a/build.template +++ b/build.template @@ -3,7 +3,6 @@ // -------------------------------------------------------------------------------------- #r @"packages/FAKE/tools/FakeLib.dll" - open Fake open Fake.Git open Fake.AssemblyInfoFile @@ -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)) ) // -------------------------------------------------------------------------------------- @@ -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) @@ -333,6 +340,7 @@ Target "All" DoNothing "Clean" ==> "AssemblyInfo" ==> "Build" + ==> "CopyBinaries" ==> "RunTests" =?> ("GenerateReferenceDocs",isLocalBuild) =?> ("GenerateDocs",isLocalBuild) diff --git a/docs/content/index.fsx b/docs/content/index.fsx index 1a42c68774..486c4d382d 100644 --- a/docs/content/index.fsx +++ b/docs/content/index.fsx @@ -4,8 +4,8 @@ #I "../../bin" (** -F# Project Scaffold -=================== +FSharp.ProjectScaffold +====================== Documentation @@ -13,8 +13,8 @@ Documentation
- The F# ProjectTemplate library can be installed from NuGet: -
PM> Install-Package FSharp.ProjectTemplate
+ The FSharp.ProjectScaffold library can be installed from NuGet: +
PM> Install-Package FSharp.ProjectScaffold
@@ -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 diff --git a/docs/content/tutorial.fsx b/docs/content/tutorial.fsx index a5ca244859..5646c672d2 100644 --- a/docs/content/tutorial.fsx +++ b/docs/content/tutorial.fsx @@ -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 (** diff --git a/docs/tools/generate.template b/docs/tools/generate.template index aeb568d567..a3e1e908e4 100644 --- a/docs/tools/generate.template +++ b/docs/tools/generate.template @@ -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##" @@ -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 () = diff --git a/paket.dependencies b/paket.dependencies index d88813177f..712fd08b5c 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -6,4 +6,4 @@ nuget NUnit.Runners nuget FAKE nuget SourceLink.Fake -github fsharp/FAKE modules/Octokit/Octokit.fsx \ No newline at end of file +github fsharp/FAKE modules/Octokit/Octokit.fsx diff --git a/src/FSharp.ProjectTemplate/FSharp.ProjectTemplate.fsproj b/src/FSharp.ProjectTemplate/FSharp.ProjectTemplate.fsproj index f7678303a5..b8f62fa321 100644 --- a/src/FSharp.ProjectTemplate/FSharp.ProjectTemplate.fsproj +++ b/src/FSharp.ProjectTemplate/FSharp.ProjectTemplate.fsproj @@ -19,19 +19,19 @@ full false false - ..\..\bin + .\bin\Debug DEBUG;TRACE 3 - ..\..\bin\FSharp.ProjectTemplate.xml + .\bin\Debug\FSharp.ProjectTemplate.xml pdbonly true true - ..\..\bin + .\bin\Release TRACE 3 - ..\..\bin\FSharp.ProjectTemplate.xml + .\bin\Release\FSharp.ProjectTemplate.xml @@ -72,4 +72,4 @@ --> - \ No newline at end of file + diff --git a/src/FSharp.ProjectTemplate/paket.template b/src/FSharp.ProjectTemplate/paket.template index 5d2c1feff3..f11c9c65d1 100644 --- a/src/FSharp.ProjectTemplate/paket.template +++ b/src/FSharp.ProjectTemplate/paket.template @@ -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