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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,25 @@ _ReSharper*/
_NCrunch*/
[Tt]est[Rr]esult*

keypair.snk
private.snk
*.snk
build/keys/private.snk
build/keys/keypair.snk
build/*
!build/tools
build/tools/*
!build/tools/sn
!build/tools/ilmerge
!build/*.fsx
!build/*.fsx
!build/*.ps1
!build/*.nuspec

/dep/Newtonsoft.Json.4.0.2
!new_docs/build
new_docs/node_modules
doc/Help

/src/Nest.Tests.Unit/*.ncrunchproject
*.ncrunchproject
Expand Down
26 changes: 26 additions & 0 deletions build/Elasticsearch.Net.Connection.Thrift.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Elasticsearch.Net.Connection.Thrift</id>
<version>1.0.0-beta1</version>
<title>Elasticsearch.Net.Connection.Thrift - Thrift support for Elasticsearch.Net</title>
<authors>Martijn Laarman and contributors</authors>
<owners>Martijn Laarman</owners>
<iconUrl>http://nest.azurewebsites.net/images/elasticsearch-net-nuget-icon.png</iconUrl>
<licenseUrl>http://mpdreamz.mit-license.org/</licenseUrl>
<projectUrl>https://github.com/Mpdreamz/NEST</projectUrl>
<summary>An IConnection implementation that utilizes Apache Thrift to talk with elasticsearch</summary>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>An IConnection implementation that utilizes Apache Thrift to talk with elasticsearch</description>
<dependencies>
<dependency id="Elasticsearch.Net" version="1.0.0-beta1"/>
<dependency id="NetReflector" />
</dependencies>
<tags>elasticsearch elastic search lucene thrift nest</tags>
</metadata>
<files>
<file src="output\Elasticsearch.Net.Connection.Thrift\Elasticsearch.Net.Connection.Thrift.dll" target="lib"/>
<file src="output\Elasticsearch.Net.Connection.Thrift\Elasticsearch.Net.Connection.Thrift.pdb" target="lib"/>
<file src="output\Elasticsearch.Net.Connection.Thrift\Elasticsearch.Net.Connection.Thrift.XML" target="lib"/>
</files>
</package>
25 changes: 25 additions & 0 deletions build/Elasticsearch.Net.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Elasticsearch.Net</id>
<version>1.0.0-beta1</version>
<title>Elasticsearch.Net - official low level elasticsearch client</title>
<authors>Martijn Laarman and contributors</authors>
<owners>Martijn Laarman</owners>
<iconUrl>http://nest.azurewebsites.net/images/elasticsearch-net-nuget-icon.png</iconUrl>
<licenseUrl>http://mpdreamz.mit-license.org/</licenseUrl>
<projectUrl>https://github.com/elasticsearch/elasticsearch-net</projectUrl>
<summary>Exposes all the api endpoints but leaves you in control of building the request and response bodies. Comes with built in cluster failover/connection pooling support.
</summary>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Exposes all the api endpoints but leaves you in control of building the request and response bodies. Comes with built in cluster failover/connection pooling support.
</description>
<tags>elasticsearch elastic search lucene nest</tags>
</metadata>
<files>
<file src="output\Elasticsearch.Net\Elasticsearch.Net.dll" target="lib"/>
<file src="output\Elasticsearch.Net\Elasticsearch.Net.pdb" target="lib"/>
<file src="output\Elasticsearch.Net\Elasticsearch.Net.XML" target="lib"/>
<file src="output\Elasticsearch.Net\init.ps1" target="tools"/>
</files>
</package>
25 changes: 25 additions & 0 deletions build/InheritDoc.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#r "System.Xml.Linq.dll"
open System.Xml
open System.Xml.XPath
open System.Linq
open System.Xml.Linq
open System.Text.RegularExpressions

let PatchXmlDoc = fun (file: string) ->
let xml = XDocument.Load file
let nodes = xml.XPathSelectElements("//inheritdoc")
|> Seq.map (fun n ->
let methodName = n.Parent.Attribute(XName.Get("name")).Value
let interfaceName = Regex.Replace(methodName, @"\.([^.]+\.[^.]+\()", ".I$1")
let interfaceNode = xml.XPathSelectElement (sprintf "//member[@name='%s']" interfaceName)
(n.Parent, interfaceNode)
)
|> Seq.filter (fun (implementationElement, interfaceElement) ->
interfaceElement <> null && implementationElement.HasElements && interfaceElement.HasElements
)
let nodesReplace = nodes
|> Seq.iter (fun (implementationElement, interfaceElement) ->
implementationElement.Add (interfaceElement.Descendants().ToList())
)

xml.Save file
5 changes: 3 additions & 2 deletions build/NEST.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>NEST</id>
<version>0.0.0.1</version>
<version>1.0.0-beta1</version>
<title>NEST - Elasticsearch Client</title>
<authors>Martijn Laarman and contributors</authors>
<owners>Martijn Laarman</owners>
Expand All @@ -13,7 +13,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Elasticsearch client, strongly typed interface to Elasticsearch. Fluent request builder, mapped responses and powerful query dsl. Uses and exposes Elasticsearch.Net</description>
<dependencies>
<dependency id="Elasticsearch.Net" />
<dependency id="Elasticsearch.Net" version="1.0.0-beta1"/>
<dependency id="Newtonsoft.Json" version="6.0.1" />
</dependencies>
<tags>elasticsearch elastic search lucene nest</tags>
Expand All @@ -22,5 +22,6 @@
<file src="output\Nest\Nest.dll" target="lib"/>
<file src="output\Nest\Nest.pdb" target="lib"/>
<file src="output\Nest\Nest.XML" target="lib"/>
<file src="output\Nest\init.ps1" target="tools"/>
</files>
</package>
176 changes: 127 additions & 49 deletions build/build.fsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// include Fake lib
#r @"tools/FAKE/tools/FakeLib.dll"
#load @"InheritDoc.fsx"
open Fake
open System
open InheritDoc
open SemVerHelper
open AssemblyInfoFile


// Properties
let buildDir = "build/output/"
Expand All @@ -14,11 +19,34 @@ Target "Clean" (fun _ ->
CleanDir buildDir
)



Target "BuildApp" (fun _ ->
let binDirs = !! "src/**/bin/**"
|> Seq.map DirectoryName
|> Seq.distinct
|> Seq.filter (fun f -> (f.EndsWith("Debug") || f.EndsWith("Release")) && not (f.Contains "CodeGeneration"))

CleanDirs binDirs

//Override the prebuild event because it just calls a fake task BuildApp depends on anyways
let msbuildProperties = [
("Configuration","Release");
("PreBuildEvent","ECHO");
]

//Compile each csproj and output it seperately in build/output/PROJECTNAME
!! "src/**/*.csproj"
|> Seq.map(fun f -> (f, buildDir + directoryInfo(f).Name.Replace(".csproj", "")))
|> Seq.iter(fun (f,d) -> MSBuildRelease d "Build" (seq { yield f }) |> ignore)
|> Seq.iter(fun (f,d) -> MSBuild d "Build" msbuildProperties (seq { yield f }) |> ignore)

