-
Notifications
You must be signed in to change notification settings - Fork 893
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
MsBuild, Native binaries and AppContext.BaseDirectory. #1498
Comments
This looks like the culprit:
When running under |
If someone agrees that this is the problem, I don't mind taking a stab at a PR to fix this. |
Interesting! Good detective work! For sure if you have a proposed fix I'd be very interested! 😀 |
@dazinator To be honest, the current state of the repo is a bit fragile because of the code generation stuff going on to get it to work on netstandard < 2.0. That's one of the reasons I've opened #1483. The intention when using this from .NET Core is that the native dependencies that are shipped in the native binaries package are directly referenced using the native assets capabilities directly. The fact that you see the lib folder showing up is an artifact of the current prerelease package being released before libgit2/libgit2sharp.nativebinaries#49 got merged. @ethomson We really do need to get an updated package out there that includes those changes. So, @dazinator, if you take a look at a netcoreapp2.0 project that references LibGit2Sharp and then publish it, you'll see the runtimes folder in there. That's where the native loading capabilities need the files to work correctly. |
In terms of a solution it looks.. tricky. This is relevent - i.e It was mentioned above that you can still get hold of So one option would be to change the compilation directive to something like this:
Note: this requires adding a new dependency for netstandard1.3:
I have just tried this, and all the unit tests still pass after this change. Another option would be to add a target for |
In other words, the lib folder is intentionally not relevant for .NET Core, and the next release of the package will have it stop needlessly copying files into the lib folder for those cases. |
@bording - sorry I think we started posting at the same time. Would you please enlighten me - if the |
@dazinator It's relying on .NET Core's built-in understanding of how to find and load native dependencies that are shipped in NuGet packages: The appropriate native library is referenced based on the RID. If you If you publish first, then you'll see the runtimes folder copied in the publish output. That combined with the deps.json file is enough for .NET Core to find and and load the correct file, once again based on the RID. |
I've got another open PR libgit2/libgit2sharp.nativebinaries#51 to further leverage this capability to be able to ship multiple files for different linux distros as well. |
My concern is that in this case Does the |
@dazinator It's my understanding that this should work for anything running in .NET Core, including the .NET Core version of MSBuild, but it's always possible there's some scenario there that isn't properly handled. |
These sort of loading complexities are what I had in mind when I was suggesting moving to a DotnetCliTool in GitTools/GitVersion#1269 (comment) |
I would love it to just work.. But I retain a healthy skepticism :-) I had previously packaged just my
Yep - it's a good suggestion - I just wasn't sure how to best go about bringing it into reality hence my probing comments! You are welcome to elaborate / contribute / spike up something over on gitversion repo. I will be happy to try out this new loading logic from an msbuild task as soon as its available please let me know! Please also consider my suggestions above in terms of tweaks to the code to potentially unblock us. I am happy to include the lib folder alongside the |
PR created. I verified the fix by including the modified |
I have closed my PR as it resolved it only on windows. Need a solution that works on all supported platforms. |
I'm going to go ahead and close this since using the lib folder and altering the path is not something that we'll be changing for .NET Core. |
I am working on the
GitVersion
msbuild task. It's distrubuted as a nuget package. The nuget package contains a build of the task assembly fornet461
and a build fornetstandard1.5
.The corresponding
libgit2sharp
assembly (which our task depends on) and the/lib
folder containing the native binaries thatlibgit2sharp
requires, lives alongside the task assembly, in the nuget package.When the
nuget
package is added to a project, and the project is built within VS - this uses the full desktop version of msbuild, and subsequently thenet461
assembly containing theGitVersion
build task is loaded from the nuget package, and the task runs successfully - LibGit2sharp all works smoothly.However when dropping to the command line and running
dotnet build
(I am using version 2.0.2 of the dotnet sdk) this runsmsbuild
onnetcoreapp
and thus thenetstandard1.5
task assembly from the nuget package is loaded. In this scenario the task msbuild fails and this is the stack trace:From the stack trace, it shows that the
libgit2sharp
assembly is being loaded from alongside the task assembly:C:\Users\Darrell\.nuget\packages\gitversiontask\0.0.1-alpha0003\build\netstandard1.5\LibGit2Sharp.dll
It also shows this:
Yet alongside the
libgit2sharp
assembly I have confirmed that there is alib
folder containing all of the native binaries - includinggit2-15e1193.dll
:Any ideas? @bording ?
If you need to replicate, you can do so by taking my PR branch of gitversion, calling
msbuild /t:Pack
on the msbuild task project to produce a nuget package containing libgit2sharp, then adding that nuget package to a sample .csproj file that has an initialised .git repository with atleast 1 commit, and building.The text was updated successfully, but these errors were encountered: