Skip to content

Cannot use a custom $(PackageId).props or targets file in a razor class library project #61891

@nvmkpk

Description

@nvmkpk

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I add my own props file with the name $(PackageId).props following the instructions in https://learn.microsoft.com/en-us/nuget/concepts/msbuild-props-and-targets, the content of it does not get included in the nuget package. Even a targets file is not packaged and neither is an analyzer/source generator from another project gets included. All of these just work when the project is not a razor class library.

I did not try including mvc views/pages in the razor class library project.

Expected Behavior

The nuget package should contain the props file with content included in the one in the project. Any analyzer/source generator should also be included in the package.

Steps To Reproduce

  • Create a razor class library (without MVC support).
  • Add props file with some custom properties (in PropertyGroup element) to the project following the instructions in https://learn.microsoft.com/en-.us/nuget/concepts/msbuild-props-and-targets.
  • Run dotnet pack from CLI.
  • Examine the built nuget package file in an archive manager.
  • Observe that the build folder has the prop file but does not have the custom content added to the props file in the project.

Exceptions (if any)

None

.NET Version

9.0.203

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions