1

I have a CI/CD script which installs dotnet core using the scripts (https://dot.net/v1/dotnet-install.ps1). We download (and cache) the script, then want to invoke it directly from script using powershell

powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy unrestricted -File "%MYDIR%\dotnet-install.ps1" -Version 2.1.806

However, on the CI/CD machine, this fails:

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

It turns out that this fails because we cannot establish a secure connection, and need to enable Tls1.2

How do I do modify my powershell command to do this?

1 Answer 1

2

There are multiple examples of invoking the file directly from the downloaded file. eg: on the official documentation page (https://learn.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>"

However, I was unable to find any examples of doing this directly from a locally downloaded/cached file. If you need a local file invoked with TLS 1.2, try this:

powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; . '%MYDIR%\dotnet-install.ps1'" -Version 2.1.806
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.