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

Symbols source #1383

Merged
merged 3 commits into from
Jan 14, 2016
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
33 changes: 21 additions & 12 deletions src/Paket.Core/PackageMetaData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,28 @@ let findDependencies (dependencies : DependenciesFile) config platform (template

// Add the assembly + pdb + dll from this project
let templateWithOutput =
let assemblyFileName = toFile config platform project
let fi = FileInfo(assemblyFileName)
let name = Path.GetFileNameWithoutExtension fi.Name
let additionalFiles =
let referencedProjects = seq{yield project; yield! project.GetInterProjectDependencies() |> Seq.map(fun proj -> ProjectFile.TryLoad(proj.Path).Value)}
let assemblyNames = referencedProjects
|> Seq.map (fun proj -> proj.GetAssemblyName())
assemblyNames
|> Seq.collect (fun assemblyFileName ->
let assemblyfi = FileInfo(assemblyFileName)
let name = Path.GetFileNameWithoutExtension assemblyfi.Name

let additionalFiles =
fi.Directory.GetFiles(name + ".*")
|> Array.filter (fun f ->
let isSameFileName = Path.GetFileNameWithoutExtension f.Name = name
let isValidExtension =
[".xml"; ".dll"; ".exe"; ".pdb"; ".mdb"]
|> List.exists ((=) (f.Extension.ToLower()))

isSameFileName && isValidExtension)
let projectdir = Path.GetDirectoryName(Path.GetFullPath(project.FileName))
let path = Path.Combine(projectDir, project.GetOutputDirectory config platform)
let files = Directory.GetFiles(path, name + ".*")
files
|> Array.map (fun f -> FileInfo f)
|> Array.filter (fun fi ->
let isSameFileName = (Path.GetFileNameWithoutExtension fi.Name) = name
let isValidExtension =
[".xml"; ".dll"; ".exe"; ".pdb"; ".mdb"]
|> List.exists ((=) (fi.Extension.ToLower()))
isSameFileName && isValidExtension)
)
|> Seq.toArray

additionalFiles
|> Array.fold (fun template file -> addFile file.FullName targetDir template) template
Expand Down
24 changes: 13 additions & 11 deletions src/Paket.Core/PackageProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,30 @@ let private merge buildConfig buildPlatform versionFromAssembly specificVersions
| Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, mergedOpt) }
| _ -> templateFile

let private convertToSymbols (projectFile : ProjectFile) templateFile =
let private convertToSymbols (projectFile : ProjectFile) (includeReferencedProjects : bool) templateFile =
let sourceFiles =
let getTarget compileItem =
match compileItem.Link with
| Some link -> link
| None -> compileItem.Include
|> Path.GetDirectoryName
|> (fun d -> Path.Combine("src", d))
let item = match compileItem.Link with
| Some link -> link
| None -> compileItem.Include

projectFile.GetCompileItems()
let dir = Path.GetDirectoryName(Path.GetFullPath(item))
let tld = Path.GetFileName(Path.GetDirectoryName(dir))
Path.Combine("src", tld, Path.GetFileName(dir))

projectFile.GetCompileItems(includeReferencedProjects)
|> Seq.map (fun c -> c.Include, getTarget c)
|> Seq.toList

match templateFile.Contents with
| CompleteInfo(core, optional) ->
let augmentedFiles = optional.Files |> List.append sourceFiles
let augmentedFiles = optional.Files |> List.append sourceFiles
{ templateFile with Contents = CompleteInfo({ core with Symbols = true }, { optional with Files = augmentedFiles }) }
| ProjectInfo(core, optional) ->
let augmentedFiles = optional.Files |> List.append sourceFiles
let augmentedFiles = optional.Files |> List.append sourceFiles
{ templateFile with Contents = ProjectInfo({ core with Symbols = true }, { optional with Files = augmentedFiles }) }

let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildConfig, buildPlatform, version, specificVersions, releaseNotes, templateFile, excludedTemplates, lockDependencies, symbols) =
let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildConfig, buildPlatform, version, specificVersions, releaseNotes, templateFile, excludedTemplates, lockDependencies, symbols, includeReferencedProjects) =
let buildConfig = defaultArg buildConfig "Release"
let buildPlatform = defaultArg buildPlatform ""
let packageOutputPath = if Path.IsPathRooted(packageOutputPath) then packageOutputPath else Path.Combine(workingDir,packageOutputPath)
Expand Down Expand Up @@ -134,7 +136,7 @@ let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildCon
// add dependencies
let allTemplates =
let optWithSymbols projectFile templateFile =
seq { yield templateFile; if symbols then yield templateFile |> convertToSymbols projectFile }
seq { yield templateFile; if symbols then yield templateFile |> convertToSymbols projectFile includeReferencedProjects }

let convertRemainingTemplate fileName =
let templateFile = TemplateFile.Load(fileName,lockFile,version,specificVersions)
Expand Down
22 changes: 16 additions & 6 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,18 +1088,28 @@ type ProjectFile =

