You have created a NuGet repository on your Repsy Open Source instance, see Creating a Private NuGet Repository. You are now ready to publish NuGet packages to your repository.
Create a .NET project
To create a class library that can be packed as a NuGet package, use the .NET CLI:
dotnet new classlib -n MyPackage
cd MyPackage
If this command is executed successfully, the .NET CLI will generate a project with a .csproj file. Make sure the project metadata in the .csproj is filled in before packing:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageId>MyPackage</PackageId>
<Version>1.0.0</Version>
<Authors>Your Name</Authors>
<Description>A sample NuGet package published to Repsy.</Description>
</PropertyGroup>
</Project>
Configure your NuGet source
Add the Repsy source to NuGet.Config in your project or solution root. This file is safe to commit to version control because it contains only the source URL, not credentials.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="repsy" value="https://<your-repsy-host>/<repo-name>/v3/index.json" />
</packageSources>
</configuration>
Replace <repo-name> with the name of your repository. https://<your-repsy-host> stands for the address of the package protocol port of your Repsy Open Source instance, for example http://localhost:9090 for a local start, see Ports and Repository URLs. There is no username in the address.
NuGet only accepts an https:// source by default. When your instance is served over plain HTTP, add allowInsecureConnections="true" to the source:
<add key="repsy" value="https://<your-repsy-host>/<repo-name>/v3/index.json" allowInsecureConnections="true" />
Store credentials in user-level config
Store your credentials in ~/.nuget/NuGet/NuGet.Config (Linux/Mac) or %appdata%\NuGet\NuGet.Config (Windows). This file is not committed to version control.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSourceCredentials>
<repsy>
<add key="Username" value="MY REPSY USERNAME" />
<add key="ClearTextPassword" value="MY REPSY PASSWORD OR DEPLOY TOKEN" />
</repsy>
</packageSourceCredentials>
</configuration>
Tip: For CI/CD pipelines, use a Deploy Token instead of your account password.
Use the username and password you sign in to the web UI with, or a deploy token in place of the password. Repsy checks only the token, so the username can be any value. A token has to be Read/Write to publish.
Pack and publish
Build and pack your project:
dotnet pack --configuration Release
Then push the generated .nupkg file to Repsy:
dotnet nuget push ./bin/Release/*.nupkg --source repsy --api-key any
When your credentials are in NuGet.Config, the client authenticates with them and the value of --api-key does not matter; if you leave the flag out, dotnet warns that no API key was provided and pushes anyway. Without credentials in a configuration file, pass a Read/Write deploy token as the API key: --api-key <deploy-token>. An account password is refused there with 401.
Congratulations, you have created and published a NuGet package to your repository! You can now install your package into any .NET project.
Check the Result
Open your NuGet repository in the web UI to see the package and its versions. The Configure button of the repository opens a dialog with the source, the credentials and the push and install commands, filled in with the address of your repository, see Creating a Private NuGet Repository.
If the push is refused, see Publishing and Restoring NuGet Packages with the dotnet CLI. To install the package, see Installing a NuGet Package.