//Scan for xml docs and patch them to replace <inheritdoc /> with the documentation
//from their interfaces
!! "build/output/Nest/Nest.xml" |> Seq.iter(fun f -> PatchXmlDoc f)

CopyFile "build/output/Nest/init.ps1" "build/nest-init.ps1"
CopyFile "build/output/Elasticsearch.Net/init.ps1" "build/elasticsearch-init.ps1"

)

Target "Test" (fun _ ->
Expand All @@ -31,85 +59,130 @@ Target "Test" (fun _ ->
)

let keyFile = "build/keys/keypair.snk"
let validateSignedAssembly = fun name ->

let createKeys = fun _ ->
let sn = "build/tools/sn/sn.exe"
ExecProcess(fun p ->
p.FileName <- sn
p.Arguments <- sprintf @"-v build\output\%s.dll" name
) (TimeSpan.FromMinutes 5.0)

let signAssembly = fun name ->
let ilmerge = "build/tools/ilmerge/ILMerge.exe"
let platform = @"/targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
let i = sprintf "build\\output\\%s\\%s" name name
let o = sprintf "build\\output\\%s" name
p.Arguments <- sprintf @"-k %s" keyFile
) (TimeSpan.FromMinutes 5.0) |> ignore

ExecProcess(fun p ->
p.FileName <- sn
p.Arguments <- sprintf @"-p %s %s" keyFile "build/keys/public.snk"
) (TimeSpan.FromMinutes 5.0) |> ignore