sprintf "%s.%s" assemblyName (this.OutputType |> function ProjectOutputType.Library -> "dll" | ProjectOutputType.Exe -> "exe")

member this.GetCompileItems () =
let getCompileItem (compileNode : XmlNode) =
let includePath = compileNode |> getAttribute "Include" |> fun a -> a.Value
member this.GetCompileItems (includeReferencedProjects:bool) =
let getCompileItem (projfile: ProjectFile, compileNode: XmlNode) =
let getIncludePath (projfile: ProjectFile) (includePath: string)=
Path.Combine(Path.GetDirectoryName(Path.GetFullPath(projfile.FileName)), includePath)

let includePath = compileNode |> getAttribute "Include" |> fun a -> a.Value |> getIncludePath projfile
compileNode
|> getDescendants "Link"
|> function
| [] -> { Include = includePath; Link = None }
| [link] | link::_ -> { Include = includePath; Link = Some link.InnerText }

this.Document
|> getDescendants "Compile"
|> Seq.map getCompileItem
let referencedProjects = if includeReferencedProjects then
let getProjects = this.GetInterProjectDependencies() |> Seq.map (fun proj -> ProjectFile.TryLoad(proj.Path).Value)
seq{yield this; yield! getProjects}
else seq {yield this}

referencedProjects |> Seq.collect(fun proj ->
proj.Document
|> getDescendants "Compile"
|> Seq.map (fun i -> getCompileItem(proj, i))
)

static member LoadFromStream(fullName:string, stream:Stream) =
let doc = new XmlDocument()
Expand Down
5 changes: 3 additions & 2 deletions src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,14 @@ type Dependencies(dependenciesFileName: string) =
FindReferences.FindReferencesForPackage (GroupName group) (PackageName package) |> this.Process

// Packs all paket.template files.
member this.Pack(outputPath, ?buildConfig, ?buildPlatform, ?version, ?specificVersions, ?releaseNotes, ?templateFile, ?workingDir, ?excludedTemplates, ?lockDependencies, ?symbols) =
member this.Pack(outputPath, ?buildConfig, ?buildPlatform, ?version, ?specificVersions, ?releaseNotes, ?templateFile, ?workingDir, ?excludedTemplates, ?lockDependencies, ?symbols, ?includeReferencedProjects) =
let dependenciesFile = DependenciesFile.ReadFromFile dependenciesFileName
let specificVersions = defaultArg specificVersions Seq.empty
let workingDir = defaultArg workingDir (dependenciesFile.FileName |> Path.GetDirectoryName)
let lockDependencies = defaultArg lockDependencies false
let symbols = defaultArg symbols false
PackageProcess.Pack(workingDir, dependenciesFile, outputPath, buildConfig, buildPlatform, version, specificVersions, releaseNotes, templateFile, excludedTemplates, lockDependencies, symbols)
let includeReferencedProjects = defaultArg includeReferencedProjects false
PackageProcess.Pack(workingDir, dependenciesFile, outputPath, buildConfig, buildPlatform, version, specificVersions, releaseNotes, templateFile, excludedTemplates, lockDependencies, symbols, includeReferencedProjects)

/// Pushes a nupkg file.
static member Push(packageFileName, ?url, ?apiKey, (?endPoint: string), ?maxTrials) =
Expand Down
2 changes: 2 additions & 0 deletions src/Paket/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ type PackArgs =
| [<CustomCommandLine("releaseNotes")>] ReleaseNotes of string
| [<CustomCommandLine("lock-dependencies")>] LockDependencies
| [<CustomCommandLine("symbols")>] Symbols
| [<CustomCommandLine("include-referenced-projects")>] IncludeReferencedProjects
with
interface IArgParserTemplate with
member this.Usage =
Expand All @@ -323,6 +324,7 @@ with
| ReleaseNotes(_) -> "Specify relase notes for the package."
| LockDependencies -> "Get the version requirements from paket.lock instead of paket.dependencies."
| Symbols -> "Build symbol/source packages in addition to library/content packages."
| IncludeReferencedProjects -> "Include symbol/source from referenced projects."

type PushArgs =
| [<CustomCommandLine("url")>][<Mandatory>] Url of string
Expand Down
3 changes: 2 additions & 1 deletion src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ let pack (results : ParseResults<_>) =
excludedTemplates = results.GetResults <@ PackArgs.ExcludedTemplate @>,
workingDir = Environment.CurrentDirectory,
lockDependencies = results.Contains <@ PackArgs.LockDependencies @>,
symbols = results.Contains <@ PackArgs.Symbols @>)
symbols = results.Contains <@ PackArgs.Symbols @>,
includeReferencedProjects = results.Contains <@ PackArgs.IncludeReferencedProjects @>)

let findPackages (results : ParseResults<_>) =
let maxResults = defaultArg (results.TryGetResult <@ FindPackagesArgs.MaxResults @>) 10000
Expand Down