Not working in Linux PowerShell with `Register-PSRepository` on a Ubuntu docker image
Opened this issue · 3 comments
How is this supposed to work in a Linux docker container with Register-PSRepository
/ Register-PackageSource
? I seem to be having the same issue that's described here where these commands fail due to a missing file (possibly nuget.exe)
I'm setting this up in my docker file like so:
FROM ubuntu:22.04
RUN wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb
RUN apt-get update && apt-get install -y --no-install-recommends \
curl jq git gnupg zip unzip iputils-ping libcurl4 libunwind8 netcat libssl1.0 openssh-client \
lxc iptables apt-transport-https powershell software-properties-common dotnet-sdk-8.0\
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*
ARG ADO_USER="user@company.com"
ARG ADO_TOKEN="somevalidtoken"
ARG ADO_SOURCE="PSNuGet"
ARG ADO_URL="https://pkgs.dev.azure.com/company/_packaging/${ADO_SOURCE}/nuget/v2"
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED="True"
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS="{\"endpointCredentials\": [{\"endpoint\":\"${ADO_URL}\", \"username\":\"${ADO_USER}\", \"password\":\"${ADO_TOKEN}\"}]}"
RUN curl -L https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | sh
ENV PATH="${PATH}:/root/.nuget/plugins/netcore/CredentialProvider.Microsoft"
But when I run the Register-PSRepository
command I get these errors
Register-PSRepository `
-Name "PSNuGet" `
-SourceLocation "https://pkgs.dev.azure.com/company/_packaging/PSNuGet/nuget/v2" `
-PublishLocation "https://pkgs.dev.azure.com/company/_packaging/PSNuGet/nuget/v2" `
-InstallationPolicy Trusted
Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.401
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet--V does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet--V does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet--V does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet--V does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
PS /azp> Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet--V does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet--V does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
The plugin does seem to work by itself in that its able to find the credentials with this command
dotnet ~/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll -Uri "https://pkgs.dev.azure.com/company/_packaging/PSNuGet/nuget/v2" -Verbosity Debug
If I register the package source and then attempt to install a module I get similar errors
What am I missing here?
For PowerShellGet, you need to pass the cred object to the install command each time. For PSResourceGet (the new version), we are working with the PowerShell folks to support credential providers here. Until then, there is the SecretManagement and SecretStore modules.
This issue has had no activity in 90 days. Please comment if it is not actually stale.
You've run into this bug that I reported quite a while ago: Credential Provider Not Found at Default Path on Linux
To make this work you need to add the cred provider DLL to the NUGET_PLUGIN_PATHS
environment variable.
if(-not (Test-Path $Profile)) { New-Item $Profile -Type File -Force }
Add-Content $Profile '','','$env:NUGET_PLUGIN_PATHS = "$($env:HOME)/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll"'