-
Notifications
You must be signed in to change notification settings - Fork 890
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
Change NuGet package native dlls deployment mode #425
Conversation
@davidebbo Have you tried to convert SqlCE NuGet package to this new format (cf. NuGet issue #109)? |
I don't own that package these days. Maybe @jeffhandley? |
FYI, That tutorial is geared towards native (C/C++) packaging. For managed projects there's not a lot of benefit for moving to the CoApp tools (well, not yet) ... as we get the native scenarios completely nailed with the tool, I'll start adding more support for managed projects too. |
From AndrewNurse, in Nuget Jabbr room: "Yeah, the NuGet 2.5 changes should definitely make that easier. You'd basically want to have a "libgit2sharp.targets" file in the "build/" folder (or if it is framework independent, just "build/"). We'll automatically add an <Import Project="path/to/libgit2sharp.targets" Condition="Exists('path/to/libgit2sharp.targets') /> node to the project file of every project that installs that package" |
Currently, installing the NuGet package triggers the execution of the
Topics to cover:
|
Hand made workaround:
<Import Project="..\packages\LibGit2Sharp.0.11.0.0\build\libgit2sharp.targets" Condition="Exists('..\packages\LibGit2Sharp.0.11.0.0\build\libgit2sharp.targets')" />
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="AfterBuild">
<CreateItem Include="$(MSBuildThisFileDirectory)..\NativeBinaries\**\*.*">
<Output TaskParameter="Include" ItemName="NativeBinaries" />
</CreateItem>
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(OutputPath)NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
</Project>
|
Building the package generates the following message
Question: |
Fix #425 Consumer now require NuGet 2.5 to update/install LibGit2Sharp packages.
Ensure that this is compatible is VS Publish mechanism (cf. projectkudu/kudu#943) |
For reference: Number of LibGit2Sharp downloads per client NuGet version Seems like 2.7 is now mostly used, so it might be "safe" to merge this PR without bothering too many users. @davidebbo Do you know if dealing with NativeBinaries this way would be kudu compliant? |
It should. You can test it without Kudu by following these steps. If you see the native binaries in the output folder, then it will almost certainly work in Kudu as well. |
Fix #425 Consumer now require NuGet 2.7 to update/install LibGit2Sharp packages.
@davidebbo I've rebased this PR and generated a fake v0.15.1 NuGet package based on it. I've created a plain ASP.Net MVC web application and referenced this fake package from a local feed. Building the project copies the Could you please help me troubleshoot where I messed up, please? The fake package's available for download here. Below the Publish output
|
I tried it, but the package doesn't have any Tools folder. Try installing
Maybe starting with these scripts and modifying them with the relevant list of binaries is the simplest approach. |
Hmmm, though it seems the sucky part with that approach is that users would end up having to commit all those binaries in @jeffhand @howarddierking is there better guidance for writing packages that need native binaries? I searched for it and found this issue, which ironically I had filed myself 3 years ago! :) |
@davidebbo Actually, that was the very purpose of this PR: to remove the powershell scripts 😉 @fearthecowboy Can you think of a NuGet tweak that would allow us to not rely on powershell scripts to deploy the native binaries while still being Publish compliant? |
Creating a .targets file is the best way to handle this (without having a .ps1 file). Files that are not expected to be referenced (but rather, copied at build time) should be in the |
@fearthecowboy do you know if there is a sample package that does this correctly today? I thought Microsoft.SqlServer.Compact was the 'standard' for dealing with native binaries, but it's using a .ps1 file. |
I don't know any example off the top of my head. I don't know that anyone sat down and cranked one out. What are the requirements for being "Publish compliant?" Is there an msbuild script being run at that point? Shouldn't it just boil down to adding some items to an already existing itemgroup? |
At a high level, being 'publish compliant' simply mean that when you deploy (e.g. to file system or via WebDeploy), the native binaries end up being deployed in the correct location in bin. And this should be done without having to commit the binaries into the bin folder of the app. |
Ah, and the 'deploy' is handled via a Target in the msbuild script I assume? (I've been hiding away from building webapps for the last few years :D ) So if a given package had the extra (native) items in the right item group, when the consuming project was 'deployed' the items would get copied to the appropriate location. Sounds easy enough. Lemme see if I can find some time this week to play with a web project that deploys that way and build you a proof of concept package. |
Yes, that's correct, it uses some magic target files. e.g. look under |
@davidebbo, @nulltoken, @fearthecowboy. |
Superseded by #821. |
Latest NuGet version (2.5) introduces a feature that should help the deployment of native dlls: Automatic import of msbuild targets and propos files.
This could help removing the
nuget.package/Tools/*.ps1
scripts by adding a.targets
file in the/build/<framework>
package folder, which can contain tags that have items that are set to copy to output.A sample is provided below:
Some additional low-level information on the topic: How to Build a Package
Note: We may also add some minimum NuGet Client version requirement, but it is unclear how a NuGet client < 2.5 will react to this directive and to the additional
.targets
file