Working with the NuGet registry
Create a package
Before you can publish and install a package from the NuGet registry, you will need to create one.
Select the Create button on the top navigation bar to open the Create dropdown menu.
[作成] ドロップダウンから [パッケージ] を選択します。
Select NuGet from the Package type dropdown.
Provide a package name for the package.
Select the Repository to link to dropdown and select the repository that you want to link the package to. Note: The package inherits the permissions of the repository which then grants users the same permissions to access the package.
[送信] を選択し、パッケージを作成します。
Repository admins only
If you are not the admin of the workspace but you are a repository admin, you will see the repositories that you can add a package to in the This repository section of the Create dropdown menu.
Package manager support
We support the NuGet CLI. Other package managers may work with the registry but aren’t officially supported.
認証
Publishing and installing NuGet packages from the Bitbucket package registry requires you to authenticate your client with an Atlassian API token.
To authenticate to the Bitbucket package registry within Bitbucket Pipelines, you can use BITBUCKET_PACKAGES_USERNAME and BITBUCKET_PACKAGES_TOKEN environment variables available to each step in your Bitbucket Pipeline runs. Learn more about using variables to integrate with Pipelines.
NuGet CLI
Add the following to your nuget.config file. Create a new file if one doesn’t exist.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="bitbucket" value="https://nuget.apkg.io/<workspace-slug>/index.json" />
</packageSources>
<packageSourceCredentials>
<bitbucket>
<add key="Username" value="<atlassian-email>" />
<add key="ClearTextPassword" value="<atlassian-api-token>" />
</bitbucket>
</packageSourceCredentials>
</configuration>When a NuGet package version is published through the native Bitbucket Pipelines authentication, the package version details includes the pipeline that published it. This gives teams better traceability from a published artifact back to the build that created it.
Publishing an NuGet package to the registry
Run the following command to publish to Bitbucket package registry:
dotnet nuget push <package-file> --api-key <atlassian-api-token> --source "bitbucket"Installing an NuGet package
Run the following command to install a package from Bitbucket package registry:
dotnet add package <package-name> --version <package-version>Viewing NuGet packages
The NuGet packages within your registry can be viewed from the workspace, project, and repository. You will see a list of NuGet packages along with other package types that have been published to your workspace, project, or repository.
To view the NuGet packages within the workspace, select Packages on the left sidebar. This opens the Packages page which lists all the NuGet packages within the workspace.
To view the NuGet packages within a project, select Packages on the left sidebar from within the project in which you want to see a list of NuGet packages.
To view the NuGet packages within a repository, select Packages on the left sidebar within the repository in which you want to see a list of NuGet packages.
Viewing NuGet package details
Display a package: Select the NuGet package name from the list of packages to see details about that NuGet package.
Display a version: Select the version to see details specific to that version.
Delete an NuGet package and version
In Bitbucket Cloud, you can delete either a NuGet version or the entire NuGet package, including all of its versions.
Delete an NuGet version
Only users with repository write or admin permissions can delete an NuGet version.
Deleting an NuGet version permanently removes it from Bitbucket Cloud. Once it is deleted, the version can no longer be installed and storage will be freed up soon after. To delete an NuGet version:
From the packages list view under the workspace, project or repository, select the NuGet package containing the version you want to delete.
Find the version you want to delete in the versions list view, and open the Actions menu.
Select Delete version, then select Delete.
Delete an NuGet package
Only repository admins can delete an NuGet package.
Deleting an NuGet package permanently removes it and all of its versions from Packages. Once deleted, the NuGet package and all its versions can no longer be installed and storage will be freed up soon after. To delete an NuGet package:
From the packages list view under the workspace, project or repository, select the NuGet package you want to delete.
Find the package you want to delete in the versions list view, and open the Actions menu
Select Delete package, then select Delete.
この内容はお役に立ちましたか?