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

Reference NuGet dependencies installed via the #addin directive #787

Closed
patriksvensson opened this issue Mar 25, 2016 · 19 comments
Closed
Assignees
Milestone

Comments

@patriksvensson
Copy link
Member

When installing a nuget package via the #addin directive, the package's dependencies should also be referenced.

@daveaglick
Copy link
Member

Is the intent to recursively descend the dependency tree, or just reference the direct dependencies of the addin?

@devlead
Copy link
Member

devlead commented Apr 20, 2016

Well intent would be to reference anything needed by the addin, so likely yes. Basically equivalent of a nuget install.

@daveaglick
Copy link
Member

I'll be watching the progress on this one with interest as I haven't quite figured out the best way to do this myself.

In Wyam I let NuGet fulfil all of it's requested packages, including transitive dependencies, and then just walk the entire packages collection and add references for every assembly I find. I haven't upgraded to the v3 libraries yet, which I understand are very different, so I'm sure all my code will break when I do.

@devlead
Copy link
Member

devlead commented Apr 20, 2016

@daveaglick V3 is different, nuget core is depreciated and replaced by a number of undocumented assemblies.

There's an issue for ET it though NuGet/Home#2243

@daveaglick
Copy link
Member

Yeah, I've been stalling and putting it off. "Undocumented assemblies" doesn't sound like my idea of a fun evening of hacking.

@devlead
Copy link
Member

devlead commented Apr 20, 2016

NuGet V3 despite of being "RTM" doesn't feel fully baked.
It's a bit too much code to effortless browse without docs, sample or even a spec at hand.
Just a blog post with a simple minimal install package sample would be a good quick start to grasp what's needed.

@devlead devlead modified the milestones: v0.21.0, v0.19.0, v0.22.0 Mar 22, 2017
@devlead
Copy link
Member

devlead commented Sep 24, 2017

@mholo65 this is avail opt in now right?

@bjorkstromm
Copy link
Member

@devlead yeah, but it doesn take target framework into account. I've another issue for that here #1801

@devlead
Copy link
Member

devlead commented Sep 26, 2017

@mholo65 so is this a matter of documentation or does something need to be done to close this issue?

bjorkstromm added a commit to bjorkstromm/cake that referenced this issue Sep 28, 2017
- Fixes cake-build#787
- Don't share project. Only share Gather Cache.
- Use DependencyBehavior.Ignore by default. Only set Lowest if load dependencies is set. This way we wont install unneccessary packages and cache gathering is faster.
devlead pushed a commit to bjorkstromm/cake that referenced this issue Sep 30, 2017
- Fixes cake-build#787
- Don't share project. Only share Gather Cache.
- Use DependencyBehavior.Ignore by default. Only set Lowest if load dependencies is set. This way we wont install unneccessary packages and cache gathering is faster.
@nlowe
Copy link

nlowe commented Oct 18, 2017

So if I'm understanding #1848 correctly, we need to use the in-process nuget client if we want support for installing addon dependencies?

@devlead
Copy link
Member

devlead commented Oct 18, 2017

@nlowe Correct.

@nlowe
Copy link

nlowe commented Oct 18, 2017

@devlead I enabled the in-process nuget client and added &loaddependencies=true to the addin I'm trying to load. A folder is created for the dependencies and they are downloaded, but it seems they're not referenced. When I turn on assembly binding logging, I see that the addin folder isn't even searched:

=== Pre-bind state information ===
LOG: DisplayName = My.Dependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942
 (Fully-specified)
LOG: Appbase = file:///C:/Users/nlowe/Projects/MyProject/tools/Cake/
LOG: Initial PrivatePath = NULL
Calling assembly : Cake.MyAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\nlowe\Projects\MyProject\tools\Cake\Cake.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: My.Dependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Cake/My.Dependency.DLL.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Cake/My.Dependency/My.Dependency.DLL.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Cake/My.Dependency.EXE.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Cake/My.Dependency/My.Dependency.EXE.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Addins/Cake.MyAddin.1.1.0/lib/net46/My.Dependency.DLL.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Addins/Cake.MyAddin.1.1.0/lib/net46/My.Dependency/My.Dependency.DLL.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Addins/Cake.MyAddin.1.1.0/lib/net46/My.Dependency.EXE.
LOG: Attempting download of new URL file:///C:/Users/nlowe/Projects/MyProject/tools/Addins/Cake.MyAddin.1.1.0/lib/net46/My.Dependency/My.Dependency.EXE.

If this is not the expected behavior I can open a new issue.

@bjorkstromm
Copy link
Member

@nlowe, no this is not expected behaviour. Could you raise an issue including minimal steps to reproduce?

@jnm2
Copy link
Contributor

jnm2 commented Nov 4, 2017

I'm trying to create an addin where you don't have to do anything special to an OOB cake script. Rather than bundling dependencies inside the nupkg, I'd much rather use nuspec dependencies. I see the netstandard1.6 dependencies are installed in the correct addins folder but they are not referenced when running Cake under CoreCLR, causing the addin to fail to load. Am I doing something wrong, or can this state of affairs be addressed?

@devlead
Copy link
Member

devlead commented Nov 4, 2017

@jnm2 Have you opted for using in proc and load dependencies?

As per documented at:
https://cakebuild.net/docs/fundamentals/default-configuration-values

@jnm2
Copy link
Contributor

jnm2 commented Nov 4, 2017

The problem is that this is an addin. It should work out of the box and without constraining folks' build script setups.

@devlead
Copy link
Member

devlead commented Nov 4, 2017

If opt in sort it now, then it'll work out of the box when we make it default in the future.

@jnm2
Copy link
Contributor

jnm2 commented Nov 4, 2017

As soon as I add --nuget_useinprocessclient=true, it stops respecting the nuget.config. I added --nuget_source= but then it didn't download anything from nuget.org. So I can't even test that. I'll always need it to respect multiple package sources in nuget.config.

@jnm2
Copy link
Contributor

jnm2 commented Nov 4, 2017

Oh no, I just hit a dead end on the other side! It doesn't look like it's possible to include System.Data.SqlClient.dll in the nupkg– it doesn't get copied to build output but rather listed in a .deps.json which I guess I'd have to parse and resolve? Plus it's not really the right solution since another addin may load a conflicting version of the System.Data.SqlClient package.

Looks like the only way for this addin to succeed on .NET Core is for Cake to automatically reference its dependencies without requiring the --nuget_useinprocessclient=true parameter.

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

No branches or pull requests

7 participants