C
C#•5mo ago
Mr. Roach

The "ResolvePackageAssets" task failed unexpectedly.

Hello there, i am getting the error in the title and don't know how to resolve it, below the title it says "System.NullReferenceException: Object reference not set to an instance of an object". Alternatively I get: projects that use central package version management should not define the version All my nuget dependencies have a yellow triangle on them suddenly. It started after I tried to install templates of WPF libaries, I dont know if it was an error by me to have executed some dotnet commands within my opened solution/project. Maybe someone here can help? I also noticed that in bin/debug the next folder is now named "net8.0-windows7.0" instead of only "net8.0-windows" I executed the following commands within my project, maybe i shouldn't have done this there:
dotnet new install Keboo.Dotnet.Templates
dotnet pack --configuration Release -o .
dotnet new install . --force
dotnet new keboo.wpf
dotnet build
dotent test --no-build
dotnet publish --no-build
dotnet new install Keboo.Dotnet.Templates
dotnet pack --configuration Release -o .
dotnet new install . --force
dotnet new keboo.wpf
dotnet build
dotent test --no-build
dotnet publish --no-build
followed this here: https://github.com/Keboo/DotnetTemplates I already googled a bit, deleted my bin and obj folder, tried to switch my local branch but nothing seems to fix it til yet. I tried looking for backuped files in roaming/local folder but sadly vs didn't backuped the whole project/solution, only few files I deleted on purpose. Can I somehow setup vs to do several complete backups of my stuff?
4 Replies
Mr. Roach
Mr. RoachOP•5mo ago
So it seems I may have solved the issue, but I dont know exactly what the crucial part was. I tried repairing VS -> didnt helped I tried adding an entry to the NuGet Package Manager Package Sources pointing to the local NuGetPackages folder -> didn't helped I deleted all the random files inside my overall repos root folder that were created due to me executing commands like in the starting post there -> there were also nuget.config stuff - maybe that helped, Im unsure because i did that like parallel with the following: I tried running Add-BindingRedirect within the Package Manager Console, switched branches again, the branch switching messed up my .csproj file causing my project being unable to load with stuff like "<<<<<<<< UPDATED | =========" in it, removed the stuff the vs error popup pointed me towards when trying to load my project / added </xyz> we're closing parts seemed to be missing inside the .csproj file, loaded my project and got relieved realizing it seems to work again. Hopefully everything stays functional now. Other thing im unsure about now is wether or not "nuget" should get recognized as a command within vs cmd/powershell prompt - it doesn't at the moment and I forgot if i also fired nuget cmds inbetween the dotnet cmds mentioned in the start post. I also lost some nuget packages and extensions it seems - i have no clue where they went. I rather try to not execute commands at random places in the future.
Anton
Anton•5mo ago
well your error is because you're using central nuget package versions then you have to specify the versions of all packages in a Directory.Build.packages Msbuild file and not reference specific versions in any of the referenced projects nuget has a separate cli that you can install it's fine to execut commands just git commit before doing it so you see what actually changes <<<<< are merge conflicts you must have force committed unresolved merge conflicts the name of the bin folder by default reflects the target framework you should really learn how MSBuild works many arcane errors become pretty clear
Mr. Roach
Mr. RoachOP•5mo ago
thanks for your over all reply. I now saw on https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management that you would add <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> into the props file to have it centrally used packages. However I couldn't find such a Build.packages / props file and didn't saw that line somewhere else... Microsoft states I could create the file myself and set the value but im unsure now wether a file exists somewhere already and Im just not able to find it. Im sure I never played around with NuGet and shouldn't have switched something there accidentally... Oh yeah I noticed that I f'd something up when I used Git in panic that morning, all the code of the last 2 days went missing and I couldn't help it in the first moment. It was more like a coincedence that I stumpled upon the git stashed entries - luckily I was able to restore much of the code but not everything. Also the version of my .bin folder did randomly change around. Like it was just net8.0 or net8.0-windows most of the time if i remember correctly. Then somehow it was net80 | net80-windows | net8.0-windows.80 👀
Anton
Anton•5mo ago
read about Directory.Build.props and .targets you might have one of these in the parent directory
Want results from more Discord servers?
Add your server