Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pack of global tools (PackAsTool) #3208

Merged
merged 4 commits into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 77 additions & 1 deletion integrationtests/Paket.IntegrationTests/PackSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,80 @@ let ``#3164 pack analyzer`` () =
ZipFile.ExtractToDirectory(package, outPath)
Path.Combine(outPath, "analyzers", "dotnet", "cs", "Analyzer.dll") |> checkFileExists

CleanDir rootPath
CleanDir rootPath


[<Test>]
[<Ignore("disabled for now, because require .net core 2.1.300")>]
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


[<Test>]
[<Ignore("disabled for now, because require .net core 2.1.300")>]
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace tool1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.1.300-rc1-008673"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source https://api.nuget.org/v3/index.json

framework: netstandard20, netcoreapp2.1

nuget Argu == 5.1.0
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Argu
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<Import Project=".paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.1.300-rc1-008673"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace l1
{
public class Class1
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Suave
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace tool1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Argu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PackAsTool>true</PackAsTool>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\l1\l1.csproj" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
3 changes: 2 additions & 1 deletion src/Paket.Core/embedded/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'true'">All</PrivateAssets>
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
<ExcludeAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
<Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
</PackageReference>
</ItemGroup>

Expand Down