question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for easier CentralPackageManagement options

See original GitHub issue

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:

dotnet new mytemplate -cpm

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

<ItemGroup>
  <!--#if (useCentralPackageManagement)-->
  <PackageReference Include="PackageA" />
  <PackageReference Include="PackageB" />
  <!--#else-->
  <PackageReference Include="PackageA" Version="8.0.0" />
  <PackageReference Include="PackageB" Version="8.0.0" />
  <!--#endif-->
</ItemGroup>

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.

"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

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
YuliiaKovalovacommented, May 29, 2023

@Evangelink , we are investigating the possibility of PostAction usage for resolving this issue. I will let you know once we know more.

0reactions
YuliiaKovalovacommented, Jun 9, 2023

Close due to the existing workaround described in https://github.com/dotnet/templating/issues/6187#issuecomment-1572223281.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing Central Package Management - The NuGet Blog
Central Package Management. Dependency management is a core feature of NuGet. Managing dependencies for a single project can be easy.
Read more >
Central Package Management
Manage your dependencies in a central location and how you can get started with central package management.
Read more >
Centrally managing NuGet package versions
For a project that is opt-out from Central Package Version Management the install/unistall/update of package versions will work as currently.
Read more >
Central Package Management for .NET Projects
It's a way of controlling versions of NuGet packages in a centralized location. This solution follows the modern pattern of using Directory.*.
Read more >
How to centrally manage NuGet package versions within your ...
To get started, you need to create a file named Directory.Build.targets at the root of your solution that declares which packages and which ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found