Target "CreateKeysIfAbsent" (fun _ ->
if not (fileExists keyFile) then createKeys()
)

let validateSignedAssembly = fun name ->
let sn = "build/tools/sn/sn.exe"
let out = (ExecProcessAndReturnMessages(fun p ->
p.FileName <- sn
p.Arguments <- sprintf @"-v build\output\%s\%s.dll" name name
) (TimeSpan.FromMinutes 5.0))

let dll = i + ".dll"
let outdll = o + ".dll"
let pdb = o + ".pdb"

let signExitCode = (
ExecProcess(fun p ->
p.FileName <- ilmerge
p.Arguments <- (sprintf "%s /keyfile:%s /out:%s %s"
dll keyFile outdll platform)
) (TimeSpan.FromMinutes 5.0)
)
let valid = (out.ExitCode, out.Messages.FindIndex(fun s -> s.Contains("is valid")))

match valid with
| (0, i) when i >= 0 -> trace (sprintf "%s was signed correctly" name)
| (_, _) -> failwithf "{0} was not validly signed"

let out = (ExecProcessAndReturnMessages(fun p ->
p.FileName <- sn
p.Arguments <- sprintf @"-T build\output\%s\%s.dll" name name
) (TimeSpan.FromMinutes 5.0))

let tokenMessage = (out.Messages.Find(fun s -> s.Contains("Public key token is")));
let token = (tokenMessage.Replace("Public key token is", "")).Trim();

let validateExitCode = validateSignedAssembly name
match (signExitCode, validateExitCode) with
| (0,0) ->
MoveFile (DirectoryName dll) outdll
MoveFile (DirectoryName dll) pdb
| _ ->
failwithf "Failed to sign {0}" name
let valid = (out.ExitCode, token)
let oficialToken = "96c599bbe3e70f5d"
match valid with
| (0, t) when t = oficialToken ->
trace (sprintf "%s was signed with official key token %s" name t)
| (_, t) -> traceFAKE "%s was not signed with the official token: %s but %s" name oficialToken t

let nugetPack = fun name ->

let fileVersion = (getBuildParamOrDefault "version" "0.1.0")
CreateDir nugetOutDir

let package = (sprintf @"build\%s.nuspec" name)
let packageContents = ReadFileAsString package
let re = @"(?<start>\<version\>|""(Elasticsearch.Net|Nest)"" version="")[^""><]+(?<end>\<\/version\>|"")"
let replacedContents = regex_replace re (sprintf "${start}%s${end}" fileVersion) packageContents
WriteStringToFile false package replacedContents

let dir = sprintf "%s/%s/" buildDir name
let version = "1.0.0-c2"
NuGetPack (fun p ->
{p with
Version = version
Version = fileVersion
WorkingDir = dir
OutputPath = dir
})
(sprintf @"build\%s.nuspec" name)
package

MoveFile nugetOutDir (buildDir + (sprintf "%s/%s.%s.nupkg" name name version))
MoveFile nugetOutDir (buildDir + (sprintf "%s/%s.%s.nupkg" name name fileVersion))

let buildDocs = fun action ->
let node = @"build\tools\Node.js\node.exe"
let wintersmith = @"..\build\tools\node_modules\wintersmith\bin\wintersmith"
ExecProcess (fun p ->
p.WorkingDirectory <- "new_docs"
p.FileName <- node
p.Arguments <- sprintf "\"%s\" %s" wintersmith action
) (TimeSpan.FromMinutes (if action = "preview" then 300.0 else 5.0))

