Skip to content

Commit

Permalink
move assemblyinfo generation to dotnet sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirik Tsarpalis committed May 31, 2019
1 parent 24735ff commit 017fdb6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 103 deletions.
73 changes: 8 additions & 65 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,13 @@

open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open System

// --------------------------------------------------------------------------------------
// START TODO: Provide project-specific details below
// --------------------------------------------------------------------------------------

// Information about the project are used
// - for version and project name in generated AssemblyInfo file
// - by the generated NuGet package
// - to run tests and to publish documentation on GitHub gh-pages
// - for documentation, you also need to edit info in "docs/tools/generate.fsx"

// The name of the project
// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
let project = "TypeShape"

// Short summary of the project
// (used as description in AssemblyInfo and as a short summary for NuGet package)
let summary = "Practical Generic Programming in F#"

// Longer description of the project
// (used as a description for NuGet package; line breaks are automatically cleaned up)
let description = "Practical Generic Programming in F#"

// List of author names (for NuGet package)
let authors = [ "Eirik Tsarpalis" ]

// Tags for your project (for NuGet package)
let tags = "fsharp, reflection"

// Folder to deposit deploy artifacts
let artifactsDir = __SOURCE_DIRECTORY__ @@ "artifacts"

Expand All @@ -54,8 +29,7 @@ let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "TypeShape"

// The url for the raw files hosted
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/eiriktsarpalis"
let testFramework = getBuildParam "testFramework" |> Option.ofObj

// --------------------------------------------------------------------------------------
// END TODO: The rest of the file includes standard build steps
Expand All @@ -64,43 +38,6 @@ let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/eiriktsarpalis
// Read additional information from the release notes document
let release = LoadReleaseNotes "RELEASE_NOTES.md"

// Helper active pattern for project types
let (|Fsproj|Csproj|Vbproj|Shproj|) (projFileName:string) =
match projFileName with
| f when f.EndsWith("fsproj") -> Fsproj
| f when f.EndsWith("csproj") -> Csproj
| f when f.EndsWith("vbproj") -> Vbproj
| f when f.EndsWith("shproj") -> Shproj
| _ -> 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 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
| Shproj -> ()
)
)

// --------------------------------------------------------------------------------------
// Clean build results

Expand All @@ -122,6 +59,11 @@ let buildWithConfiguration config =
{ c with
Project = __SOURCE_DIRECTORY__
Configuration = config
AdditionalArgs =
[
"-p:GenerateAssemblyInfo=true"
"-p:Version=" + release.AssemblyVersion
]
})

Target "Build.Emit" (fun _ -> buildWithConfiguration "Release")
Expand All @@ -138,6 +80,8 @@ let runTests config (proj : string) =
AdditionalArgs =
[
yield "--no-build"
yield "--blame"
match testFramework with Some f -> yield "--framework" ; yield f | None -> ()
yield "-p:ParallelizeAssemblies=true"
yield "-p:ParallelizeTestCollections=true"
yield "--"
Expand Down Expand Up @@ -232,7 +176,6 @@ Target "Bundle" DoNothing
Target "Release" DoNothing

"Clean"
==> "AssemblyInfo"
==> "Build.Emit"
==> "Build.NoEmit"
==> "Build"
Expand Down
11 changes: 8 additions & 3 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/usr/bin/env bash

TARGET=${1:-Bundle}
IMAGE_LABEL=${2:-"typeshape-build:$RANDOM"}
if [ -z "$*" ] ; then
ARGS=Bundle
else
ARGS="$@"
fi

IMAGE_LABEL="typeshape-build:$RANDOM"

# docker build
docker build -t $IMAGE_LABEL .
Expand All @@ -10,4 +15,4 @@ docker build -t $IMAGE_LABEL .
docker run -t --rm \
-e NUGET_KEY=$NUGET_KEY \
$IMAGE_LABEL \
./build.sh $TARGET
./build.sh $ARGS
17 changes: 0 additions & 17 deletions src/TypeShape.CSharp/Properties/AssemblyInfo.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/TypeShape/AssemblyInfo.fs

This file was deleted.

1 change: 0 additions & 1 deletion src/TypeShape/TypeShape.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="TypeShape.fs" />
<Compile Include="StagingExtensions.fs" />
<Compile Include="SubtypeExtensions.fs" />
Expand Down

0 comments on commit 017fdb6

Please sign in to comment.