Why doesn't this Octopus Channel Rule match this package? - nuget

Here are sample version numbers for Nuget packages:
1.1.9-version3
1.1.8-version3
1.1.7-version3
Here are the channel rules for a Channel titled "Version3":
Version Range: [1.1.1-2.0.0]
Tag: version3
I can't make it any simpler - why are these packages not matching the channel rule? Even removing the version range doesn't seem to make any difference.

As per the Nuget versioning syntax, a range is defined by a comma-separator, the hyphen is for defining the pre-release tag.
Your version range should be [1.1.1,2.0.0]. The tag should be correct.

Related

NuGet version range - always get the package with the highest revision number

I have declared the following package reference
<PackageReference Include="Abc.Defg" Version="9.9.5.*" />
With the desire that it should pick exactly a version 9.9.5 followed by the highest revision number it can find eg. 9.9.5.1234
Any package that doesn't start with 9.9.5. should be invalid eg. 9.9.6.0 or 9.9.4.0
I am getting the following message when I call nuget CLI command nuget restore but fail to understand how exactly to fix the warning and still get my desired result
WARNING: NU1604: Project dependency Abc.Defg does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
FYI, in case it makes a difference, the package version numer isn't declared directly as shown above but instead it is declared in a Directory.Build.props as a Property.
<MyVersion>9.9.5.*</MyVersion>
Which is than used as the following
<PackageReference Include="Abc.Defg" Version="$(MyVersion)" />
Is it possible to fix this with only one version number or do I need to change it to something like this
[9.9.5,9.9.6)
Which, if I am correct, translates to include 9.9.5.0 (0 can be omitted) and everything up to exclusively 9.9.6, so from 9.9.5.0 till 9.9.5.65534 should be valid.
The 9.9.5.* version extends the version range not just up, but down as well.
Lower version numbers that match this wildcard version constraint may not have the required "Abc.Defg" dependency.
The lower version number may need to be set to a version that covers this dependency, perhaps ...
(9.9.5.4, 9.9.5.*)

NuGet Packager with version using build number, adding -beta

My goal is to deploy NuGet packages (to in-house Nuget server) that auto-increment the version based on date and last Rev, and include a -beta tag.
I am using VSTS to build and package using cake, with a build number format of $(BuildDefinitionName)_2.0.$(Date:yyMMdd)$(Rev:.r).
I have a .nuspec manifest file that specifies: $version$, and a NuGet Packager as such:
This works great. But now, I want to have the option of a NuGet packager that produces a package that is tagged as beta, and therefor show in VS NuGet Package Manager as pre-release. I can do this if I hard code the version number with "-beta" appended in the NuGet Packager:
But how can I include the -beta tag AND the the build number? I think I need to include a variable in NuGet Arguments that will return $(BuildDefinitionName)_2.0.$(Date:yyMMdd)$(Rev:.r) plus "-beta", but I'm not sure how.
I tried creating a variable (under the Variables tab) with the Build Number Format as the value, then referencing the variable in NuGet Arguments (-Version theVariable), but received as error that the variable is not supported.
I may be going about this all wrong, however my searches have not turned up any hints on how to auto-increment versions from the date, and include a -beta tag.
NuGet Packager with version using build number, adding -beta
I could reproduce your scenario on my side. In my opinion, Nuget pack task with build number doesn't support character or numbers. You may check this task:
case "byBuildNumber":
tl.debug("Getting version number from build number")
if(tl.getVariable("SYSTEM_HOSTTYPE") === "release")
{
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_AutomaticallyVersionReleases"));
return;
}
let buildNumber: string = tl.getVariable("BUILD_BUILDNUMBER");
tl.debug(`Build number: ${buildNumber}`);
let versionRegex = /\d+\.\d+\.\d+(?:\.\d+)?/;
let versionMatches = buildNumber.match(versionRegex);
if (!versionMatches)
{
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_NoVersionFoundInBuildNumber"));
return;
}
if (versionMatches.length > 1)
{
tl.warning(tl.loc("Warning_MoreThanOneVersionInBuildNumber"))
}
version = versionMatches[0];
break;
That is the reason why the field $(BuildDefinitionName) and beta could not appear in our package version when we use them in our build number.
If we specify the nuget version in the nuget arguments, but this argument could not parsing predefined variables, like $(Rev:.r).
The limitations of these two situations have caused your current issue.
The workaround to resolve this issue, is using nuget custom task with parameter -version $(Build.BuildNumber) and move the field $(BuildDefinitionName) from our Build number format, otherwise, we still receive the error the version is invalid.
So, you nuget custom looks like:
And the Build number format:
Now, you can see it works fine:
Note:
You said you using VSTS to build and package using cake, but the images you posted shows that you are using NuGet Packagertask in TFS 2015. If you are sure using TFS 2015, I am afraid above workaround will not work for you. Because the custom nuget task is not support for TFS 2015.
Hope this helps.

