From 07617406693e45a709a81f3af379a0360924a7a8 Mon Sep 17 00:00:00 2001 From: Igor Velikorossov Date: Fri, 6 Sep 2019 20:51:28 +0300 Subject: [PATCH 1/3] Fix GitExtensions.settings creation on a new installation (cherry picked from commit abac1b4564a5166f0453fa3ee459769e8a199b6f) --- Bin/set-telemetry.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Bin/set-telemetry.ps1 b/Bin/set-telemetry.ps1 index f4ea2ec6700..3f4bfc09ae4 100644 --- a/Bin/set-telemetry.ps1 +++ b/Bin/set-telemetry.ps1 @@ -7,7 +7,12 @@ Param( [string]$userAppDataPath = Join-Path -Path $env:APPDATA -ChildPath 'GitExtensions\GitExtensions\GitExtensions.settings' if (-not (Test-Path -Path $userAppDataPath)) { - '' | Out-File $userAppDataPath -Encoding utf8 + [string]$userAppDataFolder = Split-Path $userAppDataPath -Parent + if (-not (Test-Path -Path $userAppDataFolder)) { + New-Item -ItemType Directory -Path $userAppDataFolder | Out-Null + } + + '' | Out-File $userAppDataPath -Encoding utf8 } [xml]$doc = Get-Content $userAppDataPath From 17e9d82c38312c2dd01a08c9c6ba769481be681d Mon Sep 17 00:00:00 2001 From: RussKie Date: Wed, 11 Sep 2019 15:18:35 +0300 Subject: [PATCH 2/3] fix: Unable to intstall new version There are few issues with the install script related to configuring the telemetry settings. 1. On W7 there is only PowerShell 2.0 (that is what ships with .NET 2.0). On the later versions of OS there are different versions of PowerShell and thus requiring a specific version would lead to failures. 2. A problem related to the logic responsible for self-removal * First `$MyINvocation.InvocationName` returned different and unexpected values when a script is run not from a command line but invoked as a script-block. In the latter case, `$MyINvocation.InvocationName` is set to `&`. * Secondly the installer somehow would fail to remove the script (permissions?) The self-removal logic is removed. Also bumping the version to 3.2.1 to ensure the new fix flows through to all distribution channels correctly. Resolves #7120 (cherry picked from commit cedb5886f722349df047d87d90434e8326d8f4a2) # Conflicts: # appveyor.yml --- Bin/set-telemetry.ps1 | 3 --- Setup/UI/TelemetryDlg.wxs | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Bin/set-telemetry.ps1 b/Bin/set-telemetry.ps1 index 3f4bfc09ae4..bcd6b4f853d 100644 --- a/Bin/set-telemetry.ps1 +++ b/Bin/set-telemetry.ps1 @@ -37,6 +37,3 @@ $node = $doc.CreateElement('item'); $node.InnerXml = "TelemetryEnabled$telemetryEnabled"; $_ = $topNode.AppendChild($node); $doc.Save($userAppDataPath) - -# this script now deletes itself -Remove-Item $MyINvocation.InvocationName diff --git a/Setup/UI/TelemetryDlg.wxs b/Setup/UI/TelemetryDlg.wxs index 07374e96fcc..905ef62cbb6 100644 --- a/Setup/UI/TelemetryDlg.wxs +++ b/Setup/UI/TelemetryDlg.wxs @@ -14,11 +14,10 @@ - + Value=""[POWERSHELLEXE]" -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& '[INSTALLDIR]set-telemetry.ps1' [TELEMETRY_ENABLED]; exit $$($Error.Count)"" /> From 31d4f416dbe49c76de1b0214d71eff97ea0d2722 Mon Sep 17 00:00:00 2001 From: Martin Steinisch Date: Tue, 15 Oct 2019 19:53:48 +0200 Subject: [PATCH 3/3] Add check for LanguageMode and exit early with exit code 0 if the script would otherwise fail --- Bin/set-telemetry.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Bin/set-telemetry.ps1 b/Bin/set-telemetry.ps1 index bcd6b4f853d..6e04c38793a 100644 --- a/Bin/set-telemetry.ps1 +++ b/Bin/set-telemetry.ps1 @@ -5,6 +5,11 @@ Param( [bool]$telemetryEnabled = -not [string]::IsNullOrEmpty($Enabled); +if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") +{ + exit 0 +} + [string]$userAppDataPath = Join-Path -Path $env:APPDATA -ChildPath 'GitExtensions\GitExtensions\GitExtensions.settings' if (-not (Test-Path -Path $userAppDataPath)) { [string]$userAppDataFolder = Split-Path $userAppDataPath -Parent