dotnet / dotnet/aspnetcore

Templates create compile errors in solutions with Central Package Management (CPM)

Open
#48,569 12 comments 3 reactions 0 assignees View on GitHub
area-mvc enhancement feature-templates
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

The project templates always add a `Version` attribute to the `` items in the csproj file. This is an error when [Central Package Management (CPM)](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management) is enabled.

### Expected Behavior

The project templates should not add a `Version` attribute to the `` items in the csproj file when [Central Package Management (CPM)](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management) is enabled.
If nesessary, the required `` items should be added to the `Directory.Packages.props` file.

### Steps To Reproduce

1. Create or open a solution with [Central Package Management (CPM)](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management)
2. Add a new project via one of the project templates that uses `` items (e.g. by enabling individual authentication or OpenAPI support for an ASP.NET Core project).
3. Notice that there are compile errors. The root error is [NU1008 Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items](https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1008)

### Exceptions (if any)

_No response_

### .NET Version

7.0.203

### Anything else?

Using Visual Studio 17.5.5

Related: dotnet/sdk#48903

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.