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

Integrate with Nerdbank.GitVersioning #1299

Merged
merged 37 commits into from
Jul 27, 2024
Merged

Integrate with Nerdbank.GitVersioning #1299

merged 37 commits into from
Jul 27, 2024

Conversation

scott-xu
Copy link
Collaborator

No description provided.

…his particular project needs versioning.

include package version in ThisAssembly and use nuget package version for the SSH client version. Since we define the precision of nuget package to "build", it has 3 digits. Nuget package version is unique which should be suffient.
@scott-xu scott-xu marked this pull request as ready for review January 30, 2024 14:48
@Rob-Hague
Copy link
Collaborator

I get a weird error when building this branch

1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: Nerdbank.GitVersioning.GitException: Got a com instead of a tag when opening object 1c7166a002d7633fe1595b3df4634ba0ef6e3138
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.TryGetObjectByPath(GitObjectId sha, String objectType, Stream& value)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.TryGetObjectBySha(GitObjectId sha, String objectType, Stream& value)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.<LookupTags>g__HandleCandidate|44_0(GitObjectId pointsAt, String tagName, Boolean isPeeled, <>c__DisplayClass44_0& )
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.LookupTags(GitObjectId objectId)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.Managed.ManagedGitContext.get_HeadTags()
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle..ctor(GitContext context, ICloudBuild cloudBuild, Nullable`1 overrideVersionHeightOffset)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() in D:\a\1\s\src\Nerdbank.GitVersioning.Tasks\GetBuildVersion.cs:line 240
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

@Rob-Hague
Copy link
Collaborator

I get a weird error when building this branch

It seems to be a bug in the Nerdbank package, where it does not correctly handle lightweight tags in .git/ref/tags (e.g. 2023.0.1).

In a fresh clone, the tags are in .git/packed-refs which are handled correctly, hence it passing in CI. In my local copy of the repo, the tags are in .git/ref/tags and it is assuming they are all annotated tags.

@scott-xu
Copy link
Collaborator Author

It updates the CI build number:
image

@Rob-Hague
Copy link
Collaborator

I've not forgotten about this PR, I just want to read up some more on the configuration

Copy link
Collaborator

@Rob-Hague Rob-Hague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that 2024.0.0 already has the commit info tagged to the dll (probably because of sourcelink?):

image

In that case, I am not sure if there still benefits to this change. I am not sure the release process needs to change (it seems simple enough), but as I don't make the releases I think I will have to defer to @WojciechNagorski as to whether to take this change.

version.json Outdated Show resolved Hide resolved
version.json Outdated Show resolved Hide resolved
version.json Outdated
},
"release": {
"tagName" : "{version}",
"branchName" : "master",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be e.g.

Suggested change
"branchName" : "master",
"branchName" : "release/{version}",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the curernt release is based on master branch with tag?

@scott-xu
Copy link
Collaborator Author

Not very familar with current release process, but it seems to be some manual work?

@WojciechNagorski
Copy link
Collaborator

Yes it is manual

@scott-xu
Copy link
Collaborator Author

I guess the current release process is based on https://github.com/sshnet/BuildTools and https://github.com/sshnet/SSH.NET/blob/develop/build/build.proj, am I right? @WojciechNagorski
No matter merge this PR or not, I recommend delegating the release process to appveyor

@WojciechNagorski
Copy link
Collaborator

Currently it is just dotnet pack right now.

@scott-xu scott-xu marked this pull request as draft July 26, 2024 13:25
@Rob-Hague
Copy link
Collaborator

I actually have some local changes for this, let me fix the merge and push them in

- Remove the "release" section. I don't think we will use that for now
- Remove the "cloudBuild" section. Changing the CI build number doesn't seem that useful
- In the "nugetPackageVersion" section:
  - Remove "precision". It defaults to build
  - Add "semVer"=2. This makes the package version e.g. 2024.1.1-prerelease.1 instead
    of 2024.1.1-prerelease-0001
- In "assemblyVersion" change "precision" to revision. Doesn't seem to change anything, I
  was just copying nbgv's setup: https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/version.json
- Make sure there are no '-' in the softwareversion string (change the test to a regex)
@Rob-Hague
Copy link
Collaborator

Example on a PR branch:

internal static partial class ThisAssembly {
    internal const string AssemblyConfiguration = "Release";
    internal const string AssemblyFileVersion = "2024.1.1";
    internal const string AssemblyInformationalVersion = "2024.1.1-prerelease.2+84ff4f6671";
    internal const string AssemblyName = "Renci.SshNet";
    internal const string AssemblyTitle = "SSH.NET";
    internal const string AssemblyVersion = "2024.1.1.0";
    internal static readonly global::System.DateTime GitCommitDate = new global::System.DateTime(638576102900000000L, global::System.DateTimeKind.Utc);
    internal const string GitCommitId = "84ff4f66711638341a0d856299f7a62ae4bbf38b";
    internal const bool IsPrerelease = true;
    internal const bool IsPublicRelease = false;
    internal const string NuGetPackageVersion = "2024.1.1-prerelease.2.g84ff4f6671";
    internal const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2";
    internal const string PublicKeyToken = "1cee9f8bde3db106";
    internal const string RootNamespace = "Renci.SshNet";
}

image

Example on a simulated "public" branch e.g. develop:

internal static partial class ThisAssembly {
    internal const string AssemblyConfiguration = "Release";
    internal const string AssemblyFileVersion = "2024.1.1";
    internal const string AssemblyInformationalVersion = "2024.1.1-prerelease.3+57319f736f";
    internal const string AssemblyName = "Renci.SshNet";
    internal const string AssemblyTitle = "SSH.NET";
    internal const string AssemblyVersion = "2024.1.1.0";
    internal static readonly global::System.DateTime GitCommitDate = new global::System.DateTime(638576099590000000L, global::System.DateTimeKind.Utc);
    internal const string GitCommitId = "57319f736f1d0dbf25455f121669223d8fc48893";
    internal const bool IsPrerelease = true;
    internal const bool IsPublicRelease = true;
    internal const string NuGetPackageVersion = "2024.1.1-prerelease.3";
    internal const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2";
    internal const string PublicKeyToken = "1cee9f8bde3db106";
    internal const string RootNamespace = "Renci.SshNet";
}

image

@Rob-Hague Rob-Hague marked this pull request as ready for review July 26, 2024 18:58
@Rob-Hague Rob-Hague merged commit 252c732 into sshnet:develop Jul 27, 2024
1 check passed
@Rob-Hague
Copy link
Collaborator

The appveyor nuget feed is in operation:

image

@scott-xu scott-xu deleted the nbgv branch August 5, 2024 15:17
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

Successfully merging this pull request may close these issues.

4 participants