Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to treat one lib in multi-lib repo differently (always marked as preview)? #1004

Open
egil opened this issue Nov 15, 2023 · 5 comments
Open

Comments

@egil
Copy link

egil commented Nov 15, 2023

I have a repository that includes multiple libraries. One of the libraries is experimental, so when I do a dotnet pack, I want its version to retain the preview version suffix as with unstable releases, even if the rest of the libraries does not have this.

This is my current version.json:

// https://github.com/bUnit-dev/bUnit/blob/main/version.json
{
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
  "version": "1.26-preview",
  "assemblyVersion": {
    "precision": "revision"
  },
  "nuGetPackageVersion": {
    "semVer": 2.0
  },
  "publicReleaseRefSpec": [
    "^refs/heads/stable$"
  ],
  "cloudBuild": {
    "buildNumber": {
      "enabled": true
    }
  },
  "release": {
    "branchName": "release/v{version}",
    "firstUnstableTag": "preview"
  },
  "pathFilters": [
    "./src"
  ]
}

The project I want to always be marked as experimental/preview is this: https://github.com/bUnit-dev/bUnit/blob/main/src/bunit.web.query/bunit.web.query.csproj

@AArnott
Copy link
Collaborator

AArnott commented Nov 15, 2023

The best way you can do it today is to add a src/bunit.web.query/version.json file with content like this:

{
 "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
  "version": "1.26-preview",
  "inherit": "true"
}

The inherit part keeps you from having to double up on everything. You'll still have to double up on the version number, unfortunately. But having the unique copy of the version property allows that one project to retain the -preview suffix.

@egil
Copy link
Author

egil commented Nov 15, 2023

I'm currently managing versions by doing nbgv prepare-release --versionIncrement minor at the root level. Do I need to change that with the nested version.json?

@AArnott
Copy link
Collaborator

AArnott commented Nov 15, 2023

Yes, you'd have to edit that one manually.
Not a great story, to be sure. I'm open to proposals to improve it.

@egil
Copy link
Author

egil commented Nov 15, 2023

Ok.

Just so I understand correctly, if I run dotnet pack from my stable branch with the version number in the root version.json file is 1.25, i.e. without the -preview suffix, and if I add a version.json in my "experimental" projects folder and it has the version set to 1.25-preview, will dotnet pack will create a preview package for that project?

Or so I need to override other properties too?

@AArnott
Copy link
Collaborator

AArnott commented Nov 16, 2023

Just the additional version.json file should do it. But it needs to be committed before you'll see the full effect, as normal for such a file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants