0

I have created a Xamarin.iOS binding project by adding UnityFramework.framework as Native References. When I build this binding project it generstes a .dll file. Now I want to generate a Nuget package and for my actual project I need to add this nuget package instead of the DLL. I did read this but not clear how to apply it for my existing binding project. Please help me on how to create a nuget package from my biding project. Thank you very much.

Randi
  • 639
  • 2
  • 6
  • 23

1 Answers1

0

You can do that using a nuspec file like so:

%NUGET_EXE_PATH% pack YourApplication.nuspec -version 1.0.0.0 -Properties Configuration=Release

The nuspec file looks something like this:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
        <id>YourApplicationName</id>
        <version>1.0.0.0</version>
        <title>Title</title>
        <authors>Author</authors>
        <owners/>
        <licenseUrl>https://yoururl.com</licenseUrl>
        <projectUrl>https://yoururl.com</projectUrl>
        <iconUrl>file://YourProgram_Icon.ico</iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Your description</description>
        <releaseNotes/>
        <copyright>Your copyright notice</copyright>
        <tags/>
        <dependencies>
            <dependency id=""/>
        </dependencies>
        <summary/>
    </metadata>
    <files>
        <file src="..\InstallDir\YourApplication.exe" target="YourApplication.exe"/>
        <file src="..\InstallDir\Library1.dll" target="Library1.dll"/>
        <file src="..\InstallDir\library2.dll" target="Library2.dll"/>
    </files>
</package>
Paul Sinnema
  • 2,534
  • 2
  • 20
  • 33
  • what should be given for src and target under files? – Randi Mar 23 '22 at 09:47
  • Changed the post. Forgot to change the target to `YourApplication.exe`. In target you declare where the file is stored in the directory structure of the final nuget package. A nuget package file is in essence a zip file. Change the extension from `.nuget` to `.zip` and you can unzip it. – Paul Sinnema Mar 23 '22 at 09:50
  • In my case I don't have any .exe file only the .dll which is generated when I build the binding project. – Randi Mar 23 '22 at 10:50
  • Nuget only creates the package. How you deploy that is a different matter. In our organization all packages are deployed using Octopus. Octopus unpacks it for us and puts it in a place where it can run. You do not need to add an .exe if that is not needed. – Paul Sinnema Mar 23 '22 at 10:54
  • Another question,, Should I add debug version or release version of DLL to the nuget package? I added the release version and it is very small and my debug version DLL is like 21MB – Randi Mar 29 '22 at 06:36
  • Are you going to use this for production in the end? If so you should use the release version. Are you developing for an Enterprise or just private? The release version has code optimization enabled and no way to debug. You will than have to rely on logging for your bug assessments. – Paul Sinnema Mar 29 '22 at 18:08
  • Yes I am going to use this in production at the end – Randi Mar 30 '22 at 04:19
  • I created the nuget package including my release version of the DLL. Then I installed it into my xamarin.iOS project. But I cannot access the nuget package within my code. Cannot import it using statement in my class. Do you know any reason for this? – Randi Mar 31 '22 at 06:46
  • I don't think that is the way to deploy to iOS. Look in the documentation on how to do that: https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/ – Paul Sinnema Mar 31 '22 at 10:19
  • I am trying to run the nuget package included project on my own device. Not creating a build to distributeion. – Randi Mar 31 '22 at 11:10
  • As I said before. I don't think you can use a Nuget package for that. You need to deploy as described in the article. – Paul Sinnema Mar 31 '22 at 11:13
  • I have already added nuget package as references to my old projects. But those packages are not created by my self – Randi Mar 31 '22 at 11:20
  • You don't really add a reference to a Nuget package in your project but a reference to the library/libraries in the package. The Nuget package is unpacked and stored in the Packages directory inside your solution directory. You can simply add a reference to your own library in your project. During deployment this library will be deployed alongside your application. – Paul Sinnema Mar 31 '22 at 11:26
  • Thanks for the explanation. My package folder doesn't have unpacked and stored nuget package folder.and project.assets.json only has this for my nuget package "ABC.SDK/1.0.0": { "type": "package" }, – Randi Apr 01 '22 at 11:32