fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
2.02k stars 524 forks source link

`copy_local: false` has no effect (at least with .NET SDK) #3154

Closed nightroman closed 6 years ago

nightroman commented 6 years ago

copy_local: false has no effect (at least with "new style" .NET SDK projects, I remember it used to work some long time ago with "old style" .NET Framework projects).

Environments and steps

In a new empty directory, create a new F# project

dotnet new classlib -lang f#

Edit the project file and replace netstandard2.0 with net462

<TargetFramework>net462</TargetFramework>

Invoke

paket init

Edit paket.dependencies (note copy_local: false)

copy_local: false
framework: net462
source https://www.nuget.org/api/v2
nuget Suave

Edit paket.references

Suave

Invoke

paket install

Now build the project

dotnet build

Expected behaviour

bin\Debug\net462 contains DLL and PDB files of our library and nothing else.

Actual behaviour

bin\Debug\net462, in spite of copy_local: false, contains a lot of files copied from FSharp.Core and Suave.

forki commented 6 years ago

What should it do?

Roman Kuzmin notifications@github.com schrieb am So., 15. Apr. 2018, 14:36:

copy_local: false has no effect (at least with .NET SDK, I remember it used to work some long time ago).

Environments and steps

  • paket info ~ Paket version 5.156.1
  • dotnet --version ~ 2.1.104

In a new empty directory, create a new F# project

dotnet new classlib -lang f#

Edit the project file and replace netstandard2.0 with net462

net462

Invoke

paket init

Edit paket.dependencies (note copy_local: false)

copy_local: false framework: net462 source https://www.nuget.org/api/v2 nuget Suave

Edit paket.references

Suave

Invoke

paket install

Now build the project

dotnet build

Expected behaviour

bin\Debug\net462 contains DLL and PDB files of our library and nothing else.

Actual behaviour

bin\Debug\net462, in spite of copy_local: false, contains a lot of files copied from FSharp.Core and Suave.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fsprojects/Paket/issues/3154, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNJLCOdgU663m-FITJplktOgZK1pCks5toz7fgaJpZM4TVdTr .

nightroman commented 6 years ago

What should it do?

If there is such a way then it should result in assemblies not copied to the output directory during build.

If there is no such a way known (is it what the question means?) it would be nice to mention this fact about copy_local behaviour in .NET SDK projects.

nightroman commented 6 years ago

I am not suggesting this but one possible way is to add assembly references in the old fashioned way to projects if copy_local: false. Just in order to be able to set their Private to false. Yes, this will make projects less "clean" but avoiding redundant copies in several projects in a large solution may be important.

forki commented 6 years ago

The question is: does PackageReferences have a corresponding attribute. If not we need to feature request it.

Roman Kuzmin notifications@github.com schrieb am So., 15. Apr. 2018, 20:10:

I am not suggesting this but one possible way is to add assembly references in the old fashioned way to projects if copy_local: false. Just in order to be able to set their Private to false. Yes, this will make projects less "clean" but avoiding redundant copies in several projects in a large solution may be important.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fsprojects/Paket/issues/3154#issuecomment-381426071, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNDuTtP0SZa2iqq4offh-VpnVzXw4ks5to40rgaJpZM4TVdTr .

nightroman commented 6 years ago

According to https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files ExcludeAssets with runtime should do the trick

    <PackageReference Include="Suave" Version="2.2.1">
      <ExcludeAssets>runtime</ExcludeAssets>
    </PackageReference>
nightroman commented 6 years ago

TIL Yes, this does the trick. Thus, one "workaround" is using native .net sdk packaging instead of paket...

forki commented 6 years ago

can you please try? But you have to update the Paket.restore.targets file

forki commented 6 years ago

urgs that didn't work

forki commented 6 years ago

deploying another version.

nightroman commented 6 years ago

Paket 5.156.4 is doing exactly what I expect. The output contains just my library output. Thank you very much!

atlemann commented 6 years ago

I just switched a large solution from old SDK to new SDK and ran into this problem. I have Paket version 5.177.1. I have copy_local: false for one single package in my paket.dependencies file and after switching to new SDK style project I get that .dll and all it's transient deps into the bin/net461 folder. Before they were left out as expected.

I have tried looking at the paket.Restore.targets file to see if there is anything I could try there to fix this, but I guess I need some pointers in the right direction.

I see that ExcludeAssets is set to runtime if "%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'" Where is this set to exclude and why is it different from the line above where it checks for == true?

atlemann commented 6 years ago

I'm building using VS2017 by the way