asp.net-core-mvcnuget.net-8.0nuget-package-explorer

ASP.NET Core 8.0 library with MVC views and controllers adds unwanted PackageReference options in the ASP.NET Core projects that reference it


I have an ASP.NET Core 8.0 library with MVC views and controllers. It was converted from .NET Framework. In general it is working as expected. However, when I add it as a nuget reference to other ASP.NET Core 8.0 programs, it doesn't add like all the other nuget packages I've created. Instead, inside of its PackageReference in the project file, I have these children entries:

<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

So it looks like this:

<PackageReference Include="MyDll" Version="2.0.57">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

And both the children it adds are causing issues for me. If I manually remove them they come back after I upgrade the nuget package (which is happening a lot right now as I work through the upgrade for several client applications).

In the library project I believe I've followed Microsoft's instructions for how to create it: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-8.0&tabs=visual-studio

I have tried building the library with every project SDK I can think of, including (though I believe Web is the one I actually want):

  <Project Sdk="Microsoft.NET.Sdk">
  <Project Sdk="Microsoft.NET.Sdk.Razor">
  <Project Sdk="Microsoft.NET.Sdk.Web">

I have tried it with and without the output type specified (required for Web):

  <OutputType>Library</OutputType>

I have AddRazorSupportForMvc set to true:

  <AddRazorSupportForMvc>true</AddRazorSupportForMvc>

I have the nuget package setup the same as my other libraries, and they're working as expected. I use NugetPackageExplorer to build them. The nugets are internal-only, just shared across our company, so we can change them as needed.

I'm not sure what else to try. I'm not even sure where the problem is and I can't seem to find anyone else having the same issue (nuget, .NET, etc.). Any ideas or suggestions? Does anyone know what I'm doing wrong?


Solution

  • I spent too much time focusing on the .NET upgrade and the project file, and not enough time comparing the nuget packages. Development Dependency was selected and that was causing my problems. I un-checked it and my problems went away (along with these extra options in the project file).

    enter image description here