From ef3b8137d7f0d981da819210667872fde9ca6289 Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Wed, 2 Sep 2026 07:00:02 +0000 Subject: [PATCH] upgrade to powershellget 2.2.5 --- Vagrantfile | 2 ++ provision/windows/provision-chocolatey.ps1 | 6 ++++ provision/windows/provision-powershellget.ps1 | 35 +++++++++++++++++++ .../windows/use-chocolatey-repository.ps1 | 3 -- .../windows/use-powershell-repository.ps1 | 14 -------- renovate.json5 | 24 +++++++++++++ 6 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 provision/windows/provision-chocolatey.ps1 create mode 100644 provision/windows/provision-powershellget.ps1 diff --git a/Vagrantfile b/Vagrantfile index fe8edc8..f0e7d40 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -46,6 +46,8 @@ Vagrant.configure(2) do |config| end config.vm.provision :shell, inline: "echo '#{nexus_ip} #{nexus_domain}' | Out-File -Encoding Ascii -Append c:/Windows/System32/drivers/etc/hosts" config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['provision-base.ps1', nexus_domain] + config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['provision-chocolatey.ps1'] + config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['provision-powershellget.ps1'] config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['use-chocolatey-repository.ps1', nexus_domain] config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['use-powershell-repository.ps1', nexus_domain] config.vm.provision :shell, path: 'provision/windows/ps.ps1', args: ['use-npm-repository.ps1', nexus_domain] diff --git a/provision/windows/provision-chocolatey.ps1 b/provision/windows/provision-chocolatey.ps1 new file mode 100644 index 0000000..f3ecb03 --- /dev/null +++ b/provision/windows/provision-chocolatey.ps1 @@ -0,0 +1,6 @@ +# install chocolatey. +# see https://community.chocolatey.org/packages/chocolatey +# renovate: datasource=nuget:chocolatey depName=chocolatey +$chocolateyVersion = '2.7.4' +$env:chocolateyVersion = $chocolateyVersion +Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) diff --git a/provision/windows/provision-powershellget.ps1 b/provision/windows/provision-powershellget.ps1 new file mode 100644 index 0000000..458ddff --- /dev/null +++ b/provision/windows/provision-powershellget.ps1 @@ -0,0 +1,35 @@ +# install PowerShellGet v2. +# NB we cannot uninstall the built-in modules. +# see https://learn.microsoft.com/en-us/powershell/gallery/powershellget/install-powershellget?view=powershellget-2.x + +$nugetPackageProviderVersion = '2.8.5.208' +Write-Host "Installing the NuGet $nugetPackageProviderVersion provider..." +Install-PackageProvider ` + -Name NuGet ` + -RequiredVersion $nugetPackageProviderVersion ` + -Force ` + | Format-List + +# see https://community.chocolatey.org/packages/nuget.commandline +# renovate: datasource=nuget:chocolatey depName=nuget.commandline +$nugetVersion = '7.9.0' +Write-Host "Installing nuget $nugetVersion and configuring PowerShellGet to use it..." +choco install -y nuget.commandline --version $nugetVersion +$psGetNugetPath = 'C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe' +mkdir (Split-Path -Parent $psGetNugetPath) | Out-Null +New-Item ` + -ItemType SymbolicLink ` + -Path $psGetNugetPath ` + -Target 'C:\ProgramData\chocolatey\lib\NuGet.CommandLine\tools\NuGet.exe' ` + | Out-Null + +# see https://www.powershellgallery.com/packages/PowerShellGet +# renovate: datasource=nuget:powershellgallery depName=PowerShellGet +$powerShellGetModuleVersion = '2.2.5' +Write-Host "Installing PowerShellGet $powerShellGetModuleVersion..." +Install-Module ` + -Repository PSGallery ` + -Name PowerShellGet ` + -RequiredVersion $powerShellGetModuleVersion ` + -AllowClobber ` + -Force diff --git a/provision/windows/use-chocolatey-repository.ps1 b/provision/windows/use-chocolatey-repository.ps1 index 2091d05..81aab49 100644 --- a/provision/windows/use-chocolatey-repository.ps1 +++ b/provision/windows/use-chocolatey-repository.ps1 @@ -2,9 +2,6 @@ param( [string]$nexusDomain = 'nexus.example.com' ) -# install chocolatey. -Invoke-Expression ((New-Object Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - Write-Host 'Default Chocolatey sources:' choco sources list diff --git a/provision/windows/use-powershell-repository.ps1 b/provision/windows/use-powershell-repository.ps1 index 30fc3ce..174a944 100644 --- a/provision/windows/use-powershell-repository.ps1 +++ b/provision/windows/use-powershell-repository.ps1 @@ -10,7 +10,6 @@ Get-PSRepository Write-Host 'Configuring PowerShell to only use the nexus server...' Get-PSRepository | Unregister-PSRepository -Install-PackageProvider NuGet -Force Register-PSRepository ` -Name nexus ` -SourceLocation https://$nexusDomain/repository/powershell-group/ ` @@ -20,19 +19,6 @@ Register-PSRepository ` Write-Host 'Current PowerShell sources:' Get-PSRepository -Write-Host 'Installing the Sql Server module from the nexus server...' -Install-Module SqlServer - -Write-Host 'Installing nuget and configuring PowerShellGet to use it...' -choco install -y nuget.commandline -$psGetNugetPath = 'C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe' -mkdir (Split-Path -Parent $psGetNugetPath) | Out-Null -New-Item ` - -ItemType SymbolicLink ` - -Path $psGetNugetPath ` - -Target 'C:\ProgramData\chocolatey\lib\NuGet.CommandLine\tools\NuGet.exe' ` - | Out-Null - Write-Host 'Publishing the ExampleGreeter module into the nexus server...' Set-Location $env:TEMP mkdir ExampleGreeter | Out-Null diff --git a/renovate.json5 b/renovate.json5 index 3f51ee5..de3094a 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -17,5 +17,29 @@ "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver-coerced{{/if}}", "extractVersionTemplate": "{{#if extractVersion}}{{{extractVersion}}}{{else}}^v?(?.+)${{/if}}" }, + // nuget:chocolatey datasource. + { + "fileMatch": [ + "\\.ps1$" + ], + "matchStrings": [ + "# renovate: datasource=(?nuget):chocolatey depName=(?.+?)( versioning=(?.+?))?( extractVersion=(?.+?))?( registryUrl=(?.+?))?\\s.+?[:=]\\s*[\"']?(?.+?)[\"']?\\s" + ], + "registryUrlTemplate": "{{#if registryUrl}}{{{registryUrl}}}{{else}}https://community.chocolatey.org/api/v2{{/if}}", + "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}nuget{{/if}}", + "extractVersionTemplate": "{{#if extractVersion}}{{{extractVersion}}}{{else}}^v?(?.+)${{/if}}" + }, + // nuget:powershellgallery datasource. + { + "fileMatch": [ + "\\.ps1$" + ], + "matchStrings": [ + "# renovate: datasource=(?nuget):powershellgallery depName=(?.+?)( versioning=(?.+?))?( extractVersion=(?.+?))?( registryUrl=(?.+?))?\\s.+?[:=]\\s*[\"']?(?.+?)[\"']?\\s" + ], + "registryUrlTemplate": "{{#if registryUrl}}{{{registryUrl}}}{{else}}https://www.powershellgallery.com/api/v2{{/if}}", + "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}nuget{{/if}}", + "extractVersionTemplate": "{{#if extractVersion}}{{{extractVersion}}}{{else}}^v?(?.+)${{/if}}" + }, ] } \ No newline at end of file