Skip to content

Commit

Permalink
(#250) Removes 'choco' alias override from Invoke-Choco
Browse files Browse the repository at this point in the history
Removes the alias of "choco", which causes a lot of replacements.

This is in order to not confuse users, after running the QSG scripts, who don't expect choco to be replaced.
  • Loading branch information
JPRuskin committed Sep 27, 2024
1 parent d3a19a2 commit 02aeaaa
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions OfflineInstallPreparation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if (-not $Licensed) {
} else {
'https://licensedpackages.chocolatey.org/api/v2/'
}
choco install chocolatey.extension --source $ExtensionSource --params="'/NoContextMenu'" --confirm
Invoke-Choco install chocolatey.extension --source $ExtensionSource --params="'/NoContextMenu'" --confirm
}

# Download each set of packages to the output directories
Expand Down Expand Up @@ -126,7 +126,7 @@ foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertF
Start-Sleep -Seconds 5
}

choco @ChocoArgs
Invoke-Choco @ChocoArgs
}
} catch {
throw $_
Expand Down
10 changes: 5 additions & 5 deletions Set-SslSecurity.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ process {
} until($response.StatusCode -eq '200')
Write-Host "Nexus is ready!"

choco source remove --name="'ChocolateyInternal'"
Invoke-Choco source remove --name="'ChocolateyInternal'"
$RepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"

# Build Credential Object, Connect to Nexus
Expand Down Expand Up @@ -190,7 +190,7 @@ process {
"--user='chocouser'",
"--password='$NexusPw'"
)
& choco @ChocoArgs
& Invoke-Choco @ChocoArgs
}

else {
Expand All @@ -201,12 +201,12 @@ process {
"--source='$RepositoryUrl'",
'--priority=1'
)
& choco @ChocoArgs
& Invoke-Choco @ChocoArgs
}

# Update Repository API key
$chocoArgs = @('apikey', "--source='$RepositoryUrl'", "--api-key='$NuGetApiKey'")
& choco @chocoArgs
& Invoke-Choco @chocoArgs

# Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
Expand Down Expand Up @@ -251,7 +251,7 @@ process {
$IsSelfSigned = $true
.\scripts\New-IISCertificateHost.ps1
}

# Generate Register-C4bEndpoint.ps1
$EndpointScript = "$PSScriptRoot\scripts\Register-C4bEndpoint.ps1"

