Содержание

nuget

Зарегистрировать источник:

nuget.exe sources Add -Name "NugetName" -Source "https://nexus.domain.com/repository/nuget-group/index.json" -Username "loginNuget" -Password "passowordNuget"

Удалить источник:

nuget.exe sources Remove -Name "NugetName"

Загрузить и установить пакет:

nuget.exe install IDScanNet.Validation.Shared -source "https://nexus.domain.com/repository/nuget-group/index.json" -PreRelease -Version 1.2110.27.1-dev -OutputDirectory C:\test

https://docs.nuget.org/docs/reference/command-line-reference

nuget.config

https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

Распространение

Через NuGet.Config

Через NuGet.Config

Для WSL (powershell)

$NUGET=(Get-Content "$env:AppData\NuGet\config\COMPANY.Config")
wsl mkdir -p `~/.nuget/NuGet; wsl echo "$NUGET" `> `~/.nuget/NuGet/NuGet.Config

Для Docker

Добавить в Dockerfile:

ARG NUGET
RUN mkdir -p ~/.nuget/NuGet; echo "$NUGET" > ~/.nuget/NuGet/NuGet.Config

и запускать/собирать с передачей аргумента

для Windows (powershell):

$NUGET=(Get-Content "$env:AppData\NuGet\config\COMAPNY.Config") docker build --build-arg NUGET=$NUGET

для Linux:

docker build --build-arg NUGET="$(cat ~/.nuget/NuGet/NuGet.Config)"

Через переменные

Через переменные

Задать переменные: для windows (powershell)

[Environment]::SetEnvironmentVariable('NUGETHOST', 'https://registry.domain.net/repository/nuget-group/index.json', 'User')
[Environment]::SetEnvironmentVariable('NUGETUSER', 'nuget-user','User')
[Environment]::SetEnvironmentVariable('NUGETPASS', 'nuget-password','User')

для linux:

printf "\nif [ -f \"\$HOME/.nuget_env\" ]; then . \"\$HOME/.nuget_env\"; fi\n" >> ~/.profile
echo "export NUGETHOST='https://registry.domain.net/repository/nuget-group/index.json'" > ~/.nuget_env
echo "export NUGETUSER='nuget-user'" >> ~/.nuget_env
echo "export NUGETPASS='nuget-password'" >> ~/.nuget_env
. $HOME/.nuget_env

Для WSL (powershell)

wsl dotnet nuget add source "$env:NUGETHOST" -n registry.domain.net -u "$env:NUGETUSER" -p "$env:NUGETPASS" --store-password-in-clear-text

Для docker

Добавить в Dockerfile:

ARG NUGETHOST
ARG NUGETUSER
ARG NUGETPASS
RUN set -ex;\
  if [ "${NUGETHOST}" ]; then\
    dotnet nuget list source;\
    dotnet nuget list source | grep registry.domain.net && dotnet nuget remove source registry.domain.net;\
    dotnet nuget add source ${NUGETHOST} -n registry.domain.net -u ${NUGETUSER} -p ${NUGETPASS} --store-password-in-clear-text;\
    dotnet nuget list source;\
  fi

и запускать/собирать с передачей аргумента

для Windows (powershell):

--build-arg NUGETHOST="$env:NUGETHOST" --build-arg NUGETUSER="$env:NUGETUSER" --build-arg NUGETPASS="$env:NUGETPASS"

для Linux:

--build-arg NUGETHOST="$NUGETHOST" --build-arg NUGETUSER="$NUGETUSER" --build-arg NUGETPASS="$NUGETPASS"


Очистка

Директории хранения кэша и пакетов:

C:\Users\$env:USERNAME\.nuget\packages
C:\Users\$env:USERNAME\AppData\Local\NuGet\v3-cache

Очистка кэша:

dotnet nuget locals http-cache --clear
#или
nuget locals http-cache -clear

Очистка глобального каталога пакетов:

dotnet nuget locals global-packages --clear
#или
nuget locals global-packages -clear

https://docs.microsoft.com/ru-ru/nuget/consume-packages/managing-the-global-packages-and-cache-folders

dotnet

Зарегистрировать источник:

dotnet add sources "https://nexus.domain.com/repository/nuget-group/index.json" -n "NugetName" -u "loginNuget" -Password "passowordNuget" --store-password-in-clear-text

Удалить источник:

dotnet nuget remove source "NugetName"

PackageManagement

Установить:

Install-Module -Name PackageManagement -Force

Перед запуском выполнить:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Проблемы:
Не регистрирует новые источники https://github.com/OneGet/oneget/issues/506

Зарегистрировать источник:

$login="loginNuget"
$password="passwordNuget" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object system.Management.Automation.PSCredential($login,$password)
Register-PackageSource -name IDScan.net -Location https://nexus.domain.com/repository/nuget-group/index.json -Credential $credential -ProviderName NuGet

https://docs.microsoft.com/en-us/powershell/module/packagemanagement/

Alpine linux

apk add --no-cache curl mono --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing && \
    apk add --no-cache --virtual=.build-dependencies ca-certificates && \
    cert-sync /etc/ssl/certs/ca-certificates.crt && \
    apk del .build-dependencies && \
    curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe && \
    alias nuget="mono /usr/local/bin/nuget.exe"

https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools