Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Actions Workflow - Published Nuget Package Always marked as pre-release

I am publishing a Nuget package from a GitHub Actions Workflow (.yml file listed below) to GitHub Packages.

C# Project file PropertyGroup:

As shown below the project's.csproj file does not contain a value for VersionSuffix:

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <LangVersion>latest</LangVersion>
    <VersionPrefix>1.4.0</VersionPrefix>
    <Version>1.4.0</Version>
    <PackageVersion>1.4.0</PackageVersion>
    <VersionSuffix></VersionSuffix>
    <InformationalVersion>This is a package.</InformationalVersion>
  </PropertyGroup>

GitHub Actions Workflow .yml File:

name: Build, Pack, Publish

on: [push]

jobs:
  build:
    runs-on: windows-latest
    steps:

    - uses: actions/checkout@v1

    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 2.2.109

    - name: dotnet build
      run: dotnet build --configuration Release

    - name: Install NuGet client
      uses: warrenbuckley/Setup-Nuget@v1

    - name: Add private GitHub registry to NuGet
      run: nuget sources add -name "GPR" -Source https://nuget.pkg.github.com/Operator9/index.json -Username Operator9 -Password ${{ secrets.GITHUB_TOKEN }}

    - name: Pack
      run: dotnet pack -c Release -o out

    - name: Push generated package to GitHub registry
      run: nuget push .\out\*.nupkg -Source "GPR" -SkipDuplicate

Problem:

Everything in the workflow executes fine except the package is always considered prerelease.

Testing Method 1:

When I visit this URL my package is only listed if I change prerelease=false to prerelease=true

https://nuget.pkg.github.com/Operator9/query?q=MyPackageName&prerelease=false

Testing Method 2:

The same behavior exists from within Visual Studio Nuget Package Manager. The package is only visible if I check "Include prerelease".

like image 319
Operator9 Avatar asked Nov 06 '22 11:11

Operator9


1 Answers

There's some minimal properties that you must specify inside the <PropertyGroup> tag on your csproj.

<PackageId>AppLogger</PackageId>
<Version>1.0.0</Version>
<Authors>your_name</Authors>
<Company>your_company</Company>

Looks like you need PackageId, Authors and Company.

like image 141
Rob Avatar answered Nov 12 '22 13:11

Rob