-
Notifications
You must be signed in to change notification settings - Fork 4k
Add deprecation for PowerShell 3/4 to Profile psm1 #5413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -38,6 +38,10 @@ if ($PSVersionTable.PSVersion.Major -ge 5) | |||
Register-ArgumentCompleter -CommandName $_.Command -ParameterName $_.Parameter -ScriptBlock $sb | |||
} | |||
} | |||
else | |||
{ | |||
%PSVersionDeprecationMessage% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to save a file in their user directory to indicate that we have displayed this message, simila to the pattern we use for enabling/disabling data collection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markcowl is this what you had in mind?
tools/UpdateModules.ps1
Outdated
@@ -67,6 +67,21 @@ function Create-ModulePsm1 | |||
$template = $template -replace "%DATE%", [string](Get-Date) | |||
$template = $template -replace "%IMPORTED-DEPENDENCIES%", $importedModules | |||
|
|||
if ($ModulePath -like "*Profile*") | |||
{ | |||
$SpecialFolderPath = [Environment]::GetFolderPath("ApplicationData") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly what I had in mind, but we want to make sure that any error in writing the file isn't bubbled up to the user. The safest thing would be to wrap the file write in a try/catch
tools/UpdateModules.ps1
Outdated
$template = $template -replace "%PSVersionDeprecationMessage%", | ||
"if (!(Test-Path '$SpecialFolderPath\Windows Azure Powershell\PSDeprecationWarning.txt')) { ` | ||
Write-Warning $WarningMessage ` | ||
$WarningMessage | Out-File -FilePath '$SpecialFolderPath\Windows Azure Powershell\PSDeprecationWarning.txt' ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, use join-path, this will make this work across platforms
Updated sign job here: https://azuresdkci.westus2.cloudapp.azure.com/view/PowerShell/job/ps-sign/118/ |
Description
#5149
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines