Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

(unofficial) Chocolatey .nuspec Checker (Script)

This is not the latest version of (unofficial) Chocolatey .nuspec Checker (Script) available.

  • 1
  • 2
  • 3

2019.01.13 | Updated: 14 Jan 2019

Downloads:

8,154

Downloads of v 2019.01.13:

264

Software Author(s):

  • Bill Curran

(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.13

This is not the latest version of (unofficial) Chocolatey .nuspec Checker (Script) available.

Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Bill Curran. The inclusion of Bill Curran trademark(s), if any, upon this webpage is solely to identify Bill Curran goods or services and not for commercial purposes.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install (unofficial) Chocolatey .nuspec Checker (Script), run the following command from the command line or from PowerShell:

>

To upgrade (unofficial) Chocolatey .nuspec Checker (Script), run the following command from the command line or from PowerShell:

>

To uninstall (unofficial) Chocolatey .nuspec Checker (Script), run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade choco-nuspec-checker -y --source="'INTERNAL REPO URL'" --version="'2019.01.13'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade choco-nuspec-checker -y --source="'INTERNAL REPO URL'" --version="'2019.01.13'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install choco-nuspec-checker
  win_chocolatey:
    name: choco-nuspec-checker
    version: '2019.01.13'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'choco-nuspec-checker' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '2019.01.13'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller choco-nuspec-checker
{
    Name     = "choco-nuspec-checker"
    Version  = "2019.01.13"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'choco-nuspec-checker':
  ensure   => '2019.01.13',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved by moderator gep13 on 14 Jan 2019.

Description


choco://choco-nuspec-checker
To use choco:// protocol URLs, install (unofficial) choco:// Protocol support


Screenshot of (unofficial) Chocolatey .nuspec Checker (Script)

choco-nuspec-checker (CNC) is a PowerShell script designed for Chocolatey package maintainers/creators to check Chocolatey .nuspec files for common errors and ommisions. Find out what the Chocolatey validator is going to tell you BEFORE you submit your package.

FEATURES:

  • CNC checks for all .nuspec elements and reports any missing
  • CNC checks for all verifier messages (guidelines, suggestions, and notes) and reports them if applicable
  • CNC checks for UTF-8 encoding and reports the type of encoding if not UTF-8
  • CNC checks for dead URLs and reports them
  • CNC checks for GitHub direct links, reports them, and can convert to Staticaly CDN URLs
  • CNC checks for RawGit CDN links, reports them, and can convert to Staticaly CDN URLs
  • CNC can open all your .nuspec element URLs in your default browser for quick viewing
  • CNC can add a standard template header and/or footer to your .nuspec description (saving coming soon)

Helps make packaging Chocolateasy!

INSTRUCTIONS:

  • Change to the directory where you have a package .nuspec file and run CNC via PowerShell; it's already in your path. CNC -help for help and options.
  • To check all your packages' .nuspec files change to the root directory of all your packages and via PowerShell run Get-ChildItem -Recurse | ?{if ($.PSIsContainer){cls;cd $.Name;cnc;cd ..;pause}}

PACKAGE NOTES

If you find choco-nuspec-checker useful please consider donating: https://www.paypal.me/bcurran3donations or become a patron at https://www.patreon.com/bcurran3


tools\ChocolateyInstall.ps1
$packageName = 'choco-nuspec-checker' 
$toolsDir    = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$script      = 'CNC.ps1'
$CNCHeader   = 'CNCHeader.txt'
$CNCFooter   = 'CNCFooter.txt'
$CheckExecutionPolicy = Get-ExecutionPolicy

Write-Host "  ** $packageName - FYI: Your PowerShell Execution Policy is curently set to $CheckExecutionPolicy" -ForeGround Yellow

Move-Item "$toolsDir\$script" $env:ChocolateyInstall\bin -Force 

if (!(Test-Path $ENV:ChocolateyInstall\bin\$CNCHeader)) {
    Move-Item "$toolsDir\$CNCHeader" $env:ChocolateyInstall\bin -Force
	$WhoAmI=whoami
    $Acl = Get-Acl "$env:ChocolateyInstall\bin\$CNCHeader"
    $Ar = New-Object  system.security.accesscontrol.filesystemaccessrule($WhoAmI,"FullControl","Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl "$env:ChocolateyInstall\bin\$CNCHeader" $Acl
   }
if (!(Test-Path $ENV:ChocolateyInstall\bin\$CNCFooter)) {
    Move-Item "$toolsDir\$CNCFooter" $env:ChocolateyInstall\bin -Force
	$WhoAmI=whoami
    $Acl = Get-Acl "$env:ChocolateyInstall\bin\$CNCFooter"
    $Ar = New-Object  system.security.accesscontrol.filesystemaccessrule($WhoAmI,"FullControl","Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl "$env:ChocolateyInstall\bin\$CNCFooter" $Acl	
   }
tools\ChocolateyUninstall.ps1
$packageName = 'choco-nuspec-checker' 
$script      = 'CNC.ps1'
$CNCHeader   = 'CNCHeader.txt'
$CNCFooter   = 'CNCFooter.txt'

Remove-Item "$ENV:ChocolateyInstall\bin\$script" -Force | Out-Null
Remove-Item "$ENV:ChocolateyInstall\bin\$CNCHeader" -Force -ErrorAction SilentlyContinue | Out-Null
Remove-Item "$ENV:ChocolateyInstall\bin\$CNCFooter" -Force -ErrorAction SilentlyContinue | Out-Null
tools\CNC.ps1
# CNC.ps1 Copyleft 2018-2019 by Bill Curran AKA BCURRAN3
# LICENSE: GNU GPL v3 - https://www.gnu.org/licenses/gpl.html
# Open a GitHub issue at https://github.com/bcurran3/ChocolateyPackages/issues if you have suggestions for improvement.

# REF: https://github.com/chocolatey/package-validator/wiki
# REF: https://docs.microsoft.com/en-us/nuget/reference/nuspec

function CNC-Splash{
Write-Host "CNC.ps1 v2019.01.13 - (unofficial) Chocolatey .nuspec Checker ""CNC - Run it through the Bill.""" -ForeGroundColor white
Write-Host "Copyleft 2018-2019 Bill Curran ([email protected]) - free for personal and commercial use" -ForeGroundColor white
Write-Host
}

$AcceptableIconExts=@("png","svg")
$BinaryExtensions=@("*.exe","*.msi","*.zip","*.rar","*.7z","*.gz","*.tar","*.sfx","*.iso","*.img","*.msu","*.msp") # miss any?
$CDNlist     = "https://www.staticaly.com, https://raw.githack.com, https://gitcdn.link, or https://www.jsdelivr.com"
$CNCHeader   = "$ENV:ChocolateyInstall\bin\CNCHeader.txt"
$CNCFooter   = "$ENV:ChocolateyInstall\bin\CNCFooter.txt"

if (($args -eq "-help") -or ($args -eq "-?") -or ($args -eq "/?")) {
    CNC-Splash
    Write-Host "OPTIONS AND SWITCHES:" -ForeGround Magenta
	Write-Host
	Write-Host "-help, -?, or /?"
	Write-Host "   Displays this information."
	Write-Host "-AddFooter (saving not implemented yet)"
    Write-Host "   Adds a footer ($CNCFooter) to your .nuspec file and saves it."	
	Write-Host "-AddHeader (saving not implemented yet)"
    Write-Host "   Adds a header ($CNCHeader) to your .nuspec file and saves it."
	Write-Host "-EditFooter"
    Write-Host "   Edit $CNCFooter with Notepad."
	Write-Host "-EditHeader"
    Write-Host "   Edit $CNCHeader with Notepad."
	Write-Host "-OpenURLs"
    Write-Host "   Open all URLs in your browser for inspection when finished."
	Write-Host "-OpenValidatorInfo"
    Write-Host "   Open the Chocolatey package-validator info page on GitHub in your default browser."	
	Write-Host "-ShowFooter"
    Write-Host "   Displays $CNCFooter."	
	Write-Host "-ShowHeader"
    Write-Host "   Displays $CNCHeader."
	Write-Host "-UpdateImageURLs"
    Write-Host "   Updates image URLs with Staticaly CDN URLs."
	Write-Host
	Write-Host "To check all your packages' .nuspec files: Change to the root directory of your packages and run (via PowerShell):"
	Write-Host 'Get-ChildItem -Recurse | ?{if ($_.PSIsContainer){cls;cd $_.Name;cnc;cd ..;pause}}'
	return
}

CNC-Splash

if ($args -eq "-EditFooter") {
    Write-Host "  ** Editing contents of $CNCFooter." -ForeGround Magenta
	&Notepad $CNCFooter
	return
}

if ($args -eq "-EditHeader") {
    Write-Host "  ** Editing contents of $CNCHeader." -ForeGround Magenta
	&Notepad $CNCHeader
	return
}

if ($args -eq "-ShowFooter") {
	Write-Host "  ** Displaying contents of $CNCFooter." -ForeGround Magenta
    Write-Host	
    Get-Content $CNCFooter
	return
}

if ($args -eq "-ShowHeader") {
    Write-Host "  ** Displaying contents of $CNCHeader." -ForeGround Magenta
    Write-Host	
    Get-Content $CNCHeader
	return
}

if ($args -eq "-OpenValidatorInfo") {
    Write-Host "  ** Opening https://github.com/chocolatey/package-validator/wiki." -ForeGround Magenta
    Write-Host	
    &start https://github.com/chocolatey/package-validator/wiki
	return
}

# Get and parse .nuspec in current directory
#FUTURE ENCHANCEMENT accept a filespec and use that as well
$LocalnuspecFile = Get-Item *.nuspec
if (!($LocalnuspecFile)) {
    $CurrentDir=Get-Location
    Write-Host "  ** No .nuspec file found in $CurrentDir" -ForeGround Red
	return
   }

# borrowed from https://blogs.technet.microsoft.com/samdrey/2014/03/26/determine-the-file-encoding-of-a-file-csv-file-with-french-accents-or-other-exotic-characters-that-youre-trying-to-import-in-powershell/   
function Get-FileEncoding
{
    [CmdletBinding()] Param (
     [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string]$Path
    )

    [byte[]]$byte = get-content -Encoding byte -ReadCount 4 -TotalCount 4 -Path $Path

    if ( $byte[0] -eq 0xef -and $byte[1] -eq 0xbb -and $byte[2] -eq 0xbf )
    { Write-Output 'UTF8' }
    elseif ($byte[0] -eq 0xfe -and $byte[1] -eq 0xff)
    { Write-Output 'Unicode' }
    elseif ($byte[0] -eq 0 -and $byte[1] -eq 0 -and $byte[2] -eq 0xfe -and $byte[3] -eq 0xff)
    { Write-Output 'UTF32' }
    elseif ($byte[0] -eq 0x2b -and $byte[1] -eq 0x2f -and $byte[2] -eq 0x76)
    { Write-Output 'UTF7'}
    else
    { Write-Output 'ASCII' } 
}

# Validate that URL elements are actually URLs and verify the URLs are good
# Thanks https://stackoverflow.com/questions/23760070/the-remote-server-returned-an-error-401-unauthorized
function Validate-URL([string]$element,[string]$url){
if (($url -match "http://") -or ($url -match "https://")){
     $HTTP_Response = $null
     $HTTP_Request = [System.Net.WebRequest]::Create($url)
     try{
         $HTTP_Response = $HTTP_Request.GetResponse()
         $HTTP_Status = [int]$HTTP_Response.StatusCode
         if ($HTTP_Status -eq 200) { 
            # do nothing, it's good!
         } else {
           Write-Host ("  ** $element - $url site might be OK, status code:" + $HTTP_Status)
		   Write-Host "           ** Consider using CNC's -OpenURLs option to open and view all URLs in the .nuspec." -ForeGround Cyan
         }
         $HTTP_Response.Close()
        } catch {
          $HTTP_Status = [regex]::matches($_.exception.message, "(?<=\()[\d]{3}").Value
          Write-Warning ("  ** $element - ""$url"" is probably bad, status code: " + $HTTP_Status)
          Write-Host "           ** Consider using CNC's -OpenURLs option to open and view all URLs in the .nuspec." -ForeGround Cyan
        }
   }
}

# Check for license files when binaries are included
function Check-LicenseFile{
$LicenseFile=(Get-ChildItem -Include *LICENSE*.txt -Recurse)
if ($LicenseFile){
	 Write-Host '           ** Binary files - '  $LicenseFile.Name ' file(s) found.' -ForeGround Green
	} else {
	 Write-Warning "           ** Binary files - LICENSE.txt file NOT found."
   }
}

# Check for verfication file when binaries are included
function Check-VerificationFile{
$VerificationFile=(Get-ChildItem -Include *VERIFICATION*.txt -Recurse)
if ($VerificationFile){
     Write-Host '           ** Binary files - '  $VerificationFile.Name ' file(s) found.' -ForeGround Green
	} else {
	 Write-Warning "           ** Binary files - VERIFICATION.txt file NOT found."
   }
}

# check for binaries
function Check-Binaries{
$IncludedBinaries=(Get-ChildItem -Include $BinaryExtensions -Recurse)
if ($IncludedBinaries){
    Write-Warning "  ** Binary files found in package. This will trigger a message from the verifier:"
    Write-Host "           ** Note: Binary files (.exe, .msi, .zip) have been included. The reviewer will ensure the maintainers have`n              distribution rights." -ForeGround Cyan
	Check-LicenseFile
	Check-VerificationFile
   }
}

# add header template to <description>
function Add-Header{
if (Test-Path $CNCHeader){
    $Header=(Get-Content $CNCHeader)
    $NuspecDescription=$Header+$NuspecDescription
    $UpdateNuspec=$True
	return $NuspecDescription
   } else {
	Write-Warning "           ** $CNCHeader not found."
   }
}

# add footer template to <description>
function Add-Footer{
if (Test-Path $CNCFooter){
    $Footer=(Get-Content $CNCFooter)
    $NuspecDescription=$NuspecDescription+$Footer
    $UpdateNuspec=$True
	return $NuspecDescription
   } else {
	Write-Warning "           ** $CNCFooter not found."
   }
}

# check if header template is already in the description
function Check-Header{
$NuspecDescription=$NuspecDescription.Trim()
if ($NuspecDescription.StartsWith("***") -or $NuspecDescription.StartsWith("---") -or $NuspecDescription.StartsWith("___")){ 
    Write-Host "           ** <description> - standardized header found." -ForeGround Green
	$HeaderFound=$True
   }
}

# check if footer template is already in the description
function Check-Footer{
$NuspecDescription=$NuspecDescription.Trim()
if ($NuspecDescription.EndsWith("***") -or $NuspecDescription.EndsWith("---") -or $NuspecDescription.EndsWith("___")){
    Write-Host "           ** <description> - standardized footer found." -ForeGround Green
	$FooterFound=$True
   }
}

# Open all .nuspec URLs for viewing
function Open-URLs{
if ($NuspecBugTrackerURL){&start $NuspecBugTrackerURL}
if ($NuspecDocsURL){&start $NuspecDocsURL}
if ($NuspecIconURL){&start $NuspecIconURL}
if ($NuspecLicenseURL){&start $NuspecLicenseURL}
if ($NuspecMailingListURL){&start $NuspecMailingListURL}
if ($NuspecPackageSourceURL){&start $NuspecPackageSourceURL}
if ($NuspecProjectSourceURL){&start $NuspecProjectSourceURL}
if ($NuspecProjectURL){&start $NuspecProjectURL}
}

# Convert RawGit and non-CDN URLs to Staticaly (and maybe others in the future)
function Update-CDNURL([string]$oldURL){
if ($oldURL -match 'https://raw.githubusercontent.com'){$StaticalyURL=($oldURL -replace 'https://raw.githubusercontent.com','https://cdn.staticaly.com/gh')}
if ($oldURL -match 'https://cdn.rawgit.com'){$StaticalyURL=($oldURL -replace 'https://cdn.rawgit.com','https://cdn.staticaly.com/gh')}
$UpdateNuspec=$True
Write-Host "           ** URL converted but saving not implemented yet." -ForeGround Red	
return $StaticalyURL
}

# FUTURE ENHANCEMENT load nuspec file and save changes
Function Update-nuspec{
if ($UpdateNuspec){
    Write-Host "Writing changes to $LocalnuspecFile." -ForeGround Magenta
    [xml]$Updatednuspec = Get-Content $LocalnuspecFile
# Need to determine changes then write out file
    $Updatednuspec.Save("$LocalnuspecFile")
	}
}

# Import package.nuspec file to get values
# FUTURE ENHANCEMENT change to function
$nuspecXML = $LocalnuspecFile
[xml]$nuspecFile = Get-Content $nuspecXML
$NuspecAuthors = $nuspecFile.package.metadata.authors
$NuspecBugTrackerURL = $nuspecFile.package.metadata.bugtrackerurl	
$NuspecConflicts = $nuspecFile.package.metadata.conflicts # Built for the future
$NuspecCopyright = $nuspecFile.package.metadata.copyright
$NuspecDependencies = $nuspecFile.package.metadata.dependencies # Not fully implemented yet
$NuspecDescription = $nuspecFile.package.metadata.description
$NuspecDocsURL = $nuspecFile.package.metadata.docsurl
$NuspecFiles = $nuspecFile.package.files.file # Not fully implemented yet
$NuspecIconURL = $nuspecFile.package.metadata.iconurl
$NuspecID = $nuspecFile.package.metadata.id
$NuspecLicenseURL = $nuspecFile.package.metadata.licenseurl
$NuspecMailingListURL = $nuspecFile.package.metadata.mailinglisturl
$NuspecOwners = $nuspecFile.package.metadata.owners
$NuspecPackageSourceURL = $nuspecFile.package.metadata.packagesourceurl
$NuspecProjectSourceURL = $nuspecFile.package.metadata.projectsourceurl
$NuspecProjectURL = $nuspecFile.package.metadata.projecturl
$NuspecProvides = $nuspecFile.package.metadata.provides # Built for the future
$NuspecReleaseNotes = $nuspecFile.package.metadata.releasenotes
$NuspecReplaces = $nuspecFile.package.metadata.replaces # Built for the future
$NuspecRequireLicenseAcceptance = $nuspecFile.package.metadata.requirelicenseacceptance
$NuspecSummary = $nuspecFile.package.metadata.summary
$NuspecTags = $nuspecFile.package.metadata.tags
$NuspecTitle = $nuspecFile.package.metadata.title
$NuspecVersion = $nuspecFile.package.metadata.version

$NuspecDisplayName=$LocalnuspecFile.Name

# Start outputting check results
Write-Host "CNC summary of $NuspecDisplayName :" -ForeGroundColor Magenta

# Open all .nuspec URLs for viewing if -OpenURLs is passed
if ($args -eq "-OpenURLs") {
    Write-Host "           ** Opening all .nuspec URLs in your default browser for viewing." -ForeGround Magenta
	Open-URLs
	}

# check for UTF8 encoding
$NuspecEncoding=(Get-FileEncoding -Path $LocalnuspecFile)
if ($NuspecEncoding -ne "UTF8"){Write-Warning "  ** $NuspecDisplayName is $NuspecEncoding, NOT UTF8 encoded."}

# <authors> checks
if (!($NuspecAuthors)) {Write-Warning "  ** <authors> element is empty, this element is a requirement."}

# <bugTrackerUrl> checks
if (!($NuspecBugTrackerURL)) {
     Write-Warning "  ** <bugTrackerUrl> - element is empty. This will trigger a message from the verifier:"
	Write-Host '           ** Suggestion: bugTrackerUrl - points to the location where issues and tickets can be accessed' -ForeGround Cyan
   } else {
     Validate-URL "<bugTrackerUrl>" $NuspecBugTrackerURL
	}

# <conflicts> checks - Built for the future
#if (!($NuspecConflicts)) {Write-Warning "  ** <conflicts> element is empty."}

# <copyright> checks
if (!($NuspecCopyright)) {
    Write-Warning "  ** <copyright> - element is empty."
	} else {
	  if ($NuspecCopyright.Length -lt 5) {
	      Write-Warning "  ** <copyright> - Please update the copyright field so that it is using at least 4 characters."
		  }
	}

# <dependencies> checks
if (!($NuspecDependencies)) {
    Write-Warning "  ** <dependencies> - element is empty."
   } else {
     if ((!$NuspecDependencies) -and ($NuspecTitle -match "deprecated")){Write-Warning "  ** <dependencies> - Deprecated packages must have a dependency."}
	 if ($NuspecDependencies.dependency.id -eq 'chocolatey'){
	     Write-Warning "  ** <dependencies> - ""chocolatey"" is a dependency. This will trigger a message from the verifier:"
	     Write-Host "           ** Note: The package takes a dependency on Chocolatey. The reviewer will ensure the package uses a specific`n              Chocolatey feature that requires a minimum version." -ForeGround Cyan
		 }
		 
	 $DependencyNumber=0
	 do{
 	    if ($NuspecDependencies.dependency[$DependencyNumber].version -eq $null){
		    if ($NuspecDependencies.dependency.id.count -eq 1){
			    $DependencyName=$NuspecDependencies.dependency.id
				} else {
	              $DependencyName=$NuspecDependencies.dependency.id[$DependencyNumber]
				 }
	        Write-Warning "  ** <dependencies> - ""$DependencyName"" has no version. This will trigger a message from the verifier:"
			Write-Host "           ** Guideline: Package contains dependencies with no specified version. You should at least specify`n              a minimum version of a dependency." -ForeGround Cyan
			}
	   $DependencyNumber++
       } while ($DependencyNumber -lt $NuspecDependencies.dependency.id.count)
	 }
	 

# <description> checks
if (!($NuspecDescription)) {
    Write-Warning "  ** <description> - element is empty, this element is a requirement."
   } else {
     Check-Header
     Check-Footer
     if ($NuspecDescription.Length -lt 30) {Write-Warning "  ** <description> - is less than 30 characters."}
     if ($NuspecDescription.Length -gt 4000) {Write-Warning "  ** <description> - is greater than 4,000 characters."}
	 if ($NuspecDescription -match "raw.githubusercontent"){
         Write-Warning "  ** <description> - has a GitHub direct link. Please change to a CDN such as:"
         Write-Host "           ** $CDNlist" -ForeGround Cyan
#         Update-CDNURL - (need to parse and pass URL)
        }
     if ($NuspecDescription -match "cdn.rawgit.com"){
         Write-Warning "  ** <description> - RawGit CDN will be going offline October 2019. Please change to a CDN such as:"
         Write-Host "           ** $CDNlist" -ForeGround Cyan
#         Update-CDNURL - (need to parse and pass URL)
       }
	}
	
# <docsUrl> checks
if (!($NuspecDocsURL)) {
    Write-Warning "  ** <docsUrl> - element is empty. This will trigger a message from the verifier:"
	Write-Host '           ** Suggestion: docsUrl - points to the location of the wiki or docs of the software' -ForeGround Cyan
   } else {
     Validate-URL "<docsUrl>" $NuspecDocsURL
	}

# <files> checks
if (!($NuspecFiles)) {Write-Warning "  ** <files> - element is empty."}

# <iconUrl> checks
if (!($NuspecIconURL)) {
    Write-Warning "  ** <iconUrl> - element is empty. This will trigger a message from the verifier:"
	Write-Host '           ** Guideline: The iconUrl should be added if there is one. Please correct this in the nuspec, if applicable.' -ForeGround Cyan
   } else {
     Validate-URL "<iconUrl>" $NuspecIconURL
	 if ($NuspecIconURL -match "raw.githubusercontent"){
         Write-Warning "  ** <iconUrl> - Your package icon links directly to GitHub. Please use a CDN such as:"
         Write-Host "           ** $CDNlist" -ForeGround Cyan
         if ($args -eq "-UpdateImageURLs") {
		    $NewNuspecIconURL=(Update-CDNURL "$NuspecIconURL")
		   }
        }
     if ($NuspecIconURL -match "cdn.rawgit.com"){
        Write-Warning "  ** <iconUrl> - RawGit CDN will be going offline October 2019. Please change to a CDN such as:"
        Write-Host "           ** $CDNlist" -ForeGround Cyan
        if ($args -eq "-UpdateImageURLs") {
		    $NewNuspecIconURL=(Update-CDNURL "$NuspecIconURL")
		   }
       }
     $IconExt=($NuspecIconURL | Select-String -Pattern $AcceptableIconExts)
     if (!($IconExt)){
         Write-Warning "  ** <iconUrl> - Suggestion: .PNG and .SVG are the preferred package icon file types." 
       }
   }

# <id> checks
if (!($NuspecID)) {
    Write-Warning "  ** <id> - element is empty, this element is a requirement."
	} else {
     if (($NuspecID.Length -gt 20) -and (!$NuspecID.Contains("-")) -and (!$NuspecID.Contains("."))) {
	     Write-Warning "  ** <id> - is greater than 20 characters. This will trigger a message from the verifier:"
	     Write-Host "           ** Note: If this is a new package that has never been approved, moderators will review and reject the`n              package for one that will be pushed with a new id that meets the package naming guidelines." -ForeGround Cyan
	    }
	 if ($NuspecID -cmatch "[A-Z]") {Write-Warning "  ** <id> - includes UPPERcase letters." }
	 if (($NuspecID.Contains(".")) -and (!$NuspecID.Contains(".install")) -and (!$NuspecID.Contains(".portable")) -and (!$NuspecID.Contains(".extension"))) {
	      Write-Warning "  ** <id> - includes a '.'. This will trigger a message from the verifier:"
		  Write-Host "           ** Note: If this is a new package that has never been approved, moderators will review and reject the package`n              for one that will be pushed with a new id that meets the package naming guidelines."  -ForeGround Cyan
		 }
	 }

# <licenseUrl> checks
if (!($NuspecLicenseURL)) {
    Write-Warning "  ** <licenseUrl> - element is empty. This will trigger a message from the verifier:"
	Write-Host "           ** Guideline: The licenseUrl should be added if there is one. Please correct this in the nuspec,`n              if applicable." -ForeGround Cyan
   } else {
     Validate-URL "<licenseUrl>" $NuspecLicenseURL
	}	

# <mailingListUrl> checks
if (!($NuspecMailingListURL)) {
    Write-Warning "  ** <mailingListUrl> - element is empty. This will trigger a message from the verifier:"
	Write-Host '           ** Suggestion: mailingListUrl - points to the forum or email list group for the software' -ForeGround Cyan
   } else {
     Validate-URL "<mailingListUrl>" $NuspecMailingListURL
	}
	
# <owners> checks
if (!($NuspecOwners)) {
    Write-Warning "  ** <owners> element is empty."
   } else {
     if ($NuspecAuthors -eq $NuspecOwners){
        Write-Warning "  ** <owners> and <authors> elements are the same. This will trigger a message from the verifier:"
        Write-Host "           ** Note: The package maintainer field (owners) matches the software author field (authors) in the nuspec.`n              The reviewer will ensure that the package maintainer is also the software author." -ForeGround Cyan
		}
   }

# <packageSourceUrl> checks
if (!($NuspecPackageSourceURL)) {
    Write-Warning "  ** <packageSourceUrl> - element is empty."
	Write-Host "           ** Suggestion: Consider publishing your packages on GitHub. Other people might help you improve your package.`n              Users can also notify you of issues or program updates." -ForeGround Cyan
   } else {
     Validate-URL "<packageSourceUrl>" $NuspecPackageSourceURL
	}		

# <projectSourceUrl> checks
if (!($NuspecProjectSourceURL)) {
    Write-Warning "  ** <projectSourceUrl> - element is empty. This will trigger a message from the verifier:"
	Write-Host '           ** Suggestion: projectSourceUrl - points to the location of the underlying software source' -ForeGround Cyan
   } else {
     Validate-URL "<projectSourceUrl>" $NuspecProjectSourceURL
	 if ($NuspecProjectURL -eq $NuspecProjectSourceURL){
         Write-Warning "  ** <projectUrl> and <projectSourceUrl> elements are the same. This will trigger a message from the verifier:"
         Write-Host "           ** Guideline: ProjectUrl and ProjectSourceUrl are typically different, but not always. Please ensure`n              that projectSourceUrl is pointing to software source code or remove the field from the nuspec." -ForeGround Cyan
       }
	}
	
# <projectUrl> checks
if (!($NuspecProjectURL)) {
    Write-Warning "  ** <projectUrl> - element is empty."
   } else {
     Validate-URL "<projectUrl>" $NuspecProjectURL
	}	

# <provides> checks - Built for the future
#if (!($NuspecProvides)) {Write-Warning "  ** <provides> element is empty"}

# <releaseNotes> checks
if (!($NuspecReleaseNotes)) {
    Write-Warning "  ** <releaseNotes> element is empty. This will trigger a message from the verifier:"
	Write-Host "           ** Guideline: Release Notes (releaseNotes) are a short description of changes in each version of a package.`n              Please include releasenotes in the nuspec. NOTE: To prevent the need to continually update this field,`n              providing a URL to an external list of Release Notes is perfectly acceptable." -ForeGround Cyan
   }

# <replaces> checks - Built for the future
#if (!($NuspecReplaces)) {Write-Warning "  ** <replaces> element is empty."}

# <requireLicenseAcceptance> checks
if (!($NuspecRequireLicenseAcceptance)) {
    Write-Warning "  ** <requireLicenseAcceptance> - element is empty."
	} else {
	  if (($NuspecRequireLicenseAcceptance -eq "true") -and (!($NuspecLicenseURL))) {
	      Write-Warning "  ** <requireLicenseAcceptance> is set to true but <licenseUrl> is empty."
		  }
	  }

# <summary> checks
if (!($NuspecSummary)) {Write-Warning "  ** <summary> - element is empty."}

# <tags> checks
if (!($NuspecTags)) {
     Write-Warning "  ** <tags> - element is empty."
	} else {
	  if ($NuspecTags -match ","){
         Write-Warning "  ** <tags> - tags are separated with commas. They should only be separated with spaces."
		}
	  if ($NuspecTags -match "chocolatey"){
         Write-Warning "  ** Note: There is a tag named chocolatey. This will trigger a message from the verifier:"
         Write-Host '           ** Tags (tags) should not contain 'chocolatey' as a tag. Please remove that in the nuspec.' -ForeGround Cyan
		}
	  if ($NuspecTags -match "notsilent"){
         Write-Warning "  ** Note: There is a tag named notsilent. This will trigger a message from the verifier:"
         Write-Host '           ** Note: notSilent tag is being used. The reviewer will ensure this is being used appropriately. ' -ForeGround Cyan
		}		
    }

# <title> checks
if (!($NuspecTitle)) {Write-Warning "  ** <title> - element is empty."}

# <version> checks
if (!($NuspecVersion)) {Write-Warning "  ** <version> - element is empty, this element is a requirement."}

# Binaries checks
Check-Binaries

# add header template to <description> if -AddHeader is passed to script
if ($args -eq "-AddHeader") {
$NewNuspecDescription=(Add-Header)
}

# add footer template to <description> if -AddFooter is passed to script
if ($args -eq "-AddFooter") {
$NewNuspecDescription=(Add-Footer)
}

Write-Host $NewNuspecDescription -ForeGround Green # temporary debugging

# FUTURE ENHANCEMENT update changes to nuspec
# Update-nuspec{
# $NewNuspecIconURL - make global ?
# $NewNuspecDescription - make global ?
#}

Write-Host "Found CNC.ps1 useful?" -ForeGroundColor white
Write-Host "Buy me a beer at https://www.paypal.me/bcurran3donations" -ForeGroundColor white
Write-Host "Become a patron at https://www.patreon.com/bcurran3" -ForeGroundColor white
return

# TDL
# add the saving of changes to the nuspec
# option of displaying useful tips and tweaks (AutoHotKey, BeCyIconGrabber, PngOptimizer, Regshot, service viewer program, Sumo, etc)
# check http links to see if https links are available and report if so - low priority
# MAYBE download icon file and check it's dimension - very low priority
# What else?
tools\CNCFooter.txt
---
---
tools\CNCHeader.txt
---
---

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
(unofficial) Chocolatey .nuspec Checker (CNC) (Script) 2024.1.14-pre 59 Sunday, January 14, 2024 Exempted
(unofficial) Chocolatey .nuspec Checker (Script) 2023.9.10 226 Sunday, September 10, 2023 Exempted
(unofficial) Chocolatey .nuspec Checker (Script) 2023.05.17 180 Wednesday, May 17, 2023 Exempted
(unofficial) Chocolatey .nuspec Checker (Script) 2023.05.15 80 Wednesday, May 17, 2023 Exempted
(unofficial) Chocolatey .nuspec Checker (Script) 2020.09.21 701 Monday, September 21, 2020 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2020.09.20 174 Sunday, September 20, 2020 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2020.09.15 180 Wednesday, September 16, 2020 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2020.04.06.0001 448 Monday, April 6, 2020 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2020.04.06 182 Monday, April 6, 2020 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2020.01.16 319 Thursday, January 16, 2020 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.12.14 221 Saturday, December 14, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.09.01 342 Monday, September 2, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.08.26 268 Tuesday, August 27, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.03.04 341 Monday, March 4, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.02.22 269 Sunday, March 3, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.02.18 269 Tuesday, February 19, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.02.16 231 Sunday, February 17, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.02.04 255 Tuesday, February 5, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.29 249 Wednesday, January 30, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.26 220 Sunday, January 27, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.22 273 Wednesday, January 23, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.15 285 Wednesday, January 16, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.13 264 Monday, January 14, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.12 273 Saturday, January 12, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.09 248 Thursday, January 10, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.07 244 Tuesday, January 8, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.04 228 Saturday, January 5, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2019.01.03 262 Friday, January 4, 2019 Approved
(unofficial) Chocolatey .nuspec Checker (Script) 2018.12.22 278 Friday, December 28, 2018 Approved

CHANGELOG:

  • 2019.01.13 - finished the dependencies checking, all verifier messages (guidelines, suggestions, and notes) now reporting in *CNC
  • 2019.01.12 - minor fixes
  • 2019.01.09 - many more checks and warnings added, almost all known verifier guidelines, suggestions and notes added, some beautifications, added option to view Chocolatey validator info page, added optional image GitHub direct and RawGit URL conversions to Staticaly CDN URLs
  • 2019.01.07 - added help, added option to open and view all URLs in your default browser, added options to view, edit, and add "standard" (template) headers and footers to the description (can't save yet), added reporting of standard header and footer if found, added more verifier messages, added checking for descriptions that are too large (>4,000), now checks for license files other than LICENSE.txt, probably more I don't remember :)
  • 2019.01.04 - implemented included binary files checking and messages, laid out the groundwork for the future enhancements
  • 2019.01.03 - fixed some URL checking handling that could cause PS errors, updated list of CDN recommendations, added checking for RawGit URLs in description, cosmetic updates
  • 2018.12.22-2018-12.28 - initial release

ROADMAP:

  • save desired changes to the .nuspec file
  • take a filespec to check .nuspec files outside of the local path
  • capture and test URLs found in description
  • add packaging tips/tweaks/etc

This package has no dependencies.

Discussion for the (unofficial) Chocolatey .nuspec Checker (Script) Package

Ground Rules:

  • This discussion is only about (unofficial) Chocolatey .nuspec Checker (Script) and the (unofficial) Chocolatey .nuspec Checker (Script) package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or (unofficial) Chocolatey .nuspec Checker (Script), or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus