dotnet / dotnet/templating

Add support for easier CentralPackageManagement options

Open
#6,187 13 comments 9 reactions 1 assignee Claimed by @baronfel View on GitHub
area:package-management gathering-feedback help-wanted triage:transfer-to-sdk triaged
Dominant language
No language data
Stars
1.7k
Forks
399
Avg merge
3d 5h
Merged PRs (30d)
39

Description

### Is your feature request related to a problem? Please describe.

As CentralPacakgeManagement becomes more mainstream it is something we would like to offer as an option in our templates like:
```bash
dotnet new mytemplate -cpm
```

Currently we would need to have dependencies in our template like:
```xml







```

### Describe the solution you'd like.

Add a post action that can work from any host (VS/CLI/etc) which can remove versions on PackageReferences. This could be purpose build to strip out any PackageReference Version. Or to make this the most useful for a variety of situations perhaps a Regex Replace Post Action could be more useful.

```json
"postActions": [{
"condition": "(useCentralPackageManagement)",
"description": "Removes the PackageReference Versions in the generated csproj.",
"args": {
"files": "**\\*.csproj",
"pattern": "(\\s?Version=\\\"\\d+\\.\\d+(.\\d+)?(.\\d+)?(-[A-Za-z\\.0-9]+)?\\\")",
"replace": ""
},
"manualInstructions": [{
"text": "Remove the PackageReference Versions'"
}],
"actionId": "Some Id",
"continueOnError": false
}]
```

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.