Skip to content

Conversation

@lukas-lansky
Copy link
Contributor

@lukas-lansky lukas-lansky commented Mar 3, 2021

This is going to work with runtime's dotnet.cmd after adding something like chcp 65001 to that script.

If I understand the situation properly, Set-Content -Encoding changed defaults between different versions of PowerShell from "system's active code page" to "utf8NoBOM". It's probably better for us to fix that value more often than not.

Solves #6960

@lukas-lansky lukas-lansky requested a review from riarenas March 3, 2021 16:09
@riarenas
Copy link
Contributor

riarenas commented Mar 3, 2021

Wondering how you validated that this solves things? We should also link an issue to this PR so that it's clear what it's trying to fix.

@lukas-lansky
Copy link
Contributor Author

lukas-lansky commented Mar 3, 2021

This one is actually already linked to an issue, to #6960. (Maybe the ZenHub way of linking stuff isn't preferable in this repo?)

I did this to verify:

C:\Source\runťime> git diff
diff --git a/dotnet.cmd b/dotnet.cmd
index b3cf59daa28..c37121decaa 100644
--- a/dotnet.cmd
+++ b/dotnet.cmd
@@ -1,4 +1,5 @@
 @echo off
+chcp 65001 > nul

 powershell -ExecutionPolicy ByPass -NoProfile -Command "& { . '%~dp0eng\common\tools.ps1'; InitializeDotNetCli $true $true }"

diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1
index 572da3b9f12..312546aac1d 100644
--- a/eng/common/tools.ps1
+++ b/eng/common/tools.ps1
@@ -166,7 +166,7 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
       $sdkCacheFileTemp = Join-Path $ToolsetDir $([System.IO.Path]::GetRandomFileName())
     }
     until (!(Test-Path $sdkCacheFileTemp))
-    Set-Content -Path $sdkCacheFileTemp -Value $dotnetRoot
+    Set-Content -Path $sdkCacheFileTemp -Value $dotnetRoot -Encoding utf8

     try {
       Rename-Item -Force -Path $sdkCacheFileTemp 'sdk.txt'

With the patch, ./dotnet.cmd works, without it, it fails just like described in the ticket.

@riarenas
Copy link
Contributor

riarenas commented Mar 3, 2021

Zenhub linking doesn't end up anywhere in the git history, which is why we usually prefer to mention the issue as part of the PR description so that it gets saved for posterity in the commit history.

@lukas-lansky
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lukas-lansky lukas-lansky merged commit 5083874 into dotnet:master Mar 3, 2021
@lukas-lansky lukas-lansky deleted the sdk-txt-utf branch March 3, 2021 21:52
akoeplinger pushed a commit to akoeplinger/arcade that referenced this pull request Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants