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
PM> Install-Package FSharp.ProjectTemplate+ The FSharp.ProjectScaffold library can be installed from NuGet: +
PM> Install-Package FSharp.ProjectScaffold