Skip to content

Commit

Permalink
NuGet packages with FrameworkAssembly nodes did not work - fixes #1306
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Dec 13, 2015
1 parent d6f6c3e commit 53a9469
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 21 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 2.36.2 - 13.12.2015
* BUGFIX: NuGet packages with FrameworkAssembly nodes did not work - https://github.com/fsprojects/Paket/issues/1306

#### 2.36.1 - 12.12.2015
* Paket install did an unnecessary update when framework restriction were present - https://github.com/fsprojects/Paket/issues/1305

Expand Down
47 changes: 28 additions & 19 deletions src/Paket.Core/InstallModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,19 @@ type InstallModel =
| _ -> None)
|> Seq.choose id
| None -> Seq.empty


member this.CalcLibFolders libs =
libs
|> Seq.map this.ExtractLibFolder
|> Seq.choose id
|> Seq.distinct
|> List.ofSeq
|> PlatformMatching.getSupportedTargetProfiles
|> Seq.map (fun entry -> { Name = entry.Key; Targets = entry.Value; Files = InstallFiles.empty })
|> Seq.toList

member this.AddLibReferences(libs : seq<string>, references) : InstallModel =
let libFolders =
libs
|> Seq.map this.ExtractLibFolder
|> Seq.choose id
|> Seq.distinct
|> List.ofSeq
|> PlatformMatching.getSupportedTargetProfiles
|> Seq.map (fun entry -> { Name = entry.Key; Targets = entry.Value; Files = InstallFiles.empty })
|> Seq.toList
let libFolders = this.CalcLibFolders libs

Seq.fold (fun (model:InstallModel) file ->
match model.ExtractLibFolder file with
Expand All @@ -170,7 +172,7 @@ type InstallModel =
|> Seq.map AnalyzerLib.FromFile
|> List.ofSeq

{ this with Analyzers = this.Analyzers @ analyzerLibs}
{ this with Analyzers = this.Analyzers @ analyzerLibs}

member this.AddTargetsFiles(targetsFiles : seq<string>) : InstallModel =
let targetsFileFolders =
Expand All @@ -181,7 +183,7 @@ type InstallModel =
|> List.ofSeq
|> PlatformMatching.getSupportedTargetProfiles
|> Seq.map (fun entry -> { Name = entry.Key; Targets = entry.Value; Files = InstallFiles.empty })
|> Seq.toList
|> Seq.toList


Seq.fold (fun model file ->
Expand Down Expand Up @@ -217,8 +219,8 @@ type InstallModel =

{ this with ReferenceFileFolders = this.AddFileToFolder(path, file, this.ReferenceFileFolders, (fun f -> f.AddReference)) }

member this.AddTargetsFile(path : LibFolder, file : string) : InstallModel =
{ this with TargetsFileFolders = this.AddFileToFolder(path, file, this.TargetsFileFolders, (fun f -> f.AddTargetsFile)) }
member this.AddTargetsFile(path : LibFolder, file : string) : InstallModel =
{ this with TargetsFileFolders = this.AddFileToFolder(path, file, this.TargetsFileFolders, (fun f -> f.AddTargetsFile)) }

member this.AddReferences(libs) = this.AddLibReferences(libs, NuspecReferences.All)

Expand All @@ -245,16 +247,23 @@ type InstallModel =
| FrameworkRestriction.Between(min,max) ->
folder.GetSinglePlatforms()
|> List.exists (fun t -> t >= min && t < max && t.IsSameCategoryAs(min)))

this.MapFolders(fun folder ->

let model =
if List.isEmpty this.ReferenceFileFolders then
let folders = this.CalcLibFolders ["lib/Default.dll"]
{ this with ReferenceFileFolders = folders }
else
this

model.MapFolders(fun folder ->
if referenceApplies folder then
{ folder with Files = folder.Files.AddFrameworkAssemblyReference reference.AssemblyName }
else
folder)

member this.AddFrameworkAssemblyReferences(references) : InstallModel =
references
|> Seq.fold (fun model reference -> model.AddFrameworkAssemblyReference reference) this
|> Seq.fold (fun model -> model.AddFrameworkAssemblyReference) this

member this.FilterBlackList() =
let includeReferences = function
Expand Down Expand Up @@ -299,7 +308,7 @@ type InstallModel =
TargetsFileFolders =
this.TargetsFileFolders
|> List.map applRestriction
|> List.filter (fun folder -> folder.Targets <> []) }
|> List.filter (fun folder -> folder.Targets <> []) }

member this.GetFrameworkAssembliesLazy =
lazy ([ for lib in this.ReferenceFileFolders do
Expand Down Expand Up @@ -331,4 +340,4 @@ type InstallModel =
.AddFrameworkAssemblyReferences(nuspec.FrameworkAssemblyReferences)
.FilterBlackList()
.ApplyFrameworkRestrictions(frameworkRestrictions)
.RemoveIfCompletelyEmpty()
.RemoveIfCompletelyEmpty()
2 changes: 1 addition & 1 deletion src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ let private applyBindingRedirects (loadedLibs:Dictionary<_,_>) isFirstGroup crea
let findAllReferencesFiles root =
root
|> ProjectFile.FindAllProjects
|> Array.map (fun p ->
|> Array.map (fun p ->
match ProjectFile.FindReferencesFile(FileInfo p.FileName) with
| Some fileName ->
try
Expand Down
29 changes: 29 additions & 0 deletions tests/Paket.Tests/InstallModel/Xml/EmptyLibs.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Paket.InstallModel.Xml.EmptyLibsSpecs

open Paket
open NUnit.Framework
open FsUnit
open Paket.TestHelpers
open Paket.Domain
open Paket.Requirements

let expected = """
<ItemGroup xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Reference Include="System.Xaml">
<Paket>True</Paket>
</Reference>
</ItemGroup>"""

[<Test>]
let ``should generate Xml for framework references and empty libs``() =
let model =
InstallModel.CreateFromLibs(PackageName "TempPkg", SemVer.Parse "0.1", [],
[ ],
[],
[],
Nuspec.Load("Nuspec/EmptyLibs.nuspec"))

let _,targetsNodes,chooseNode,_,_ = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,true,true,None)
chooseNode.OuterXml
|> normalizeXml
|> shouldEqual (normalizeXml expected)
18 changes: 18 additions & 0 deletions tests/Paket.Tests/Nuspec/EmptyLibs.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>TempPkg</id>
<version>0.1</version>
<title>TempPkg</title>
<authors>MtW</authors>
<owners>MtW</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>TempPkg</description>
<language />
<dependencies>
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Xaml" />
</frameworkAssemblies>
</metadata>
</package>
6 changes: 5 additions & 1 deletion tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -121,6 +121,9 @@
</Content>
<Content Include="Nuspec\FsXaml.Wpf.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Nuspec\EmptyLibs.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Nuspec\log4net.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -293,6 +296,7 @@
<Compile Include="InstallModel\Xml\SQLite.fs" />
<Compile Include="InstallModel\Xml\GitInfoPlanter.fs" />
<Compile Include="InstallModel\Xml\LibGit2Sharp.fs" />
<Compile Include="InstallModel\Xml\EmptyLibs.fs" />
<Compile Include="InstallModel\Xml\Plossum.fs" />
<Compile Include="InstallModel\Xml\System.Spatial.fs" />
<Compile Include="InstallModel\Xml\FantomasLib.fs" />
Expand Down

0 comments on commit 53a9469

Please sign in to comment.