Skip to content

Commit a9db162

Browse files
committed
Merge branch 'paket_pack_by_tfm' of https://github.com/enricosada/Paket
2 parents 923d734 + 0c0b17d commit a9db162

File tree

13 files changed

+212
-31
lines changed

13 files changed

+212
-31
lines changed

build.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ Target "RunIntegrationTestsNetCore" (fun _ ->
277277
AdditionalArgs =
278278
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky")
279279
sprintf "--logger:trx;LogFileName=%s" ("tests_result/netcore/Paket.IntegrationTests/TestResult.trx" |> Path.GetFullPath) ]
280-
TimeOut = TimeSpan.FromMinutes 50.
280+
TimeOut = TimeSpan.FromMinutes 60.
281281
})
282282
)
283283
"Clean" ==> "DotnetPublish" ==> "RunIntegrationTestsNetCore"

integrationtests/Paket.IntegrationTests/PackSpecs.fs

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,4 +788,68 @@ let ``#2776 transitive references stops on project with template`` () =
788788
dependencies |> shouldContain (PackageName "C")
789789
dependencies |> shouldNotContain (PackageName "nlog")
790790

791-
CleanDir rootPath
791+
CleanDir rootPath
792+
793+
[<Test>]
794+
let ``#3166 pack multitarget with p2p by tfm`` () =
795+
let scenario = "i003166-pack-multitarget-with-p2p-by-tfm"
796+
prepareSdk scenario
797+
let rootPath = scenarioTempPath scenario
798+
799+
directDotnet true "build MyProj.Main -c Release" rootPath
800+
|> Seq.iter (printfn "%A")
801+
802+
let outPath = Path.Combine(rootPath, "out")
803+
directPaket (sprintf """pack "%s" """ outPath) scenario
804+
|> printfn "%s"
805+
806+
let tfmNET45 = FrameworkIdentifier.DotNetFramework(FrameworkVersion.V4_5)
807+
let ``>= net45`` = FrameworkRestriction.AtLeast(tfmNET45)
808+
let tfmNETSTANDARD2_0 = FrameworkIdentifier.DotNetStandard(DotNetStandardVersion.V2_0)
809+
let ``>= netstandard2.0`` = FrameworkRestriction.And [FrameworkRestriction.NotAtLeast(tfmNET45); FrameworkRestriction.AtLeast(tfmNETSTANDARD2_0)]
810+
811+
let _checkNupkgCommon =
812+
813+
let nupkgPath = Path.Combine(outPath, "MyProj.Common.1.0.0.nupkg")
814+
815+
if File.Exists nupkgPath |> not then Assert.Fail(sprintf "Expected '%s' to exist" nupkgPath)
816+
let nuspec = NuGetLocal.getNuSpecFromNupgk nupkgPath
817+
printfn "%A" nuspec
818+
printfn "%A" nuspec.Dependencies.Value
819+
let depsByTfm byTfm = nuspec.Dependencies.Value |> Seq.choose (fun (pkgName,version,tfm) -> if (tfm.GetExplicitRestriction()) = byTfm then Some (pkgName,version) else None) |> Seq.toList
820+
let pkgVer name version = (PackageName name), (VersionRequirement.Parse version)
821+
822+
CollectionAssert.AreEquivalent([ pkgVer "Suave" "[1.1.3]" ], depsByTfm (``>= net45``))
823+
824+
CollectionAssert.AreEquivalent([ pkgVer "Argu" "[5.2.0]" ], depsByTfm (``>= netstandard2.0``))
825+
826+
CollectionAssert.AreEquivalent([ pkgVer "FSharp.Core" "3.1.2.5" ], depsByTfm (FrameworkRestriction.Or [``>= net45``; ``>= netstandard2.0``]))
827+
828+
let unzippedNupkgPath = Path.Combine(outPath, "MyProj.Common")
829+
ZipFile.ExtractToDirectory(nupkgPath, unzippedNupkgPath)
830+
Path.Combine(unzippedNupkgPath, "lib", "net45", "MyProj.Common.dll") |> checkFileExists
831+
Path.Combine(unzippedNupkgPath, "lib", "netstandard2.0", "MyProj.Common.dll") |> checkFileExists
832+
833+
let _checkNupkgMain =
834+
835+
let nupkgPath = Path.Combine(outPath, "MyProj.Main.1.0.0.nupkg")
836+
837+
if File.Exists nupkgPath |> not then Assert.Fail(sprintf "Expected '%s' to exist" nupkgPath)
838+
let nuspec = NuGetLocal.getNuSpecFromNupgk nupkgPath
839+
printfn "%A" nuspec
840+
printfn "%A" nuspec.Dependencies.Value
841+
let depsByTfm byTfm = nuspec.Dependencies.Value |> Seq.choose (fun (pkgName,version,tfm) -> if (tfm.GetExplicitRestriction()) = byTfm then Some (pkgName,version) else None) |> Seq.toList
842+
let pkgVer name version = (PackageName name), (VersionRequirement.Parse version)
843+
844+
CollectionAssert.AreEquivalent([ pkgVer "Suave" "[1.1.3]" ], depsByTfm (``>= net45``))
845+
846+
CollectionAssert.AreEquivalent([ pkgVer "Argu" "[5.2.0]" ], depsByTfm (``>= netstandard2.0``))
847+
848+
CollectionAssert.AreEquivalent([ pkgVer "FSharp.Core" "3.1.2.5"; pkgVer "MyProj.Common" "1.0.0" ], depsByTfm (FrameworkRestriction.Or [``>= net45``; ``>= netstandard2.0``]))
849+
850+
let unzippedNupkgPath = Path.Combine(outPath, "MyProj.Main")
851+
ZipFile.ExtractToDirectory(nupkgPath, unzippedNupkgPath)
852+
Path.Combine(unzippedNupkgPath, "lib", "net45", "MyProj.Main.dll") |> checkFileExists
853+
Path.Combine(unzippedNupkgPath, "lib", "netstandard2.0", "MyProj.Main.dll") |> checkFileExists
854+
855+
CleanDir rootPath
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace MyProj.Common
4+
{
5+
public class Class1
6+
{
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
5+
</PropertyGroup>
6+
<Import Project="..\.paket\Paket.Restore.targets" />
7+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FSharp.Core
2+
Suave framework: net45
3+
Argu framework: netstandard2.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type project
2+
dependencies
3+
framework: net45
4+
framework: netstandard2.0
5+
files
6+
bin/Release/net45/MyProj.Common.dll ==> lib/net45
7+
bin/Release/netstandard2.0/MyProj.Common.dll ==> lib/netstandard2.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace MyProj.Main
4+
{
5+
public class Class1
6+
{
7+
}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<ProjectReference Include="..\MyProj.Common\MyProj.Common.csproj" />
8+
</ItemGroup>
9+
<Import Project="..\.paket\Paket.Restore.targets" />
10+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FSharp.Core
2+
Suave
3+
Argu
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type project
2+
dependencies
3+
framework: net45
4+
framework: netstandard2.0
5+
files
6+
bin/Release/net45/MyProj.Main.dll ==> lib/net45
7+
bin/Release/netstandard2.0/MyProj.Main.dll ==> lib/netstandard2.0

0 commit comments

Comments
 (0)