当我需要启用 Tls1.2 时,如何从下载的脚本安装 dotnet 核心?
How do i install dotnet core from a downloaded script when i need to enable Tls1.2?
我有一个 CI/CD 脚本,它使用脚本 (https://dot.net/v1/dotnet-install.ps1) 安装 dotnet 核心。我们下载(并缓存)脚本,然后想使用 powershell
从脚本中直接调用它
powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy unrestricted -File "%MYDIR%\dotnet-install.ps1" -Version 2.1.806
然而,在 CI/CD 机器上,这失败了:
dotnet-install: Downloading link: https://dotnetcli.[snip]/dotnet-sdk-2.1.806-win-x86.zip
dotnet-install: Cannot download: https://dotnetcli.[snip]/dotnet-sdk-2.1.806-win-x86.zip
dotnet-install: Downloading legacy link: https://dotnetcli.[snip]/dotnet-dev-win-x86.2.1.806.zip
dotnet-install: Cannot download: https://dotnetcli.[snip]/dotnet-dev-win-x86.2.1.806.zip
Could not find/download: ".NET Core SDK" with version = 2.1.806
原来这个失败是因为我们无法建立安全连接,需要开启Tls1.2
如何修改我的 powershell 命令来执行此操作?
有多个直接从下载文件调用文件的例子。例如:在官方文档页面 (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script):
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"
但是,我无法从本地 downloaded/cached 文件中找到直接执行此操作的任何示例。如果您需要使用 TLS 1.2 调用的本地文件,试试这个:
powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; . '%MYDIR%\dotnet-install.ps1'" -Version 2.1.806
我有一个 CI/CD 脚本,它使用脚本 (https://dot.net/v1/dotnet-install.ps1) 安装 dotnet 核心。我们下载(并缓存)脚本,然后想使用 powershell
从脚本中直接调用它powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy unrestricted -File "%MYDIR%\dotnet-install.ps1" -Version 2.1.806
然而,在 CI/CD 机器上,这失败了:
dotnet-install: Downloading link: https://dotnetcli.[snip]/dotnet-sdk-2.1.806-win-x86.zip
dotnet-install: Cannot download: https://dotnetcli.[snip]/dotnet-sdk-2.1.806-win-x86.zip
dotnet-install: Downloading legacy link: https://dotnetcli.[snip]/dotnet-dev-win-x86.2.1.806.zip
dotnet-install: Cannot download: https://dotnetcli.[snip]/dotnet-dev-win-x86.2.1.806.zip
Could not find/download: ".NET Core SDK" with version = 2.1.806
原来这个失败是因为我们无法建立安全连接,需要开启Tls1.2
如何修改我的 powershell 命令来执行此操作?
有多个直接从下载文件调用文件的例子。例如:在官方文档页面 (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script):
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"
但是,我无法从本地 downloaded/cached 文件中找到直接执行此操作的任何示例。如果您需要使用 TLS 1.2 调用的本地文件,试试这个:
powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; . '%MYDIR%\dotnet-install.ps1'" -Version 2.1.806