Nuget version restrictions

I'm using Nuget 4.3.0.4406 to pack an assembly with version 5.2.29.181212.8244-RC but I get
2018-12-12T08:44:02.8053309Z ##[error]The nuget command failed with
exit code(1) and error('5.2.29.181212.8244-RC' is not a valid version
string. Parameter name: value)
The versioning is NOT semver compliant but Nuget puts on restrictions and it's not clear which..? Does this mean Nuget not just supports SemVer but enforces it? I found this but I'm not sure what they mean with the SpecialVersion?
Basically I just want x.y.z.[date+buildid](-rc) where x.y.z are tied to a specification version so it can not be ommitted (we don't own that versioning).
Update
9.9.9.1812129999-rc works but 9.9.9.18121299999-rc and 9.9.9.9812129999-rc don't, where is this specified? (it's a numeric size limitation not a string length)
Taken from the NuGet Package Versioning Reference on Microsoft Docs:
With NuGet 4.3.0+ and Visual Studio 2017 version 15.3+, NuGet supports Semantic Versioning 2.0.0.
Certain semantics of SemVer v2.0.0 are not supported in older clients. NuGet considers a package version to be SemVer v2.0.0 specific if either of the following statements is true:
The pre-release label is dot-separated, for example, 1.0.0-alpha.1
The version has build-metadata, for example, 1.0.0+githash
For nuget.org, a package is defined as a SemVer v2.0.0 package if either of the following statements is true:
The package's own version is SemVer v2.0.0 compliant but not SemVer v1.0.0 compliant, as defined above.
Any of the package's dependency version ranges has a minimum or maximum version that is SemVer v2.0.0 compliant but not SemVer v1.0.0 compliant, defined above; for example, [1.0.0-alpha.1, ).
Of course you can find the Semmantic Versioning Specification at semver.org. I think you're especially interested in spec-item10:
Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Build metadata SHOULD be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85.
Your version would become something like x.y.z(-rc)+[date+buildid]

SPM - Package contains revisioned dependencies

I am trying to install the MongoDB swift driver using the swift package driver. I followed their instructions and installed the mongo-c-driver using home-brew. I then created a new directory and within a new project using:
swift package init --type executable
I then added the dependencies to the Package.swift file.
When trying to run any command that summonsswift package resole in the directory, i get the following error:
error: the package PackageReference(identity: "mongo-swift-driver", name: nil, path: "https://github.com/mongodb/mongo-swift-driver.git", isLocal: false) # 0.0.2 contains revisioned dependencies:
PackageReference(identity: "swift-bson", name: nil, path: "https://github.com/mongodb/swift-bson", isLocal: false) # master
PackageReference(identity: "swift-mongoc", name: nil, path: "https://github.com/mongodb/swift-mongoc", isLocal: false) # master
I made sure that everything is up to date and that the first line of the Package.swift is // swift-tools-version:4.0
I would like to know what these revisioned dependencies are, as i have not found anything useful. And how this error can be resolved.
The Swift Evolution proposal that introduced the ability to specify branches instead of revisions in SPM packages (SE-0150 says this:
While this feature [specifying branches] is useful during development, a package's dependencies should be updated to point at versions instead of branches before that package is tagged for release. This is because a released package should provide a stable specification of its dependencies, and not break when a branch changes over time. To enforce this, it is an error if a package referenced by a version-based dependency specifies a branch in any of its dependencies.
It looks like the version 0.0.2 of the parent package that you're using did not follow the rule to switch to specific versions for its dependencies and SPM doesn't allow this.
If possible, you should try to use a newer version of the parent package that fixes this issue. If a newer version doesn't exist, you may have to override the dependency and fix it yourself (I believe you can use swift package edit to do that — or fork the dependency and point to your own repo, of course.)

Meaning of the * in nuget 4.6.2

What is meaning of the * wildcard in the nuget 4.6.2
<PackageReference Include="Autofac">
<Version>*</Version>
</PackageReference>
The PackageReference documentation in turn refers to the package versioning documentation, which includes:
When using the PackageReference format, NuGet also supports using a wildcard notation, *, for Major, Minor, Patch, and pre-release suffix parts of the number. Wildcards are not supported with the packages.config format.
The documentation is a little unclear when it comes to pre-releases:
Pre-release versions are not included when resolving version ranges. Pre-release versions are included when using a wildcard (*). The version range [1.0,2.0], for example, does not include 2.0-beta, but the wildcard notation 2.0-* does.
My experience is that it will pick up pre-releases when the wildcard is after a dash, but not before.
As a worked example, at the time of writing, xunit has version 2.3.1 and 2.4.0-beta.1.build3958. Here's the results I get:
Version attribute Version installed
* 2.3.1
2.* 2.3.1
2.4.* Error
2-* 2.0.0
2.4.0-* 2.4.0-beta.1.build3958
The * is a wild card, as you specified. This means the package you're building needs some version of Autofac.