Skip to content

Commit 04b7d9d

Browse files
authored
Merge pull request #3208 from enricosada/paket_and_global_tool
Support pack of global tools (`PackAsTool`)
2 parents 471e570 + 503d9ad commit 04b7d9d

File tree

17 files changed

+184
-2
lines changed

17 files changed

+184
-2
lines changed

integrationtests/Paket.IntegrationTests/PackSpecs.fs

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,4 +564,80 @@ let ``#3164 pack analyzer`` () =
564564
ZipFile.ExtractToDirectory(package, outPath)
565565
Path.Combine(outPath, "analyzers", "dotnet", "cs", "Analyzer.dll") |> checkFileExists
566566

567-
CleanDir rootPath
567+
CleanDir rootPath
568+
569+
570+
[<Test>]
571+
[<Ignore("disabled for now, because require .net core 2.1.300")>]
572+
let ``#4002 dotnet pack of a global tool shouldnt contain references``() =
573+
let project = "tool1"
574+
let scenario = "i004002-pack-global-tools"
575+
prepareSdk scenario
576+
577+
let rootPath = scenarioTempPath scenario
578+
let outPath = Path.Combine(rootPath, "out")
579+
580+
directPaket ("restore") scenario
581+
|> ignore
582+
583+
directDotnet true (sprintf "pack -o \"%s\" /p:PackAsTool=true /bl" outPath) rootPath
584+
|> ignore
585+
586+
let nupkgPath = Path.Combine(outPath, project + ".1.0.0.nupkg")
587+
if File.Exists nupkgPath |> not then Assert.Fail(sprintf "Expected '%s' to exist" nupkgPath)
588+
let nuspec = NuGetLocal.getNuSpecFromNupgk nupkgPath
589+
590+
printfn "%A" nuspec
591+
592+
match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "FSharp.Core") with
593+
| Some s -> Assert.Fail(sprintf "Expected package to still contain the FSharp.Core reference! %A" s)
594+
| None -> ()
595+
596+
match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "Argu") with
597+
| Some s -> Assert.Fail(sprintf "Expected package to still contain the Argu reference! %A" s)
598+
| None -> ()
599+
600+
// Should we remove Microsoft.NETCore.App?
601+
// Problably not as "packaged" console applications have this dependency by default, see https://www.nuget.org/packages/dotnet-mergenupkg
602+
nuspec.Dependencies.Value.Length
603+
|> shouldEqual 0
604+
605+
606+
[<Test>]
607+
[<Ignore("disabled for now, because require .net core 2.1.300")>]
608+
let ``#4003 dotnet pack of a global tool with p2p``() =
609+
let project = "tool1"
610+
let scenario = "i004003-pack-global-tools-p2p"
611+
prepareSdk scenario
612+
613+
let rootPath = scenarioTempPath scenario
614+
let outPath = Path.Combine(rootPath, "out")
615+
616+
directPaket ("restore") scenario
617+
|> ignore
618+
619+
directDotnet true (sprintf "pack tool1 -o \"%s\" /bl" outPath) rootPath
620+
|> ignore
621+
622+
let nupkgPath = Path.Combine(outPath, project + ".1.0.0.nupkg")
623+
if File.Exists nupkgPath |> not then Assert.Fail(sprintf "Expected '%s' to exist" nupkgPath)
624+
let nuspec = NuGetLocal.getNuSpecFromNupgk nupkgPath
625+
626+
printfn "%A" nuspec
627+
628+
match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "FSharp.Core") with
629+
| Some s -> Assert.Fail(sprintf "Expected package to still contain the FSharp.Core reference! %A" s)
630+
| None -> ()
631+
632+
match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "Argu") with
633+
| Some s -> Assert.Fail(sprintf "Expected package to still contain the Argu reference! %A" s)
634+
| None -> ()
635+
636+
match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "Suave") with
637+
| Some s -> Assert.Fail(sprintf "Expected package to still contain the Suave reference! %A" s)
638+
| None -> ()
639+
640+
// Should we remove Microsoft.NETCore.App?
641+
// Problably not as "packaged" console applications have this dependency by default, see https://www.nuget.org/packages/dotnet-mergenupkg
642+
nuspec.Dependencies.Value.Length
643+
|> shouldEqual 0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace tool1
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
Console.WriteLine("Hello World!");
10+
}
11+
}
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "2.1.300-rc1-008673"
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source https://api.nuget.org/v3/index.json
2+
3+
framework: netstandard20, netcoreapp2.1
4+
5+
nuget Argu == 5.1.0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RESTRICTION: || (== netcoreapp2.1) (== netstandard2.0)
2+
NUGET
3+
remote: https://api.nuget.org/v3/index.json
4+
Argu (5.1)
5+
FSharp.Core (>= 4.3.2)
6+
System.Configuration.ConfigurationManager (>= 4.4)
7+
FSharp.Core (4.3.4)
8+
System.Configuration.ConfigurationManager (4.4.1)
9+
System.Security.Cryptography.ProtectedData (>= 4.4)
10+
System.Security.Cryptography.ProtectedData (4.4)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Argu
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
</PropertyGroup>
7+
<Import Project=".paket\Paket.Restore.targets" />
8+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "2.1.300-rc1-008673"
4+
}
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace l1
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+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
<Import Project="..\.paket\Paket.Restore.targets" />
7+
</Project>

0 commit comments

Comments
 (0)