deploy.ps1
|
if(!(Test-Path .\.api_key)) { Write-Error "Set .apikey file with api key" return } $API_KEY=Get-Content .\.api_key function Set-CultureWin([System.Globalization.CultureInfo] $culture) { [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture ; [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture } ; Set-CultureWin en-US ; [system.threading.thread]::currentthread.currentculture function Remove-ComObject { # Requires -Version 2.0 [CmdletBinding()] param() end { Start-Sleep -Milliseconds 500 [Management.Automation.ScopedItemOptions]$scopedOpt = 'ReadOnly, Constant' Get-Variable -Scope 1 | Where-Object { $_.Value.pstypenames -contains 'System.__ComObject' -and -not ($scopedOpt -band $_.Options) } | Remove-Variable -Scope 1 -Verbose:([Bool]$PSBoundParameters['Verbose'].IsPresent) [gc]::Collect() } } Function Using-Culture ( [System.Globalization.CultureInfo]$culture, [ScriptBlock]$script) { $OldCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture trap { [System.Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture } [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture $ExecutionContext.InvokeCommand.InvokeScript($script) [System.Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture } # End Function Using-Culture en-us { Import-Module PowerShellGet -Version 3.0.19 Publish-Module -Name "Telegram-Webhook" -NuGetApiKey $API_KEY #[System.Runtime.InteropServices.Marshal]::ReleaseComObject($xl) } # in case of failed to compress error -> install newer powershell # in case requiredModules error - install all required modules # in case of "Ѓ §®ў®Ґ ᮥ¤ЁҐЁҐ § Єалв®: ЌҐЇаҐ¤ўЁ¤Ґ п ®иЁЎЄ ЇаЁ ЇҐаҐ¤ зҐ. - restart session # in case of pushlish errors "Failed to Pack" use this # # find the file having wrong .NET version # $path = Get-ChildItem (Get-Module PowerShellGet -ListAvailable).ModuleBase -Recurse -File | # Select-String -Pattern netcoreapp2.0 | ForEach-Object Path # # unload the module # Remove-Module PowerShellGet -Verbose -Force -EA 0 # # update the file # $path | ForEach-Object { # (Get-Content -LiteralPath $_ -Raw).Replace('netcoreapp2.0', 'net6') | # Set-Content $_ # } # Import-Module PowerShellGet -Force -Verbose # # now try to publish |