dotnet / dotnet/aspnetcore

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

Open
#61,891 0 comments 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [x] 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.