Skip to content

Commit

Permalink
Pack deps without template - fixes #1429
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 25, 2016
1 parent e20488e commit 0b862be
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
46 changes: 21 additions & 25 deletions src/Paket.Core/PackageMetaData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ let addFile (source : string) (target : string) (templateFile : TemplateFile) =
| IncompleteTemplate ->
failwith "You should only try and add files to template files with complete metadata."

let findDependencies (dependencies : DependenciesFile) config platform (template : TemplateFile) (project : ProjectFile) lockDependencies (map : Map<string, TemplateFile * ProjectFile>) includeReferencedProjects (version :SemVerInfo option) =
let findDependencies lockFile (dependencies : DependenciesFile) config platform (template : TemplateFile) (project : ProjectFile) lockDependencies (map : Map<string, TemplateFile * ProjectFile>) includeReferencedProjects (version :SemVerInfo option) =
let targetDir =
match project.OutputType with
| ProjectOutputType.Exe -> "tools/"
Expand All @@ -136,33 +136,34 @@ let findDependencies (dependencies : DependenciesFile) config platform (template
| None -> PreReleaseStatus.No
| _ -> PreReleaseStatus.All

let getProjects =
seq {
if includeReferencedProjects then
yield! project.GetAllInterProjectDependenciesWithoutProjectTemplates
else
yield project
}
let projectsWithTemplateFile =
project.GetAllInterProjectDependenciesWithProjectTemplates
|> Seq.toList
|> List.filter (fun proj -> proj <> project)

let deps, files =
getProjects
|> Seq.filter (fun proj -> proj <> project)
|> Seq.fold (fun (deps, files) p ->
let deps =
projectsWithTemplateFile
|> List.fold (fun (deps) p ->
match Map.tryFind p.FileName map with
| Some packagedRef -> packagedRef :: deps, files
| Some packagedRef -> packagedRef :: deps
| None ->
let p =
match ProjectFile.TryLoad p.FileName with
| Some p -> p
| _ -> failwithf "Missing project reference in proj file %s" p.FileName

deps, p :: files) ([], [])
let t =
match ProjectFile.FindTemplatesFile(FileInfo p.FileName) with
| Some t -> TemplateFile.Load(t, lockFile, None, Seq.empty |> Map.ofSeq)
| _ -> failwithf "Missing template file for proj file %s" p.FileName

(t,p)::deps) []

// Add the assembly + pdb + dll from this project
// Add the assembly + pdb + dll from this project and recursive project deps
let templateWithOutput =
let additionalFiles =
let assemblyNames = getProjects
|> Seq.map (fun proj -> proj.GetAssemblyName())
let assemblyNames =
if includeReferencedProjects then project.GetAllInterProjectDependenciesWithoutProjectTemplates |> Seq.toList else [ project ]
|> List.map (fun proj -> proj.GetAssemblyName())

assemblyNames
|> Seq.collect (fun assemblyFileName ->
Expand Down Expand Up @@ -206,11 +207,6 @@ let findDependencies (dependencies : DependenciesFile) config platform (template
| None -> failwithf "There was no version given for %s." templateFile.FileName
| IncompleteTemplate -> failwithf "You cannot create a dependency on a template file (%s) with incomplete metadata." templateFile.FileName)
|> List.fold addDependency templateWithOutput

// If project refs will not be packaged, add the assembly to the package
let withDepsAndIncluded =
files
|> List.fold (fun templatefile file -> addFile (toFile config platform file) targetDir templatefile) withDeps

let lockFile =
dependencies.FindLockfile().FullName
Expand Down Expand Up @@ -267,7 +263,7 @@ let findDependencies (dependencies : DependenciesFile) config platform (template

let refs = allReferences |> Seq.toArray
match refs.Length with
| 0 -> withDepsAndIncluded
| 0 -> withDeps
| _ ->
let deps =
refs
Expand Down Expand Up @@ -330,4 +326,4 @@ let findDependencies (dependencies : DependenciesFile) config platform (template
else
failwithf "No package with id '%A' installed in group %O." np.Name groupName
np.Name, dep)
deps |> List.fold addDependency withDepsAndIncluded
deps |> List.fold addDependency withDeps
2 changes: 1 addition & 1 deletion src/Paket.Core/PackageProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildCon
}
)
|> Seq.map (fun (t, p) ->
let deps = findDependencies dependencies buildConfig buildPlatform t p lockDependencies projectTemplates includeReferencedProjects version
let deps = findDependencies lockFile dependencies buildConfig buildPlatform t p lockDependencies projectTemplates includeReferencedProjects version
deps
)
|> Seq.append (allTemplateFiles |> Seq.collect convertRemainingTemplate)
Expand Down
14 changes: 13 additions & 1 deletion src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,17 @@ module ProjectFile =
| None -> true
)

let projectsWithTemplates this projects =
projects
|> Seq.filter(fun proj ->
if proj = this then true
else
let templateFilename = findTemplatesFile (FileInfo proj.FileName)
match templateFilename with
| Some tfn -> TemplateFile.IsProjectType tfn
| None -> false
)


let getOutputDirectory buildConfiguration buildPlatform (project:ProjectFile) =
let platforms =
Expand Down Expand Up @@ -1281,8 +1292,9 @@ type ProjectFile with

member this.GetRecursiveInterProjectDependencies = ProjectFile.getAllReferencedProjects this

member this.GetAllInterProjectDependenciesWithoutProjectTemplates = ProjectFile.getAllReferencedProjects this |> ProjectFile.projectsWithoutTemplates this
member this.GetAllInterProjectDependenciesWithoutProjectTemplates = ProjectFile.getAllReferencedProjects this |> ProjectFile.projectsWithoutTemplates this

member this.GetAllInterProjectDependenciesWithProjectTemplates = ProjectFile.getAllReferencedProjects this |> ProjectFile.projectsWithTemplates this

member this.ReplaceNuGetPackagesFile () = ProjectFile.removeNuGetTargetsEntries this

Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<StartArguments>pack output D:\code\paketbug\output</StartArguments>
<StartArguments>install</StartArguments>
<StartArguments>restore</StartArguments>
<StartArguments>pack -v output D:\code\Paket\integrationtests\scenarios\i001429-pack-deps\temp\out</StartArguments>
<StartArguments>pack -v output D:\code\Paket\integrationtests\scenarios\i001429-pack-deps\temp\out templatefile D:\code\Paket\integrationtests\scenarios\i001429-pack-deps\temp\PaketBug\paket.template</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>c:\code\Paketkopie</StartWorkingDirectory>
Expand Down

0 comments on commit 0b862be

Please sign in to comment.