-
Notifications
You must be signed in to change notification settings - Fork 60
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
Runtimes folder is not copied during publish-process on .NET Framework #39
Comments
Okey, I managed to get a hacky fix for this in asp.net framework project by adding these lines at the bottom of the publish profile
But it is still nasty because one has to think about manually fixing package version while upgrading nuget dependency. |
Hmm, that's odd, it's in the build output, but not in publish. Hopefully we can find out a solution that goes into the Nuget package so we don't have to make any changes to the csproj of the consuming project. I don't know what that fix is though, happy to accept suggestions/PRs. |
It s not realy a fix, it is an ugly hack appended inside the .pubxml file of our ASP.NET project which copies the required files into the publish folder, because otherwise we would forget to publish them manually every now and then ;) I'm hoping to give you a working minimum example tomorrow |
Created a minimal ASP.NET API and installed Haukcode.WkHtmlToPdfDotNET nuget package and finally added two visual studio publish profiles (one with above additions, one without) First I tried to get something working like this inside csproj file, but as I am not that familiar with legacy framework build techniques I had no success. But maybe this can be a starting point for a real fix... |
Thanks @mrblumi, I'm not sure what the real fix is either, we may have to leave this open for now to see if somebody else can come up with a fix. The best way would obviously be a fix in the source Nuget package. |
I 100% agree with you. Adding some custom stuff to either csproj or pubxml files is alwas error prone... |
I'm not an expert in this by any means, but it looks like there are a couple of options for getting the nuget working properly with .net framework.
|
I've got this working on a local nuget feed OK. Sent a pull request for you to review. |
@mrblumi and @horizondave Can you please test with the latest Nuget package, v1.5.59 and see if it works now and report back here? Thanks! |
I can test this tomorrow afternoon :) |
Version 1.5.59 works fine for me, many thanks :) |
Works for new csproj based .NET Framework based projects (tested with dotnet publish) . Does not work for old style ASP.NET Framework projects... |
Not sure what the fix is for that, or if it's even possible. |
Well, this definitively fixes the bug i described in the initial statement of this issue. But old ASP projects are still broken and one has to mess around with the build config to get this working. This was the only way i found to get the native dlls published into the correct location... |
We may have to just say that the old style csproj isn't supported. Unless someone can figure out a solution and post a PR. I think there may be some examples like SQLite that also has native libraries that could be looked into for ideas. |
Not sure if my problem is the same issue or not (#61, I closed it when I THOUGHT I had fixed it, then found this issue), but I'm hitting a similar issue/symptom. When publishing ( Steps to reproduce
|
This looks promising, though the Q/A is a few years old. Not sure if it's changed with the refactoring made to newer versions of .NET like, 5 and 6. |
@nickalbrecht Hmm, no, there shouldn't be a file in the root, don't know where that's coming from. It may be some of the attempts to solve this issue, we do have some Nuget-related commits. |
@nickalbrecht I think the latest version has this resolved. I've also added some test projects in the main solution to test the various platforms. It works for me in .NET 4.6.1, .NET 4.7.1, .NET 4.8, .NET Core 3.1, .NET 5, .NET 6 and also .NET 4.7.1 in the old csproj format. |
I just tried it using the same repro steps I had above, it grabbed Would it be better to allow the I don't know how this affects the full .NET Framework, as I've only been testing this with .NET 6 however (I'm guessing my observations would be the same with other versions of .NET Core SDK). |
If it helps, when I used to use the DinkHtmlToPdf package (granted, this is on windows), I didn't load the wkhtmltox.dll directly via DllImport, so I didn't have to hardcode the path. Instead, I loaded it using this internal static class NativeMethods
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "LoadLibrary")]
internal static extern IntPtr LoadLibrary(string libname);
} var ptr = NativeMethods.LoadLibrary(path);
if (ptr == IntPtr.Zero)
{
throw new Exception($"Error loading {path} (ErrorCode: {Marshal.GetLastWin32Error()})");
} Which would allow things like checking |
The issue is/was that NativeMethods.LoadLibrary is not available in .NET Core (now I think it's been added in .NET Core 3.0, so it may be an option now, but I forked Dink when it was .NET Core 2.0 and it wasn't available). And we have to make sure all this works in Windows, Mac and Linux/docker. But I'm open to rewrite it, but at the moment I don't have the time to spend to rewrite that part, but I'm happy to accept a PR, hint hint :) |
If there is a way to exclude the runtimes folder when doing publish that would be good, but for the portable publish the recommended way (going off memory here) is to have the runtimes folder for native libraries. I think I had the initial load code in the ModuleFactory to cover that scenario (when the dll is in the root), but at least running it from VS it seems to work for all the different platforms right now. |
I've tested the latest version with all the various client projects and they all seem to work. I'm closing this issue, feel free to re-open if anything related is still broken. |
Publishing .NET Framework (4.8) Projects does not copy runtimes directory to target location.
The problem occures with new csproj-format (i.e. console app) as well as with old csproj-format (i.e. asp.net application)...
Steps to reproduce for first example:
dotnet new console -n Test -o ./
dotnet add package Haukcode.WkHtmlToPdfDotNet --version 1.5.8
dotnet publish --configuration=Release
I have not tried to get a minimum example for legacy csproj format since I think it s the same problem with both formats...
The text was updated successfully, but these errors were encountered: