You have registered and created a repository on Repsy. 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://repo.repsy.io/<username>/<repo-name>/v3/index.json" />
</packageSources>
</configuration>
Replace <username> and <repo-name> with your actual values.
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.
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
The NuGet CLI requires the --api-key flag. When your credentials are in NuGet.Config, the client authenticates with them and the value of --api-key does not matter, so you can pass any non-empty value. Without credentials in a configuration file, pass a personal access token or a deploy token with Read/Write access as the API key: --api-key <token>.
Congratulations, you have created and published a NuGet package to your repository! You can now install your package into any .NET project.