I am building and pushing nuget packages using gitlab CI. whenever the package is pushed to the nuget repository in gitlab, it appends the name of the branch.
this is my ci pipeline:
<code>.vars-readstores:
variables:
PROJECT_NAME: "EventFlow.ReadStores"
PROJECT_ROOT: "Pathway.Packages/$PROJECT_NAME"
PROJECT_PATH: "$PROJECT_ROOT/$PROJECT_NAME.csproj"
PACKAGE_VERSION: "2.0.0"
readstores-build:
image: mcr.microsoft.com/dotnet/sdk:8.0
extends:
- .vars-readstores
stage: nuget-build
before_script:
- dotnet nuget add source
script:
- dotnet restore $PROJECT_PATH
- dotnet build $PROJECT_PATH -c Release
- dotnet pack $PROJECT_PATH -c Release
artifacts:
paths:
- $PROJECT_ROOT/bin/Release/*.nupkg
readstores-push:
image: mcr.microsoft.com/dotnet/sdk:8.0
extends:
- .vars-readstores
stage: nuget-push
dependencies:
- readstores-build
script:
- |
dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
echo "Pushing package to registry."
ORIGINAL_PACKAGE=$(ls $PROJECT_ROOT/bin/Release/*.nupkg)
mv "$ORIGINAL_PACKAGE" "$PROJECT_ROOT/bin/Release/${PROJECT_NAME}.${PACKAGE_VERSION}.nupkg"
dotnet nuget push "$PROJECT_ROOT/bin/Release/*.nupkg" --source gitlab
when: manual
</code>
<code>.vars-readstores:
variables:
PROJECT_NAME: "EventFlow.ReadStores"
PROJECT_ROOT: "Pathway.Packages/$PROJECT_NAME"
PROJECT_PATH: "$PROJECT_ROOT/$PROJECT_NAME.csproj"
PACKAGE_VERSION: "2.0.0"
readstores-build:
image: mcr.microsoft.com/dotnet/sdk:8.0
extends:
- .vars-readstores
stage: nuget-build
before_script:
- dotnet nuget add source
script:
- dotnet restore $PROJECT_PATH
- dotnet build $PROJECT_PATH -c Release
- dotnet pack $PROJECT_PATH -c Release
artifacts:
paths:
- $PROJECT_ROOT/bin/Release/*.nupkg
readstores-push:
image: mcr.microsoft.com/dotnet/sdk:8.0
extends:
- .vars-readstores
stage: nuget-push
dependencies:
- readstores-build
script:
- |
dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
echo "Pushing package to registry."
ORIGINAL_PACKAGE=$(ls $PROJECT_ROOT/bin/Release/*.nupkg)
mv "$ORIGINAL_PACKAGE" "$PROJECT_ROOT/bin/Release/${PROJECT_NAME}.${PACKAGE_VERSION}.nupkg"
dotnet nuget push "$PROJECT_ROOT/bin/Release/*.nupkg" --source gitlab
when: manual
</code>
.vars-readstores:
variables:
PROJECT_NAME: "EventFlow.ReadStores"
PROJECT_ROOT: "Pathway.Packages/$PROJECT_NAME"
PROJECT_PATH: "$PROJECT_ROOT/$PROJECT_NAME.csproj"
PACKAGE_VERSION: "2.0.0"
readstores-build:
image: mcr.microsoft.com/dotnet/sdk:8.0
extends:
- .vars-readstores
stage: nuget-build
before_script:
- dotnet nuget add source
script:
- dotnet restore $PROJECT_PATH
- dotnet build $PROJECT_PATH -c Release
- dotnet pack $PROJECT_PATH -c Release
artifacts:
paths:
- $PROJECT_ROOT/bin/Release/*.nupkg
readstores-push:
image: mcr.microsoft.com/dotnet/sdk:8.0
extends:
- .vars-readstores
stage: nuget-push
dependencies:
- readstores-build
script:
- |
dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
echo "Pushing package to registry."
ORIGINAL_PACKAGE=$(ls $PROJECT_ROOT/bin/Release/*.nupkg)
mv "$ORIGINAL_PACKAGE" "$PROJECT_ROOT/bin/Release/${PROJECT_NAME}.${PACKAGE_VERSION}.nupkg"
dotnet nuget push "$PROJECT_ROOT/bin/Release/*.nupkg" --source gitlab
when: manual
this is the metadata of .csproj file
<code><Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<PackageId>EventFlow.ReadStores</PackageId>
<Version>2.0.0</Version>
</PropertyGroup>
</code>
<code><Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<PackageId>EventFlow.ReadStores</PackageId>
<Version>2.0.0</Version>
</PropertyGroup>
</code>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<PackageId>EventFlow.ReadStores</PackageId>
<Version>2.0.0</Version>
</PropertyGroup>