Skip to content

Commit

Permalink
Strong name Bogus. Fixes #52.
Browse files Browse the repository at this point in the history
  • Loading branch information
bchavez committed Jan 18, 2017
1 parent 2661c19 commit 079c6fb
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 41 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ paket.lock
.paket/paket.exe
__test

/__package
/__compile
/Source/Bogus.snk

Source/Builder/node_modules/**

# User-specific files
Expand Down Expand Up @@ -162,7 +166,5 @@ $RECYCLE.BIN/

# Mac crap
.DS_Store
/Source/Coinbase.Tests/App.config
/nuget.push.bat
/__package
/__compile

3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v9.0.1
* New Feature: Bogus is now a signed assembly; PublicToken: fa1bb3f3f218129a

## v8.0.4
* New Feature: Added `PickRandom(IEnumerable)` overload. Thanks joleharkes.

Expand Down
2 changes: 2 additions & 0 deletions Source/Bogus.snk.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:��Y�y�yP�V�� 6�1h���2�Rw�2����(���o����]fF��~�x��$䜞P�j��+��PX�N��ߏ@��qK��x��^���<B8c�uLT�'����ֈ��IM����=\@�x�aӘղD�����e���f�f�� ��/M^ן���t.R��:�%@�l���l�P���0 ���ƍ�2V�O�Vy�J5�T���!�BH^o�JH����[0���E�qWD��F@�LU�L��E<#Uļ�@��
�_a�'�!���G^he��r�B��\�ƕ��ym�4�J�]T���䪌DF�['�4�3�r6��u6��N_�#�#�=1��So=��{˻��`_�C{�ssV�]I�i�k{9�!Z �NZ����ј�oZB1�P+�~_�>����<���aN����Ch�bqn���S˘�;j�u�,P��r�9��T_�ȱ�F#IQ�V_y����=<(���h�ꍠ5��6�:�/�����N�@ò�2���Y��U�mn%[7vJ����q�0$�u*���j�!�Х��Q���<�MQѽ���PR�( g�z�#���0Z�{�ZX�C�x}3���FP��A�}>����((���
Expand Down
Binary file added Source/Bogus.snk.pub
Binary file not shown.
3 changes: 0 additions & 3 deletions Source/Bogus/AssemblyAttributes.cs

This file was deleted.

1 change: 0 additions & 1 deletion Source/Bogus/Bogus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyAttributes.cs" />
<Compile Include="Binder.cs" />
<Compile Include="DataCategoryAttribute.cs" />
<Compile Include="DataSet.cs" />
Expand Down
19 changes: 7 additions & 12 deletions Source/Bogus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
// <auto-generated/>
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyTitleAttribute("Bogus Fake Data Generator for .NET")]
[assembly: AssemblyProductAttribute("Bogus")]
[assembly: AssemblyCompanyAttribute("Brian Chavez")]
[assembly: AssemblyCopyrightAttribute("Brian Chavez © 2016")]
[assembly: AssemblyCopyrightAttribute("Brian Chavez © 2015")]
[assembly: AssemblyVersionAttribute("0.0.0")]
[assembly: AssemblyFileVersionAttribute("0.0.0")]
[assembly: AssemblyInformationalVersionAttribute("0.0.0-localbuild built on 24/11/2016 22:44:53")]
[assembly: AssemblyInformationalVersionAttribute("0.0.0-localbuild built on 1/1/2015 12:00:00 AM")]
[assembly: AssemblyTrademarkAttribute("Apache License v2.0")]
[assembly: AssemblyDescriptionAttribute("http://www.github.com/bchavez/Bogus")]
[assembly: AssemblyDescriptionAttribute("https://github.com/bchavez/Bogus")]
[assembly: InternalsVisibleToAttribute("Bogus.Tests")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "Bogus Fake Data Generator for .NET";
internal const System.String AssemblyProduct = "Bogus";
internal const System.String AssemblyCompany = "Brian Chavez";
internal const System.String AssemblyCopyright = "Brian Chavez © 2016";
internal const System.String AssemblyVersion = "0.0.0";
internal const System.String AssemblyFileVersion = "0.0.0";
internal const System.String AssemblyInformationalVersion = "0.0.0-localbuild built on 24/11/2016 22:44:53";
internal const System.String AssemblyTrademark = "Apache License v2.0";
internal const System.String AssemblyDescription = "http://www.github.com/bchavez/Bogus";
internal const string Version = "0.0.0";
internal const string InformationalVersion = "0.0.0-localbuild built on 1/1/2015 12:00:00 AM";
}
}
3 changes: 2 additions & 1 deletion Source/Bogus/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"owners": [
"Brian Chavez"
],
"releaseNotes": "## v8.0.1-beta-1\r\n* Allow `Faker<T>.RuleFor` rules to be overridden. Last set rule wins.\r\n\r\n## v7.1.7\r\n* `Faker<T>.AssertConfigurationIsValid` to help in unit testing scenarios.\r\n* Add `Internet.Ipv6` method to generate IPv6 addresses.\r\n\r\n## v7.1.6\r\n* Added `f => f.Commerce` on `Faker`.\r\n\r\n## v7.1.5\r\n* Added `cz`/Czech locale\r\n* Updated `en`, `nl`, `pl`, `sk`, `sv` locales.\r\n* Realistic Dutch city naming\r\n* `Randomizer.AlphaNumeric` added.\r\n* `Randomizer.Double` now accepts `(min,max)` arguments\r\n* Added convenience `Randomizer` for random `Decimal`, `Float`, `Byte`, `Bytes`, `SByte`, `Int`, `UInt`, `ULong`, `Long`, `Short`, `UShort`, `Char` and `Chars`.\r\n\r\n## v7.1.4\r\n* Newtonsoft Json 9.0.1 dependency support.\r\n\r\n\r\nFull History Here: https://github.com/bchavez/Bogus/blob/master/HISTORY.md",
"releaseNotes": "",
"iconUrl": "https://raw.githubusercontent.com/bchavez/Bogus/master/Docs/logo.png",
"projectUrl": "https://github.com/bchavez/Bogus",
"licenseUrl": "https://raw.githubusercontent.com/bchavez/Bogus/master/LICENSE",
Expand All @@ -33,6 +33,7 @@
}
},
"buildOptions": {
"keyFile": "",
"xmlDoc": true,
"configurations": {
"Debug": {
Expand Down
63 changes: 52 additions & 11 deletions Source/Builder/Utils.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

open Fake
open AssemblyInfoFile
open Fake.AppVeyor

module BuildContext =

Expand All @@ -37,7 +38,8 @@ module BuildContext =

let Version = WithoutPreReleaseName FullVersion


let IsTaggedBuild =
AppVeyorEnvironment.RepoTag


open System
Expand Down Expand Up @@ -82,16 +84,18 @@ module Setup =
type Projects(projectName : string, folders : Folders) =
let solutionFile = folders.Source @@ sprintf "%s.sln" projectName
let globalJson = folders.Source @@ "global.json"
let snkFile = folders.Source @@ sprintf "%s.snk" projectName
let snkFilePublic = folders.Source @@ sprintf "%s.snk.pub" projectName

let dnvmVersion =
let json = JsonValue.Parse(System.IO.File.ReadAllText(globalJson))
json?sdk?version.AsString()

member this.SolutionFile = solutionFile
member this.GlobalJson = globalJson
member this.DnvmVersion = dnvmVersion



member this.SnkFile = snkFile
member this.SnkFilePublic = snkFilePublic


open Setup
Expand Down Expand Up @@ -139,12 +143,31 @@ type NugetProject(name : string, assemblyTitle : string, folders : Folders) =
member this.Title = assemblyTitle


let ReadFileAsHexString file =
let bytes = ReadFileAsBytes file
let sb = new System.Text.StringBuilder()
let toHex (b : byte)=
b.ToString("x2")

let acc = bytes
|> Array.fold (fun (acc:System.Text.StringBuilder) b ->
acc.Append(toHex b)
) sb
acc.ToString()

type BuildInfoParams = { DateTime:System.DateTime; ExtraAttrs:list<AssemblyInfoFile.Attribute> }

let MakeBuildInfo (project: NugetProject) (folders : Folders) =
let MakeBuildInfo (project: NugetProject) (folders : Folders) setParams =

let bip : BuildInfoParams = {
DateTime = System.DateTime.UtcNow
ExtraAttrs = []
} |> setParams

let path = folders.Source @@ project.Name @@ "/Properties/AssemblyInfo.cs"
let infoVersion = sprintf "%s built on %s" BuildContext.FullVersion (System.DateTime.UtcNow.ToString())
let copyright = sprintf "Brian Chavez © %i" (System.DateTime.UtcNow.Year)
let infoVersion = sprintf "%s built on %s" BuildContext.FullVersion (bip.DateTime.ToString())
let copyright = sprintf "Brian Chavez © %i" (bip.DateTime.Year)

let attrs =
[
Attribute.Title project.Title
Expand All @@ -155,9 +178,9 @@ let MakeBuildInfo (project: NugetProject) (folders : Folders) =
Attribute.FileVersion BuildContext.Version
Attribute.InformationalVersion infoVersion
Attribute.Trademark "Apache License v2.0"
Attribute.Description "http://www.github.com/bchavez/Bogus"
]
CreateCSharpAssemblyInfo path attrs

CreateCSharpAssemblyInfo path (attrs @ bip.ExtraAttrs)


open System.Reflection
Expand Down Expand Up @@ -236,21 +259,39 @@ module Helpers =
open FSharp.Data
open FSharp.Data.JsonExtensions

let shellExec cmdPath args target =
let shellExec cmdPath args workingDir =
let result = ExecProcess (
fun info ->
info.FileName <- cmdPath
info.WorkingDirectory <- target
info.WorkingDirectory <- workingDir
info.Arguments <- args
) System.TimeSpan.MaxValue
if result <> 0 then failwith (sprintf "'%s' failed" cmdPath + " " + args)

let shellExecSecret cmdPath args workingDir =
let ok = directExec (
fun info ->
info.FileName <- cmdPath
info.WorkingDirectory <- workingDir
info.Arguments <- args
)
if not ok then failwith (sprintf "'%s' failed" cmdPath)

let findOnPath name =
let executable = tryFindFileOnPath name
match executable with
| Some exec -> exec
| None -> failwith (sprintf "'%s' can't find" name)

let encryptFile file secret =
let secureFile = findToolInSubPath "secure-file.exe" "."
let args = sprintf "-encrypt %s -secret %s" file secret
shellExecSecret secureFile args "."

let decryptFile file secret =
let secureFile = findToolInSubPath "secure-file.exe" "."
let args = sprintf "-decrypt %s.enc -secret %s" file secret
shellExecSecret secureFile args "."

let dotnet args workingDir =
let executable = findOnPath "dotnet.exe"
Expand Down
58 changes: 48 additions & 10 deletions Source/Builder/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ Target "msb" (fun _ ->

let tag = "msb_build";

let buildProps = [
"AssemblyOriginatorKeyFile", Projects.SnkFile
"SignAssembly", BuildContext.IsTaggedBuild.ToString()
]

!! BogusProject.ProjectFile
|> MSBuildRelease (BogusProject.OutputDirectory @@ tag) "Build"
|> MSBuildReleaseExt (BogusProject.OutputDirectory @@ tag) buildProps "Build"
|> Log "AppBuild-Output: "


!! TestProject.ProjectFile
|> MSBuildDebug "" "Build"
|> MSBuild "" "Build" (("Configuration", "Debug")::buildProps)
|> Log "AppBuild-Output: "

// !! GridTestProject.ProjectFile
// |> MSBuildDebug "" "Build"
// |> Log "AppBuild-Output: "
)


Expand Down Expand Up @@ -89,7 +90,6 @@ Target "push" (fun _ ->
trace "NuGet Push Task"

failwith "Only CI server should publish on NuGet"

)


Expand All @@ -100,12 +100,28 @@ Target "zip" (fun _ ->
!!(BogusProject.OutputDirectory @@ "**") |> Zip Folders.CompileOutput (Folders.Package @@ BogusProject.Zip)
)

open AssemblyInfoFile

let MakeAttributes (includeSnk:bool) =
let attrs = [
Attribute.Description GitHubUrl
]
if includeSnk then
let pubKey = ReadFileAsHexString Projects.SnkFilePublic
let visibleTo = sprintf "%s, PublicKey=%s" TestProject.Name pubKey
attrs @ [ Attribute.InternalsVisibleTo(visibleTo) ]
else
attrs @ [ Attribute.InternalsVisibleTo(TestProject.Name) ]


Target "BuildInfo" (fun _ ->

trace "Writing Assembly Build Info"

MakeBuildInfo BogusProject Folders
MakeBuildInfo BogusProject Folders (fun bip ->
{ bip with
ExtraAttrs = MakeAttributes(BuildContext.IsTaggedBuild) } )

JsonPoke "version" BuildContext.FullVersion BogusProject.ProjectJson

let releaseNotes = History.NugetText Files.History GitHubUrl
Expand All @@ -119,6 +135,13 @@ Target "Clean" (fun _ ->

JsonPoke "version" "0.0.0-localbuild" BogusProject.ProjectJson
JsonPoke "packOptions.releaseNotes" "" BogusProject.ProjectJson
JsonPoke "buildOptions.keyFile" "" BogusProject.ProjectJson

MakeBuildInfo BogusProject Folders (fun bip ->
{bip with
DateTime = System.DateTime.Parse("1/1/2015")
ExtraAttrs = MakeAttributes(false) } )

)

let RunTests() =
Expand All @@ -132,38 +155,52 @@ let RunTests() =
OutputFile = Files.TestResultFile
ErrorLevel = TestRunnerErrorLevel.Error })


open Fake.AppVeyor

Target "ci" (fun _ ->
trace "ci Task"
)

Target "test" (fun _ ->
trace "CI TEST"
trace "TEST"
RunTests()
)

Target "citest" (fun _ ->
trace "CI TEST"
RunTests()
UploadTestResultsXml TestResultsType.NUnit Folders.Test
)


Target "setup-snk"(fun _ ->
trace "Decrypting Strong Name Key (SNK) file."
let decryptSecret = environVarOrFail "SNKFILE_SECRET"
decryptFile Projects.SnkFile decryptSecret

JsonPoke "buildOptions.keyFile" Projects.SnkFile BogusProject.ProjectJson
)


"Clean"
==> "restore"
==> "BuildInfo"


//build systems
//build systems, order matters
"BuildInfo"
=?> ("setup-snk", BuildContext.IsTaggedBuild)
==> "dnx"
==> "zip"

"BuildInfo"
=?> ("setup-snk", BuildContext.IsTaggedBuild)
==> "msb"
==> "zip"

"BuildInfo"
=?> ("setup-snk", BuildContext.IsTaggedBuild)
==> "mono"
==> "zip"

Expand All @@ -180,6 +217,7 @@ Target "citest" (fun _ ->
"zip"
==> "ci"


//test task depends on msbuild
"msb"
==> "test"
Expand Down
1 change: 1 addition & 0 deletions Source/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ group build
nuget NuGet.CommandLine == 2.8.6
nuget NUnit.Runners == 2.6.4
nuget Newtonsoft.Json
nuget secure-file
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
version: '{build}'

environment:
SNKFILE_SECRET: #SecretDatabase.kdbx / OpenSource / Bogus.snk.enc
secure: Bce2VwNFEBM1oWspgNlpTXSH290GZmc5DCuxjnAX72nBWNbR0S2tq/odIdfv2+t3bA9xzFHEwqvjGVEWgg5ZdfWUYj+PSBr+con0PiUGng0=

skip_commits:
message: /(//skip\W*ci)|(read\W*me)/

Expand Down

0 comments on commit 079c6fb

Please sign in to comment.