Expand Down
20 changes: 10 additions & 10 deletions Start-C4bCcmSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ process {
# DB Setup
Write-Host "Installing SQL Server Express"
$chocoArgs = @('upgrade', 'sql-server-express', '-y', '--no-progress')
& choco @chocoArgs
& Invoke-Choco @chocoArgs

# https://docs.microsoft.com/en-us/sql/tools/configuration-manager/tcp-ip-properties-ip-addresses-tab
Write-Verbose 'SQL Server: Configuring Remote Access on SQL Server Express.'
Expand Down Expand Up @@ -90,19 +90,19 @@ process {
# Install prerequisites for CCM
Write-Host "Installing Chocolatey Central Management Prerequisites"
$chocoArgs = @('install', 'IIS-WebServer', "--source='windowsfeatures'", '--no-progress', '-y')
& choco @chocoArgs -ValidExitCodes 0, 3010
& Invoke-Choco @chocoArgs -ValidExitCodes 0, 3010

$chocoArgs = @('install', 'IIS-ApplicationInit', "--source='windowsfeatures'" ,'--no-progress', '-y')
& choco @chocoArgs -ValidExitCodes 0, 3010
& Invoke-Choco @chocoArgs -ValidExitCodes 0, 3010

$chocoArgs = @('install', 'dotnet-aspnetcoremodule-v2', "--version='$($Packages.Where{$_.Name -eq 'dotnet-aspnetcoremodule-v2'}.Version)'", '--no-progress', '-y')
& choco @chocoArgs
& Invoke-Choco @chocoArgs

$chocoArgs = @('install', 'dotnet-8.0-runtime', "--version=$($Packages.Where{$_.Name -eq 'dotnet-8.0-runtime'}.Version)", '--no-progress', '-y')
& choco @chocoArgs
& Invoke-Choco @chocoArgs

$chocoArgs = @('install', 'dotnet-8.0-aspnetruntime', "--version=$($Packages.Where{$_.Name -eq 'dotnet-8.0-aspnetruntime'}.Version)", '--no-progress', '-y')
& choco @chocoArgs
& Invoke-Choco @chocoArgs

Write-Host "Creating Chocolatey Central Management Database"
choco install chocolatey-management-database -y --package-parameters="'/ConnectionString=Server=Localhost\SQLEXPRESS;Database=ChocolateyManagement;Trusted_Connection=true;'" --no-progress
Expand Down Expand Up @@ -131,22 +131,22 @@ process {
else {
Write-Verbose "Certificate has been successfully found in correct store"
$chocoArgs = @('install', 'chocolatey-management-service', '-y', "--package-parameters-sensitive='/ConnectionString:Server=Localhost\SQLEXPRESS;Database=ChocolateyManagement;User Id=$DatabaseUser;Password=$DatabaseUserPw'")
& choco @chocoArgs
& Invoke-Choco @chocoArgs

Set-CcmCertificate -CertificateThumbprint $CertificateThumbprint
}
}

else {
$chocoArgs = @('install', 'chocolatey-management-service', '-y', "--package-parameters-sensitive=`"/ConnectionString:'Server=Localhost\SQLEXPRESS;Database=ChocolateyManagement;User ID=$DatabaseUser;Password=$DatabaseUserPw;'`"", '--no-progress')
& choco @chocoArgs
& Invoke-Choco @chocoArgs
}

Write-Host "Installing Chocolatey Central Management Website"
$chocoArgs = @('install', 'chocolatey-management-web', '-y', "--package-parameters-sensitive=""'/ConnectionString:Server=Localhost\SQLEXPRESS;Database=ChocolateyManagement;User ID=$DatabaseUser;Password=$DatabaseUserPw;'""", '--no-progress')
& choco @chocoArgs
& Invoke-Choco @chocoArgs

$CcmSvcUrl = choco config get centralManagementServiceUrl -r
$CcmSvcUrl = Invoke-Choco config get centralManagementServiceUrl -r
Update-Clixml -Properties @{
CCMServiceURL = $CcmSvcUrl
CCMWebPortal = "http://localhost/Account/Login"
Expand Down
4 changes: 2 additions & 2 deletions Start-C4bJenkinsSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ process {

# Install temurin21jre to meet JRE>11 dependency of Jenkins
$chocoArgs = @('install', 'temurin21jre', '-y', '--no-progress', "--params='/ADDLOCAL=FeatureJavaHome'")
& choco @chocoArgs
& Invoke-Choco @chocoArgs

# Environment variable used to disable jenkins install login prompts
[Environment]::SetEnvironmentVariable('JAVA_OPTS', '-Djenkins.install.runSetupWizard=false', 'Machine')

# Install Jenkins
Write-Host "Installing Jenkins"
$chocoArgs = @('install', 'jenkins', '-y', '--no-progress')
& choco @chocoArgs
& Invoke-Choco @chocoArgs

Write-Host "Giving Jenkins 30 seconds to complete background setup..." -ForegroundColor Green
Start-Sleep -Seconds 30 # Jenkins needs a moment
Expand Down
10 changes: 5 additions & 5 deletions Start-C4bNexusSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process {
# Install base nexus-repository package
Write-Host "Installing Sonatype Nexus Repository"
$chocoArgs = @('install', 'nexus-repository', '-y' ,'--no-progress', "--package-parameters='/Fqdn:localhost'")
& choco @chocoArgs
& Invoke-Choco @chocoArgs

#Build Credential Object, Connect to Nexus
Write-Host "Configuring Sonatype Nexus Repository"
Expand All @@ -56,7 +56,7 @@ process {

# Push all packages from previous steps to NuGet repo
Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\files" -Filter *.nupkg | ForEach-Object {
choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --apikey $NugetApiKey --force
Invoke-Choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --apikey $NugetApiKey --force
}

# Temporary workaround to reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
Expand All @@ -79,15 +79,15 @@ process {
}

# Nexus NuGet V3 Compatibility
choco feature disable --name="'usePackageRepositoryOptimizations'"
Invoke-Choco feature disable --name="'usePackageRepositoryOptimizations'"

# Add ChocolateyInternal as a source repository
choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1
Invoke-Choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1

# Install a non-IE browser for browsing the Nexus web portal.
if (-not (Test-Path 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')) {
Write-Host "Installing Microsoft Edge, to allow viewing the Nexus site"
choco install microsoft-edge -y --source ChocolateyInternal
Invoke-Choco install microsoft-edge -y --source ChocolateyInternal
if ($LASTEXITCODE -eq 0) {
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Edge') {
$RegArgs = @{
Expand Down
4 changes: 2 additions & 2 deletions Start-C4bSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ try {
& $FilesDir\OfflineInstallPreparation.ps1 -LicensePath $LicenseFile

if (Test-Path $FilesDir\files\*.nupkg) {
choco source add --name LocalChocolateySetup --source $FilesDir\files\ --Priority 1
Invoke-Choco source add --name LocalChocolateySetup --source $FilesDir\files\ --Priority 1
}

# Set Choco Server Chocolatey Configuration
choco feature enable --name="'excludeChocolateyPackagesDuringUpgradeAll'"
Invoke-Choco feature enable --name="'excludeChocolateyPackagesDuringUpgradeAll'"

# Convert license to a "choco-license" package, and install it locally to test
Write-Host "Creating a 'chocolatey-license' package, and testing install." -ForegroundColor Green
Expand Down
2 changes: 1 addition & 1 deletion Start-C4bVerification.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process {
if (-not (Get-Module Pester -ListAvailable).Where{$_.Version -gt "5.0"}) {
Write-Host "Installing Pester 5 to run validation tests"
$chocoArgs = @('install', 'pester', '-y', '--no-progress', '--source="https://community.chocolatey.org/api/v2/"')
& choco @chocoArgs
& Invoke-Choco @chocoArgs
}

$files = (Get-ChildItem C:\choco-setup\files\tests\ -Recurse -Filter *.ps1).Fullname
Expand Down
1 change: 0 additions & 1 deletion modules/C4B-Environment/C4B-Environment.psm1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Helper Functions for the various QSG scripts
function Invoke-Choco {
[CmdletBinding()]
[Alias('choco')]
param(
[Parameter(Position=0)]
[string]$Command,
Expand Down

0 comments on commit 02aeaaa

Please sign in to comment.