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

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

Closed
nightroman opened this issue Apr 15, 2018 · 12 comments
Closed

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

nightroman opened this issue Apr 15, 2018 · 12 comments

Comments

@nightroman
Copy link

nightroman commented Apr 15, 2018

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

  • 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

<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
Copy link
Member

forki commented Apr 15, 2018 via email

@nightroman
Copy link
Author

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
Copy link
Author

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
Copy link
Member

forki commented Apr 16, 2018 via email

@nightroman
Copy link
Author

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
Copy link
Author

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

@forki forki closed this as completed in 9edf7af Apr 17, 2018
@forki
Copy link
Member

forki commented Apr 17, 2018

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

@forki
Copy link
Member

forki commented Apr 17, 2018

urgs that didn't work

@forki
Copy link
Member

forki commented Apr 17, 2018

deploying another version.

@nightroman
Copy link
Author

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

@atlemann
Copy link
Contributor

atlemann commented Sep 7, 2018

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
Copy link
Contributor

atlemann commented Sep 7, 2018

I'm building using VS2017 by the way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants