HOWTO: Create and Publish Conan Packages to a Private Repository in ProGet
ProGet lets you set up private repositories for your Conan recipes/packages, allowing you to upload them from a local source, store, and install them internally.
In this article we will cover how to create a "Feed" in ProGet to act as a private Conan package repository, as well as covering how to create, publish, and install packages from this feed.
Step 1: Create a New Feed
First, we will create a feed to host your Conan packages. In ProGet, select "Feeds" and "Create New Feed". Then, select "Conan Packages" under "Developer Libraries".
Then select "No Connectors (Private packages only)" as we will be creating a private feed. Now name your feed. For this example we will call it internal-conan
.
You will then see options that relate to ProGet's Vulnerability Scanning and Blocking features, however as they are only for users looking to use third party packages, leave these boxes unchecked and select [Set Feed Features]. You will then be redirected to the newly created, empty internal-conan
feed.
Step 2: Create Your Conan Package
Next, we will create a Conan package. You can follow the tutorial in the official Conan documentation to learn about creating these in more detail.
Navigate to your project directory, and create a file named conanfile.py
. This will contain content similar to the following example:
from conan import ConanFile
from conan.tools.files import copy
import os
class MyPackage(ConanFile):
name = "mypackage"
version = "1.2.3"
settings = "os", "arch", "compiler", "build_type"
description = "A simple Conan package example"
license = "MIT"
author = "Your Name <youremail@example.com>"
url = "https://example.com"
topics = ("example", "conan", "tutorial")
def package(self):
src = os.path.join(self.source_folder, "src")
dst = os.path.join(self.package_folder, "include")
copy(self, "*", src=src, dst=dst)
def package_info(self):
self.cpp_info.includedirs = ["include"]
Then create a sub directory named src
and place your project files here.
Finally, run the following command to export your package to the local cache:
$ conan create . --name=mypackage --version=1.2.3
Step 3: Create an API Key
Now you will need to create an API Key to let your Conan client authenticate to the internal-conan
feed. This will let you publish and install packages from that feed.
While you can authenticate with a ProGet username and password, we highly recommend using an API Key instead. For that, use api
as the username and the API Key as the password.
When creating an API Key, fill in the fields by selecting "Feeds (Use Certain Feeds)" as the "Feed Type" and selecting the internal-conan
feed. Then set the API key. You can use any alphanumeric sequence, or just leave it blank to autogenerate one. Ensure that the "View/Download" and "Add/Repackage" boxes are checked, and then select "Save".
Step 4: Configure Your Conan Feed as a Remote
To upload packages to internal-conan
feed from your Conan V2 client (as well as install any packages uploaded to it), you will need to add it as a remote using the conan remote add
command.
$ conan remote add internal-conan https://proget.corp.local/conan/internal-conan/
If you are using a self-signed certificate with ProGet, you will also need to add the --insecure
argument:
$ conan remote add internal-conan https://proget.corp.local/conan/internal-conan/ --insecure
Recommended: Removing Conan Center as a Remote
By default the Conan client will have Conan Center configured as a remote unless you explicitly disable it. We recommend disabling Conan Center to make sure all requests are exclusively made to your internal-conan
feed, and developers aren't installing packages directly from Conan Center.
$ conan remote disable conancenter
Step 5: Upload Your Package to ProGet
To publish your Conan package to your internal-conan
ProGet feed, use the conan upload
command:
$ conan upload -r internal-conan my_package
Packages can only be uploaded to ProGet using the Conan CLI due to the complexity of the Conan package model
Your package will then be uploaded to ProGet:
Step 6: Using your Conan Feed as a Remote to Install Packages
Before installing packages you will need to configure a build profile in your Conan V2 client. You can create a default profile with the conan profile detect
command or specify your own profile with --profile:build=«myprofile»
To install Conan packages from your internal-conan
feed, use the install
command:
$ conan install --requires=mypackage/1.2.3 -r=internal-conan
(Optional) Installing Packages from an Authenticated Feed
By default, your internal-conan
feed is configured so that packages can be installed from it anonymously. However, if you have set up authentication for your feed, you will need to authenticate to it. You can use a ProGet username
and password
, however we highly recommend Creating a ProGet API Key for authentication, using api
as the username and the API key as the password.