📦 Using the Private NuGet Repository

This document explains how to configure your environment to use our private NuGet repository with Basic Authentication, restore packages, and publish new versions.

Repository URL:

1️⃣ Client Configuration (nuget.config)

To use the private repository, create a local nuget.config file inside a .nuget folder in the solution root.

🗂 1.1 Create the .nuget folder

.nuget

📄 1.2 Create .nuget/nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="PrivateRepo" value="https://nuget.itransys.eu/v3/index.json" />
  </packageSources>

  <packageSourceCredentials>
    <PrivateRepo>
      <add key="Username" value="YOUR_USERNAME" />
      <add key="ClearTextPassword" value="YOUR_PASSWORD" />
    </PrivateRepo>
  </packageSourceCredentials>
</configuration>

2️⃣ Alternative: Configure via CLI

You may configure the repository using either nuget.exe or dotnet nuget.

🛠 2.1 Using nuget.exe

nuget.exe sources Add ^
  -Name "PrivateRepo" ^
  -Source "https://nuget.itransys.eu/v3/index.json" ^
  -UserName "YOUR_USERNAME" ^
  -Password "YOUR_PASSWORD" ^
  -StorePasswordInClearText ^
  -ConfigFile ".\.nuget\nuget.config"

🛠 2.2 Using dotnet nuget

Step 1 — Create the config file:
ni .\.nuget\nuget.config

Insert:

<?xml version="1.0" encoding="utf-8"?>
<configuration></configuration>
Step 2 — Add the source:
dotnet nuget add source "https://nuget.itransys.eu/v3/index.json" ^
  --name "PrivateRepo" ^
  --username "YOUR_USERNAME" ^
  --password "YOUR_PASSWORD" ^
  --store-password-in-clear-text ^
  --configfile ".\.nuget\nuget.config"

3️⃣ Verify Configuration

dotnet restore

or:

dotnet restore --source PrivateRepo

4️⃣ Consuming Packages

dotnet add package PackageName --version 1.2.3 --source PrivateRepo

5️⃣ Publishing a Package

The server supports publishing via HTTP POST:

dotnet nuget push $packagePath -s https://nuget.itransys.eu/v3/index.json
POST https://nuget.itransys.eu/v3/publish

Form field: package

Using curl:
curl -X POST "https://nuget.itransys.eu/v3/publish" ^
  -u "YOUR_USERNAME:YOUR_PASSWORD" ^
  -F "package=@MyPackage.1.0.0.nupkg"
PowerShell script:
$packagePath = "C:\....\file.nupkg"
$url = "https://nuget.itransys.eu/v3/index.json"
$username = "USER_NAME"
$password = "USER_PASSWORD"

# Create .nuget directory if it doesn't exist
$nugetDir = [System.IO.Path]::Combine($PSScriptRoot, '.nuget')
if (-not (Test-Path $nugetDir)) {
    New-Item -ItemType Directory -Path $nugetDir | Out-Null
}

# Create the nuget.config file with the required XML content
$nugetConfigPath = [System.IO.Path]::Combine($nugetDir, 'nuget.config')
@'

# Add the private NuGet source to the nuget.config
dotnet nuget add source $url  `
  --name "PrivateRepo"  --username $username `
  --password $password `
  --store-password-in-clear-text `
  --configfile $nugetConfigPath

# Push the package to the private NuGet source
dotnet nuget push $packagePath `
    --source "PrivateRepo" `
    --configfile $nugetConfigPath

6 Priama inštalácia balíka bez pridania zdroja

Balík je možné nainštalovať priamo bez nutnosti pridávať nový zdroj do nuget.config pomocou príkazu:

dotnet add package NUGET_NAME \
  --source "https://nuget.itransys.eu/v3/index.json" \
  --username USER_NAME \
  --password USER_PASSWORD
    
List all packages:
curl.exe -u "USER_NAME:USER_PASSWORD" "https://localhost:58976/v3/query?q=*" |
    ConvertFrom-Json |
    Select-Object -ExpandProperty data |
    Select id, version


    

7 Troubleshooting

Clear NuGet cache:
nuget locals http-cache -clear
dotnet nuget locals http-cache --clear
Clear plugin cache (if VS keeps wrong credentials):
%USERPROFILE%\.nuget\plugins-cache

Delete entire folder.