p.WorkingDirectory <- "new_docs"
p.FileName <- node
p.Arguments <- sprintf "\"%s\" %s" wintersmith action
)
(TimeSpan.FromMinutes (if action = "preview" then 300.0 else 5.0))

Target "Version" (fun _ ->
let v = (getBuildParamOrDefault "version" "0.1.0")
let version = SemVerHelper.parse v
let assemblyVersion = sprintf "%i.%i.0.0" version.Major version.Minor

trace (sprintf "%s %s" v assemblyVersion)

let fileVersion = (getBuildParamOrDefault "version" "0.1.0")
let version = SemVerHelper.parse fileVersion

let suffix = fun (prerelease: PreRelease) -> sprintf "-%s%i" prerelease.Name prerelease.Number.Value
let assemblySuffix = if version.PreRelease.IsSome then suffix version.PreRelease.Value else "";
let assemblyVersion = sprintf "%i.0.0%s" version.Major assemblySuffix

match (assemblySuffix, version.Minor, version.Patch) with
| (s, m, p) when s <> "" && (m <> 0 || p <> 0) -> failwithf "Cannot create prereleases for minor or major builds!"
| ("", _, _) -> traceFAKE "Building fileversion %s for asssembly version %s" fileVersion assemblyVersion
| _ -> traceFAKE "Building prerelease %s for major assembly version %s " fileVersion assemblyVersion

let assemblyDescription = fun (f: string) ->
let name = f
match f.ToLowerInvariant() with
| f when f = "elasticsearch.net" -> "Elasticsearch.Net - oficial low level elasticsearch client"
| f when f = "nest" -> "NEST - oficial high level elasticsearch client"
| f when f = "elasticsearch.net.connection.thrift" -> "Elasticsearc.Net.Connection.Thrift - Add thrift support to elasticsearch."
| _ -> sprintf "%s" name

!! "src/**/AssemblyInfo.cs"
|> Seq.iter(fun f ->
let name = (directoryInfo f).Parent.Parent.Name
CreateCSharpAssemblyInfo f [
Attribute.Title name
Attribute.Copyright (sprintf "Elasticsearch %i" DateTime.UtcNow.Year)
Attribute.Description (assemblyDescription name)
Attribute.Company "Elasticsearch"
Attribute.Configuration "Release"
Attribute.Version assemblyVersion
Attribute.FileVersion fileVersion
Attribute.InformationalVersion fileVersion
]
)
)


Target "Release" (fun _ ->
if not <| fileExists keyFile
then failwithf "{0} does not exist to sign the assemblies" keyFile

//signAssembly("Elasticsearch.Net")
//signAssembly("Elasticsearch.Net.Connection.Thrift")
//signAssembly("Nest")

nugetPack("Elasticsearch.Net")
nugetPack("Elasticsearch.Net.Connection.Thrift")
nugetPack("Nest")

validateSignedAssembly("Elasticsearch.Net")
validateSignedAssembly("Elasticsearch.Net.Connection.Thrift")
validateSignedAssembly("Nest")
)

Target "Docs" (fun _ -> buildDocs "build" |> ignore)
Expand All @@ -120,14 +193,19 @@ Target "DocsPreview" (fun _ ->

// Dependencies
"Clean"
==> "CreateKeysIfAbsent"
=?> ("Version", hasBuildParam "version")
==> "BuildApp"
==> "Test"
==> "Build"

"Build"
==> "Docs"
==> "Release"

"DocsPreview"
"BuildApp"
"CreateKeysIfAbsent"
"Version"
// start build
RunTargetOrDefault "Build"
1 change: 1 addition & 0 deletions build/elasticsearch-init.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$DTE.ItemOperations.Navigate("http://nest.azurewebsites.net/elasticsearch-net/quick-start.html")
Binary file removed build/keys/public.snk
Binary file not shown.
1 change: 1 addition & 0 deletions build/nest-init.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$DTE.ItemOperations.Navigate("http://nest.azurewebsites.net/nest/quick-start.html")
Binary file removed doc/Help/Documentation.chm
Binary file not shown.
Loading