How to edit a nuget package in Xamarin Studio for Mac?

I'm not sure this is the right question for this forum, but here goes.

Is there a way to get into a Nuget package and edit the files in Xamarin Studio for the mac? I'm trying to fix/update some things in an open source package, and I'd like to find the easiest route to do that to test it in my project.

Posts

  • mattwardmattward Matt Ward GBMember Xamurai

    If all you have is the .nupkg file and you want to edit what it contains you can rename it to be .zip and extract the contents. It is just a .zip file with the file extension changed. Then make your changes, zip it back up again, and change the file extension back to .nupkg.

    If you have the original package's .nuspec file you could use NuGet.exe to do the packaging again: NuGet pack Your.nuspec although the layout of the .zip file can be different to what the .nuspec file needs.

    If you are testing the install process I would put the custom .nupkg into a separate directory and create a package source just for that so you make sure you are installing the correct package.

  • noahdavidsonnoahdavidson noah davidson USMember ✭✭

    Following your steps @mattward for the .nupkg file, the contents of the .nupkg file turned .zip and extracted are as shown in the attached png.

    which of these files am I supposed to be able to change? I'm looking to edit a viewcontroller from the packet and cannot seem to able to find the actual code files themselves.

  • mattwardmattward Matt Ward GBMember Xamurai

    The extracted NuGet package does not contain any files in your screenshot. It will contain assemblies in the lib directory which I am guessing contain your ViewController.

  • noahdavidsonnoahdavidson noah davidson USMember ✭✭
    edited September 30

    Im not entirely sure what you mean @mattward . The nuget package contains both a lib file and a .nupkg. In your instructions you said to reformat the .nupkg file to a .zip, but its actually the lib file that contains the correct files?

    Do I make the nuget package a zip and then extract its contencts? Sorry for not following. The image contains the contents of the nuget package.

  • mattwardmattward Matt Ward GBMember Xamurai

    The NuGet package in your screenshot only contains a lib directory. This directory will hold assemblies and not the individual C# files. If the NuGet package had a Content directory then it would have files that would be added to the project. Since the NuGet package only contains assemblies you will not be able to replace a ViewController .cs file since it does not exist.

  • mattwardmattward Matt Ward GBMember Xamurai

    For the Chafu NuGet package it may be easier to just compile it from source with your changes and use that assembly instead of the NuGet package:

    https://github.com/BruelAndKjaer/Chafu

  • noahdavidsonnoahdavidson noah davidson USMember ✭✭

    Thanks! That worked great!!

Sign In or Register to comment.