diff --git a/integrationtests/Paket.IntegrationTests/PackSpecs.fs b/integrationtests/Paket.IntegrationTests/PackSpecs.fs index c77ee8d08e..1742bf47a3 100644 --- a/integrationtests/Paket.IntegrationTests/PackSpecs.fs +++ b/integrationtests/Paket.IntegrationTests/PackSpecs.fs @@ -564,4 +564,80 @@ let ``#3164 pack analyzer`` () = ZipFile.ExtractToDirectory(package, outPath) Path.Combine(outPath, "analyzers", "dotnet", "cs", "Analyzer.dll") |> checkFileExists - CleanDir rootPath \ No newline at end of file + CleanDir rootPath + + +[] +[] +let ``#4002 dotnet pack of a global tool shouldnt contain references``() = + let project = "tool1" + let scenario = "i004002-pack-global-tools" + prepareSdk scenario + + let rootPath = scenarioTempPath scenario + let outPath = Path.Combine(rootPath, "out") + + directPaket ("restore") scenario + |> ignore + + directDotnet true (sprintf "pack -o \"%s\" /p:PackAsTool=true /bl" outPath) rootPath + |> ignore + + let nupkgPath = Path.Combine(outPath, project + ".1.0.0.nupkg") + if File.Exists nupkgPath |> not then Assert.Fail(sprintf "Expected '%s' to exist" nupkgPath) + let nuspec = NuGetLocal.getNuSpecFromNupgk nupkgPath + + printfn "%A" nuspec + + match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "FSharp.Core") with + | Some s -> Assert.Fail(sprintf "Expected package to still contain the FSharp.Core reference! %A" s) + | None -> () + + match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "Argu") with + | Some s -> Assert.Fail(sprintf "Expected package to still contain the Argu reference! %A" s) + | None -> () + + // Should we remove Microsoft.NETCore.App? + // Problably not as "packaged" console applications have this dependency by default, see https://www.nuget.org/packages/dotnet-mergenupkg + nuspec.Dependencies.Value.Length + |> shouldEqual 0 + + +[] +[] +let ``#4003 dotnet pack of a global tool with p2p``() = + let project = "tool1" + let scenario = "i004003-pack-global-tools-p2p" + prepareSdk scenario + + let rootPath = scenarioTempPath scenario + let outPath = Path.Combine(rootPath, "out") + + directPaket ("restore") scenario + |> ignore + + directDotnet true (sprintf "pack tool1 -o \"%s\" /bl" outPath) rootPath + |> ignore + + let nupkgPath = Path.Combine(outPath, project + ".1.0.0.nupkg") + if File.Exists nupkgPath |> not then Assert.Fail(sprintf "Expected '%s' to exist" nupkgPath) + let nuspec = NuGetLocal.getNuSpecFromNupgk nupkgPath + + printfn "%A" nuspec + + match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "FSharp.Core") with + | Some s -> Assert.Fail(sprintf "Expected package to still contain the FSharp.Core reference! %A" s) + | None -> () + + match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "Argu") with + | Some s -> Assert.Fail(sprintf "Expected package to still contain the Argu reference! %A" s) + | None -> () + + match nuspec.Dependencies.Value |> Seq.tryFind (fun (name,_,_) -> name = PackageName "Suave") with + | Some s -> Assert.Fail(sprintf "Expected package to still contain the Suave reference! %A" s) + | None -> () + + // Should we remove Microsoft.NETCore.App? + // Problably not as "packaged" console applications have this dependency by default, see https://www.nuget.org/packages/dotnet-mergenupkg + nuspec.Dependencies.Value.Length + |> shouldEqual 0 diff --git a/integrationtests/scenarios/i004002-pack-global-tools/before/Program.cs b/integrationtests/scenarios/i004002-pack-global-tools/before/Program.cs new file mode 100644 index 0000000000..974cb3171f --- /dev/null +++ b/integrationtests/scenarios/i004002-pack-global-tools/before/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace tool1 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/integrationtests/scenarios/i004002-pack-global-tools/before/global.json b/integrationtests/scenarios/i004002-pack-global-tools/before/global.json new file mode 100644 index 0000000000..73054ba6f8 --- /dev/null +++ b/integrationtests/scenarios/i004002-pack-global-tools/before/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.1.300-rc1-008673" + } +} \ No newline at end of file diff --git a/integrationtests/scenarios/i004002-pack-global-tools/before/paket.dependencies b/integrationtests/scenarios/i004002-pack-global-tools/before/paket.dependencies new file mode 100644 index 0000000000..333626b443 --- /dev/null +++ b/integrationtests/scenarios/i004002-pack-global-tools/before/paket.dependencies @@ -0,0 +1,5 @@ +source https://api.nuget.org/v3/index.json + +framework: netstandard20, netcoreapp2.1 + +nuget Argu == 5.1.0 diff --git a/integrationtests/scenarios/i004002-pack-global-tools/before/paket.lock b/integrationtests/scenarios/i004002-pack-global-tools/before/paket.lock new file mode 100644 index 0000000000..d44c6cdc48 --- /dev/null +++ b/integrationtests/scenarios/i004002-pack-global-tools/before/paket.lock @@ -0,0 +1,10 @@ +RESTRICTION: || (== netcoreapp2.1) (== netstandard2.0) +NUGET + remote: https://api.nuget.org/v3/index.json + Argu (5.1) + FSharp.Core (>= 4.3.2) + System.Configuration.ConfigurationManager (>= 4.4) + FSharp.Core (4.3.4) + System.Configuration.ConfigurationManager (4.4.1) + System.Security.Cryptography.ProtectedData (>= 4.4) + System.Security.Cryptography.ProtectedData (4.4) diff --git a/integrationtests/scenarios/i004002-pack-global-tools/before/paket.references b/integrationtests/scenarios/i004002-pack-global-tools/before/paket.references new file mode 100644 index 0000000000..1d61b9582d --- /dev/null +++ b/integrationtests/scenarios/i004002-pack-global-tools/before/paket.references @@ -0,0 +1 @@ +Argu diff --git a/integrationtests/scenarios/i004002-pack-global-tools/before/tool1.csproj b/integrationtests/scenarios/i004002-pack-global-tools/before/tool1.csproj new file mode 100644 index 0000000000..40ef84b0b5 --- /dev/null +++ b/integrationtests/scenarios/i004002-pack-global-tools/before/tool1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/global.json b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/global.json new file mode 100644 index 0000000000..73054ba6f8 --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.1.300-rc1-008673" + } +} \ No newline at end of file diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/Class1.cs b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/Class1.cs new file mode 100644 index 0000000000..107e341b18 --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace l1 +{ + public class Class1 + { + } +} diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/l1.csproj b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/l1.csproj new file mode 100644 index 0000000000..14a5f11835 --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/l1.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + \ No newline at end of file diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/paket.references b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/paket.references new file mode 100644 index 0000000000..653550500a --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/l1/paket.references @@ -0,0 +1 @@ +Suave diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/paket.dependencies b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/paket.dependencies new file mode 100644 index 0000000000..7c05346f92 --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/paket.dependencies @@ -0,0 +1,6 @@ +source https://api.nuget.org/v3/index.json + +framework: netstandard20, netcoreapp2.1 + +nuget Argu == 5.1.0 +nuget Suave == 2.4.0 diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/paket.lock b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/paket.lock new file mode 100644 index 0000000000..074afd24b6 --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/paket.lock @@ -0,0 +1,12 @@ +RESTRICTION: || (== netcoreapp2.1) (== netstandard2.0) +NUGET + remote: https://api.nuget.org/v3/index.json + Argu (5.1) + FSharp.Core (>= 4.3.2) + System.Configuration.ConfigurationManager (>= 4.4) + FSharp.Core (4.3.4) + Suave (2.4) + FSharp.Core (>= 4.0 < 5.0) + System.Configuration.ConfigurationManager (4.4.1) + System.Security.Cryptography.ProtectedData (>= 4.4) + System.Security.Cryptography.ProtectedData (4.4) diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/Program.cs b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/Program.cs new file mode 100644 index 0000000000..974cb3171f --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace tool1 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/paket.references b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/paket.references new file mode 100644 index 0000000000..1d61b9582d --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/paket.references @@ -0,0 +1 @@ +Argu diff --git a/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/tool1.csproj b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/tool1.csproj new file mode 100644 index 0000000000..44d4544a36 --- /dev/null +++ b/integrationtests/scenarios/i004003-pack-global-tools-p2p/before/tool1/tool1.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.1 + true + + + + + + diff --git a/src/Paket.Core/embedded/Paket.Restore.targets b/src/Paket.Core/embedded/Paket.Restore.targets index 1e7af99a9b..5c4c58e410 100644 --- a/src/Paket.Core/embedded/Paket.Restore.targets +++ b/src/Paket.Core/embedded/Paket.Restore.targets @@ -140,8 +140,9 @@ %(PaketReferencesFileLinesInfo.PackageVersion) - All + All runtime + true