CodexBloom - Programming Q&A Platform

Visual Studio 2022 - how to to Resolve Assembly Reference for a Custom NuGet Package in .NET 5 Project

👀 Views: 37 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-05
visual-studio nuget dotnet C#

I'm wondering if anyone has experience with I've tried everything I can think of but I need some guidance on This might be a silly question, but I'm experiencing an scenario where Visual Studio 2022 (v17.0) is unable to resolve a custom NuGet package I published to our private NuGet server. The package is correctly referenced in my .NET 5 project, but I'm getting the following behavior when trying to build: ``` behavior CS0012: The type 'MyCustomClass' is defined in an assembly that is not referenced. You must add a reference to assembly 'MyCustomAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. ``` I've tried several approaches to solve this. First, I ensured the package is successfully restored by running `dotnet restore` and confirmed it's listed in the `obj/project.assets.json` file. The references in my `.csproj` file look like this: ```xml <ItemGroup> <PackageReference Include="MyCustomPackage" Version="1.0.0" /> </ItemGroup> ``` I also checked that the custom package contains the appropriate assemblies and has the correct metadata by inspecting the `.nupkg` file. Furthermore, I cleared the NuGet cache with `dotnet nuget locals all --clear` and even recreated the project file from scratch to ensure no hidden configuration issues. Despite all this, the behavior continues. Other projects consuming the same NuGet package work without issues, so it seems isolated to this specific project. What else could be causing this assembly resolution question? Any help would be greatly appreciated! My development environment is macOS. Any help would be greatly appreciated! Is there a simpler solution I'm overlooking? The project is a mobile app built with C#.