How to include DLL file dependencies in package
# help-with-umbraco
a
I am working on a package which depends on DLLs which are not available on NuGet. I have tried putting the DLLs in the App_Plugins folder for the package however they are not being copied by the .targets file. I've also tried using xcopy with no luck. Any pointers on how to do this, as the code requires a string path to the dll, so that rules out adding as an embedded resource and using a Stream
s
We used to include them like this, this is from the nuspec file:
Copy code
xml
    <files>
        <!-- libs -->
        <file src="$BuildTmp$\WebApp\bin\Umbraco.Core.dll" target="lib\net472\Umbraco.Core.dll" />

        <!-- docs -->
        <file src="$BuildTmp$\WebApp\bin\Umbraco.Core.xml" target="lib\net472\Umbraco.Core.xml" />

        <!-- symbols -->
        <file src="$BuildTmp$\bin\Umbraco.Core.pdb" target="lib\net472\Umbraco.Core.pdb" />
    </files>
Guess yours need to go in the target
bin
- not sure.
a
Hmmm I'm not using a nuspec file as the package is being created in Visual Studio
s
Maybe you can include it as a reference in VS then it should get copied. Must be something you can do in the csproj file.
Is it some kind of old dll that was never put up on NuGet or what?
a
I've tried to do that, it doesn't let you add a DLL as a reference, it says it's unsupported 😅😔
s
a
It's for Ghostscript (PDF library)
s
Probably need to edit your csproj file manually
Ah I see. You might have to have both the Win 32/64 and the Linux dll somehow.. gnarly.
a
Hmmm I'll see whether your link works... Been a real headache so far!
s
Note that one of the comments says: > $(TargetFramework) does not working for VS2022. It just place my external dll outside the lib folder. I had to explicitly put lib\net6.0. And if my project multitarget, I need to have another similar block of ... with the other target framework sepcified
a
That's fine as I need them in a specific path anyway
a
@AaronSadlerUK wouldn't this suffice? It seems be from the authors of Ghostscript https://www.nuget.org/packages/Ghostscript.NET
a
They do not include the required DLLs in that package annoyingly. I was able to make use of the lib folder, this copies the DLLs out when you install the NuGet package. So a little more testing, but it looks by adding a lib directory in to a class library, and then adding the Content tags as per @Sebastiaan linked post it solves the issue
a
I'm not sure how much of this is permitted with their dual licensing. So might be worth looking into that before releasing anything. Might also be a good first step to ask them if they can release it on NuGet - this would IMO be the best solution. Anyways - based on your initial description, am I correct to assume that you're creating a package with some logic in your own that then also will contain this DLL? If you are permitted to release the DLL on NuGet, consider creating a small package that only contains the DLL (eg
YourCompany.Ghostscript.Blah
), and then add that as a dependency to your own package. That allows for greater re-use, and others can use your
YourCompany.Ghostscript.Blah
package as well should they have similar needs.
12 Views