Error Downloading Driver from Manager (MacOS Only)
I can load the Aerospike driver as an LPX6 file successfully (everything downloads and runs correctly) on the Mac. When I try to load it via NuGet/Manager, I get the below error:
Warning: No compatible assemblies found in package 'Aerospike.Database.LINQPadDriver'.
There is nothing in the LINQPad log file.
Has anyone experienced this issue and any hints on what I need to do on the Mac to get this working?
BTW, everything work correctly under windows...
Answers
-
Sorry - this is something I failed to mention in the docs. Before creating the NuGet package, you will need to remove the
-windowssuffix from any folders underlib. So lib/net8.0-windows should be renamed to lib/net8.0.The reason is that Microsoft (quite reasonably) assume that WPF is a windows-only technology. However, with XPF, this is no longer true.
This applies only to the driver, which contains WPF code, not to any dependent packages which should be deployed as normal.
-
Thanks Joe for information!
But you need to rename more than the "lib" folder. Any of the folder that has a reference to "netX.0-windows" needs to be renamed (e.g., contentFiles/any/net8.0-windows => contentFiles/any/net8.0).
I also had to edit the metadata to reflect the renamed folders plus "dependencies/target framework" had to be renamed.
Once completed, I was able to load the package from the manager. If you missed one of these changes, the package will fail to load, content missing, and/or the dependency packages did not load.
I manually performed this with the NuGet Package Explorer. I just started to look into how to do this during my build.
Do you have any suggestions on how to do this from my build pipeline?
-
I'm pretty sure you don't need the
<contentFiles>section in your .nuspec file. If you omit it, the content files will be picked up by convention. -
I've run into a similar problem with my package. I did the thing from the documentation (built package where dlls are inside the lib/net6.0 folder) but it didn't work.
There's a problem with dependencies, after building the package I could see this in .nuspec:
<group targetFramework="net6.0-windows7.0"> <dependency id="LINQPad.Reference" version="1.3.1" exclude="Build,Analyzers" /> <dependency id="MongoDB.Driver" version="3.2.1" exclude="Build,Analyzers" /> </group> <frameworkReferences> <group targetFramework="net6.0-windows7.0"> <frameworkReference name="Microsoft.WindowsDesktop.App.WPF" /> </group> </frameworkReferences>When trying to use the driver it fails with an error like this:
Could not load file or assembly 'MongoDB.Driver, Version=3.2.1.0, Culture=neutral, PublicKeyToken=94992a530f44e321'. The system cannot find the file specified.
So, in order to run properly under MacOs the .nuspec file has to look like this:
<group targetFramework="net6.0"> <dependency id="LINQPad.Reference" version="1.3.1" exclude="Build,Analyzers" /> <dependency id="MongoDB.Driver" version="3.2.1" exclude="Build,Analyzers" /> </group> <frameworkReferences> <group targetFramework="net6.0-windows7.0"> <frameworkReference name="Microsoft.WindowsDesktop.App.WPF" /> </group> </frameworkReferences>The only way I've found to do that (which doesn't involve manually editing the resulting .nupkg file). Is having a hardcoded .nuspec file in my repo instead of generating it on build.
Not sure if it's allowed to post links here, you can find my solution on GitHub under the name "Linq2MongoDB.LINQPadDriver".
@JoeAlbahari is this the correct way to create cross-platform packages? Can you add this part about dependencies to the docs, so others wouldn't have to waste time to figure this out?
Also the sample project provided with the docs seems to be outdated, there's no MacOs support in it and it uses old versions of .NET. Maybe you can update when you have the time?
