2

I have a Visual Studio web app with 2 projects in the solution: the main C# app and another C# class library I wrote. The class library references some nuget packages.

When I build & run my solution I get a reference problem because the main app doesn't have the nuget packages. The only way I can get it to run is to add the nuget packages again to the main app, even though it doesn't actually use them.

Is there a way to get VS to automatically include the relevant packages in the final build?

enter image description here

Hank
  • 8,289
  • 12
  • 47
  • 57

1 Answers1

0

If your class library project is net standard and main project is non-sdk net framework project, you should add this under the csproj file of the main app:

<PropertyGroup>
        
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    
</PropertyGroup>

This issue might be the same as yours.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41