microsoft / microsoft/component-detection
Nuget Detection: Nuspec Version as Variable $version$ (Dynamic Versioning)
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 553
- Forks
- 135
- Avg merge
- 20h 58m
- Merged PRs (30d)
- 6
Description
### Summary:
Component Detection does not detect nuspec version if it's a variable `$version$`
### Details:
#### How does the variable version work in Nuget ?
a .nuspec file in NuGet can have the version specified as a variable. This is typically done using a token that gets replaced with the actual version number at the time of packaging. The token for the version is $version$. This allows for dynamic versioning based on the build or release process, rather than hardcoding the version number in the .nuspec file.
Here's a simplified example of how you might specify the version in a .nuspec file using a variable:
```
ExamplePackage
$version$
ExampleAuthor
ExampleOwner
false
Example description
This release includes...
```
When you pack this NuGet package, you would replace $version$ with the actual version number. This can be done automatically by tools like MSBuild or dotnet CLI by passing the version number as a parameter or by using a .csproj file that contains the version information.
#### The component Detection generates following error log for this:
```
Version '$version$' from D:\a\_work\1\s\src\Setup.PowerShell\DDSetup.nuspec could not be parsed as a NuGet version
Version '$version$' from D:\a\_work\1\s\src\Setup.Tools\Microsoft.VisualStudio.Setup.Tools.nuspec could not be parsed as a NuGet version
Version '$version$' from D:\a\_work\1\s\src\UpdateDriver\UpdateDriver.nuspec could not be parsed as a NuGet version
Version '$version$' from D:\a\_work\1\s\src\VSInstaller.Managed\VSInstaller.nuspec could not be parsed as a NuGet version
````
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the component detection behavior with the example .nuspec files and the reported '$version$' error log. Trace how the value is parsed during NuGet detection, then add coverage for the variable form. Done means these .nuspec files no longer produce a version-parsing error while detection continues to handle concrete NuGet versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100