Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working in Linux PowerShell with Register-PSRepository on a Ubuntu docker image #510

Open
7wingfly opened this issue Aug 19, 2024 · 1 comment
Labels
external Something is wrong in one of our external dependencies. work-around Something isn't working, but there is a known work-around

Comments

@7wingfly
Copy link

7wingfly commented Aug 19, 2024

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.

image

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

image

If I register the package source and then attempt to install a module I get similar errors

image

What am I missing here?

@7wingfly 7wingfly changed the title Not working in PowerShell with Register-PSRepository Not working in Linux PowerShell with Register-PSRepository on a Ubuntu docker image Aug 19, 2024
@embetten
Copy link
Contributor

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.

@embetten embetten added work-around Something isn't working, but there is a known work-around external Something is wrong in one of our external dependencies. labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Something is wrong in one of our external dependencies. work-around Something isn't working, but there is a known work-around
Projects
None yet
Development

No branches or pull requests

2 participants