From 15bab278627279f278c92ed44e628111b76225d6 Mon Sep 17 00:00:00 2001 From: DavidHayden87 Date: Thu, 3 Dec 2015 10:37:41 +0000 Subject: [PATCH] #1281 Use AssemblyTitle if no title is specified in a project template --- docs/content/template-files.md | 2 +- src/Paket.Core/PackageMetaData.fs | 5 +++++ src/Paket.Core/PackageProcess.fs | 16 +++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/content/template-files.md b/docs/content/template-files.md index 033a7d3c0c..098e8e7798 100644 --- a/docs/content/template-files.md +++ b/docs/content/template-files.md @@ -82,7 +82,7 @@ them as below: The other general metadata properties are all optional, and map directly to the field of the same name in the nupkg. -* title +* title (Inferred as the value of the `AssemblyTitleAttribute` if omitted in a project template) * owners * releaseNotes * summary diff --git a/src/Paket.Core/PackageMetaData.fs b/src/Paket.Core/PackageMetaData.fs index 70f39d1e0f..9886071435 100644 --- a/src/Paket.Core/PackageMetaData.fs +++ b/src/Paket.Core/PackageMetaData.fs @@ -79,6 +79,11 @@ let getAuthors attributes = |> Array.map (fun s -> s.Trim()) |> List.ofArray) +let getTitle attributes = + attributes |> Seq.tryPick (function + | Title t -> Some t + | _ -> None) + let getDescription attributes = attributes |> Seq.tryPick (function | Description d -> Some d diff --git a/src/Paket.Core/PackageProcess.fs b/src/Paket.Core/PackageProcess.fs index 3379a242ef..208d807856 100644 --- a/src/Paket.Core/PackageProcess.fs +++ b/src/Paket.Core/PackageProcess.fs @@ -18,16 +18,22 @@ let private merge buildConfig buildPlatform version projectFile templateFile = match withVersion with | { Contents = ProjectInfo(md, opt) } -> + let assembly,id,assemblyFileName = loadAssemblyId buildConfig buildPlatform projectFile + let attribs = loadAssemblyAttributes assemblyFileName assembly + + let mergedOpt = + match opt.Title with + | Some _ -> opt + | None -> { opt with Title = getTitle attribs } + match md with - | Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, opt) } + | Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, mergedOpt) } | _ -> - let assembly,id,assemblyFileName = loadAssemblyId buildConfig buildPlatform projectFile let md = { md with Id = md.Id ++ Some id } match md with - | Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, opt) } + | Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, mergedOpt) } | _ -> - let attribs = loadAssemblyAttributes assemblyFileName assembly let merged = { Id = md.Id @@ -51,7 +57,7 @@ let private merge buildConfig buildPlatform version projectFile templateFile = Environment.NewLine md Environment.NewLine missing - | Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, opt) } + | Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, mergedOpt) } | _ -> templateFile let private convertToSymbols (projectFile : ProjectFile) templateFile =