How to update/patch third party subprojects in a Nuget environment?
Hey!
Following issue:
I need to patch some of Avalonias packages (.Skia Nuget package as well as .Base (code inside), .Controls(is a dependency), .Vulkan (code inside)).
Cloned the Avalonia repo (Version 11.3.7), patched with needed changes and then created local nuget packages via cmd using "dotnet pack proj.csproj -c Release -p:PackageVersion=11.3.7.1)
My own project has nuget package of Avalonia (11.3.7)+its dependencies (.Base, .Controls, .Vulkan...) plus .Skia)
I now need to replace .Skia (seems to work by adding my LocalFeeds folder as Nuget source, removing the original .Skia and adding it as PackageReference to my cs.proj)
So far so good. Issue: Skia needs .Base and .Vulkan as dependencies, and I needed to patch these projects as well, so I created packages locally for them as well.
The global nuget.config looks like this:
after doing this, deleting my projects bin and obj plus "dotnet nuget all locals --clear" and "dotnet restore --no-cache" afterwards, intellisense indeed picked up on my patched versions and I could use them inside the code.
BUT when building, the old Avalonia dependencies get used, leading to exceptions (MethodNotFound exception). I checked and found that it always looks for the nuget.org .dlls.
So then I created a Directory.Build.props file in my project root and added the specific version number to the patched packages (11.3.7.1) in hopes that changes anything, but no success their either.
Would someone please be so kind as to explain which steps I missed in order for my project to pick up on the patched .dlls? Thanks alot!
PS: Im not able to pack Avalonia itself and the Avalonia Discussion wasnt answered in a week (might be holidays)
2 Replies
Do you have Package Source Mapping?
Example taken from https://learn.microsoft.com/en-us/nuget/consume-packages/package-source-mapping
Package Source Mapping
Describes package source mapping functionality and how to onboard
Hey, Thats unfortunately not trivially possible because the packages I actually need to patch also require others as dependencies. If I use package source mapping, all of these dependencies need to reside inside my local feeds folder as well - so I would need to pack all of them. At least thats what it seemed when I tried it out
Answer: You need to read the very last line at the bottom of the Avalonia build description. I never scrolled until the very end, thats why I overlooked it ':D
https://github.com/AvaloniaUI/Avalonia/blob/master/docs/nuget.md <- how to build Avalonia nuget packages.
Beware: Depending on at which platform you are at, you might need to install a couple of dependencies that are not mentioned there.
For me, I needed to install the java JDK 21.0, Android SDK+Xamarin (via Visual studio installer possible on windows), Nuke, Node,.js, and needed to add some stuff inside Avalonia/Andriod/Avalonia.Android/ after a dotnet restore (what needs to be done can be found here: https://learn.microsoft.com/en-us/dotnet/android/getting-started/installation/dependencies and you need to match the specific net8.0-AndroidVERSION number, which can be found inside Avalonia.Android\obj\project.assets.json