I've been working on my first PS module, and wanted to share the beginning of my work with the community on the PSGallery.
So for the time being, this code can be used to automatically update the affected file targeting the right .NET Version (do note I'm replacing with net6
, use the correct version for you, likely will be net6
but can't be sure).
Also note, running this code will require an elevated session, or you would get Access Denied errors.
# 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