chocolatey / chocolatey/choco

Feature Request: Add script to `choco new` templates to remove comments from `ps1` and `nuspec` files

Open
#2,037 3 comments 2 reactions 0 assignees View on GitHub
0 - Triaging Enhancement Up For Grabs
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

Currently there is a comment at the top of the `chocolateyinstall.ps1` and `chocolateyuninstall.ps1` files:
```
# IMPORTANT: Before releasing this package, copy/paste the next 2 lines into PowerShell to remove all comments from this file:
# $f='c:\path\to\thisFile.ps1'
# gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*?[^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f
```

Would it be possible to move this code to a PowerShell script beside the `nuspec` file that runs on all of the ps1 files? This script could also remove all comments from the nuspec file as well.

Or, as another option: could this action be done as part of the `choco pack` process? Akin to minifying javascript before deploying to a website.

If this is something that would be desired, I have been working on a script in my own repo that I could contribute.

Contributor guide

Open the contributing guide

Research direction

Start by examining the choco new templates containing chocolateyinstall.ps1, chocolateyuninstall.ps1, and the nuspec file, then trace the choco pack process. The issue presents two possible entry points, so first clarify whether comment removal belongs in template generation or packing. Done means comments are consistently removed from the relevant ps1 and nuspec files without breaking package creation.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.