Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for AssemblyMetadata in AssemblyInfoHelper - closes #683 #694

Merged
merged 3 commits into from
Mar 22, 2015
Merged
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
23 changes: 17 additions & 6 deletions src/app/FakeLib/AssemblyInfoHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ type AssemblyInfoReplacementParams =
AssemblyFileVersion : string
AssemblyInformationalVersion : string
AssemblyConfiguration : string
AssemblyMetadata : string list }
AssemblyMetadata : (string * string) list }

/// AssemblyInfoReplacement default params
let AssemblyInfoReplacementDefaults =
Expand All @@ -224,18 +224,29 @@ let ReplaceAssemblyInfoVersions param =
let replaceAttribute attributeName value line =
if isNullOrEmpty value then line
else regex_replace (sprintf "%s\\s*[(][^)]*[)]" attributeName) (sprintf "%s(\"%s\")" attributeName value) line

let metadaData =
if parameters.AssemblyMetadata = [] then "" else
(String.Join("\", \"", parameters.AssemblyMetadata))

let rec replaceMetadataAttributes metadata line =
let replaceSingleMetadataAttribute key value line =
if isNullOrEmpty key then line
else
regex_replace
(sprintf "AssemblyMetadata\\s*\\(\\s*\"%s\"\\s*,[^)]*\\)" key)
(sprintf "AssemblyMetadata(\"%s\", \"%s\")" key value)
line
match metadata with
| (key, value) :: rest ->
line
|> replaceSingleMetadataAttribute key value
|> replaceMetadataAttributes rest
| _ -> line

let replaceLine line =
line
|> replaceAttribute "AssemblyVersion" parameters.AssemblyVersion
|> replaceAttribute "AssemblyConfiguration" parameters.AssemblyConfiguration
|> replaceAttribute "AssemblyFileVersion" parameters.AssemblyFileVersion
|> replaceAttribute "AssemblyInformationalVersion" parameters.AssemblyInformationalVersion
|> replaceAttribute "AssemblyMetadata" metadaData
|> replaceMetadataAttributes parameters.AssemblyMetadata

ReadFile parameters.OutputFileName
|> Seq.map replaceLine
Expand Down