-
Notifications
You must be signed in to change notification settings - Fork 256
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
NuGet.SemanticVersion does not parse prerelease versions. #13408
Comments
Yes, it's ironic that this package can't parse some of its own versions. |
Hey @kfertitta When the rewrite from NuGet2 to NuGet 3 (what eventually becomes current NuGet) happened around 2015-2017, NuGet had to basically become more than VS & NuGet.exe, the functionality was integrated into the .NET SDK & MSBuild. NuGet.VisualStudio use to depend on an assembly NuGet.Core which was overloaded with functionality and made it challenging for the product to evolve. Part of those decision were to basically simplify the Visual Studio functionality, by using string/string methods for id version: https://github.com/NuGet/NuGet.Client/blob/252bbee32a839623dc9af267f950d21cde5e9497/src/NuGet.Clients/NuGet.VisualStudio/Extensibility/IVsPackageInstaller.cs#L40-L41, and deprecate legacy types: https://github.com/NuGet/NuGet.Client/blob/252bbee32a839623dc9af267f950d21cde5e9497/src/NuGet.Clients/NuGet.VisualStudio/Extensibility/IVsPackageInstaller.cs#L85-L86. Unfortunately I don't think we were thorough enough deprecate all the APIs, since we didn't add Obsolete attributes to all all types from: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.VisualStudio/LegacyTypes/. https://github.com/NuGet/NuGet.Client/tree/dev/src/NuGet.Core/NuGet.Versioning has the full versioning functionality used the hood today, but we don't expose that in Visual Studio, since as I mentioned, the majority of the VS extensibility relies on string/string. I don't expect us to port this functionality to the legacy type. For what purposes do you need to parse different versions? |
@nkolev92 , thank you for the reply. We have some pretty complex custom project systems. Our project wizards present the user with various lists of domain-specific packages from which they can choose to add to their project. It's a mini package manager in some ways, so we need basic equality comparison, sort comparison, prerelease detection, etc. Having worked on VS extension for many years, I do recognize the difficulty of maintaining some level of parity between out-of-VS functionality and the core underlying machinery, such as that in NuGet.Client. That said, with so much of the project system (CPS-based ones, such as ours) and NuGet bleeding internally into one another, we're needing more NuGet client support within VS, not less. I'm actually in the process of opening an issue to suggest adding the ability to the VS NuGet APIs to query sources ( |
Team Review: There are two options:
|
@jeffkl I'm not clear on how 1. above is an option. If an extension ships NuGet.Client packages with our extension, we'll break VS. That's the whole reason for there being a |
Then your extension would include
At runtime, the built-in NuGet functionality will use the first one and your extension will load yours. If there's ever a time where your extension is using the exact same version, the |
@jeffkl Yes, our preference would, in fact, be to go ahead and ship NuGet client packages with our extension to get the much more extensive functionality there relative to the If we're clear to use NuGet client packages within our extension by shipping them, we'll do it. |
I think redistributing the exact assembly would limit options going forward if say we wanted to tweak the VS support. A less likely to cause problems method might be to repackage (ilmerge/il-repack etc) within your assembly. I have a write-up on that in #9611. |
Thanks @nkolev92 . Indeed, we've used ilmerge in the past for such things. I think that's the best approach given the scope of what we need in our extensions is growing wrt NuGet. To facilitate reuse amongst our extensions, I think I'll create a special NuGet "metapackage" that references the |
@nkolev92 Actually, wondering if |
I haven't read the whole thread here, but I have two thought:
|
Thanks for the quick reply @AArnott . The gist of this thread, and others linked to it, is that VS extensions, such as ours, which are pretty complicated full-on custom project systems, increasingly need |
All APIs that the .NET Project System uses are in NuGet.VisualStudio and NuGet.VisualStudio.Contracts, so we don't really have any other integrations. |
As far as new additions to the APIs go, our approach is to evaluate each API individually, so we'd want to make sure we have tracking issue for the exact APIs needed (for example, we can turn this issue into something like that, but I think we'd start with an explicit list of which APIs are needed). It's worth noting that NuGet.VisualStudio and NuGet.VisualStudio.Contracts do not reference any other assemblies today, so that'd be a big departure from the current approach. |
So, seems that shipping |
That isn't what I got from @nkolev92's comment, @kfertitta. It sounds like referencing NuGet.VisualStudio and NuGet.VisualStudio.Contracts and using those APIs is fair game. |
Correct, @AArnott . Those are definitely fair game. It's just that they're pretty limited relative to what we need in our project systems. And, as reported initially in this thread, the semver parsing doesn't work properly. |
pedantic: the parsing conforms to SemVer v1, not SemVer v2 |
NuGet Product Used
Other/NA
Product Version
NuGet.VisualStudio 17.9.1
Worked before?
No response
Impact
I'm unable to use this version
Repro Steps & Context
The
NuGet.VisualStudio
package includes aSemanticVersion
type with aTryParse
method that does not accept version strings with a dot.
after any prerelease tag.For example,
SemanticVersion.TryParse("17.6.0-preview.3")
fails, whereasSemanticVersion.TryParse("17.6.0-preview-3")
succeeds. The dot in a prerelease suffix is allowed by SemVer and accepted by theSemanticVersion
type in theNuGet.Versioning
package.Unfortunately, we require semver parsing in our Visual Studio extension and must use the
NuGet.VisualStudio
package.Verbose Logs
No response
The text was updated successfully, but these errors were encountered: