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

Nuget Detection: Nuspec Version as Variable $version$ (Dynamic Versioning) #1191

Open
RushabhBhansali opened this issue Jul 5, 2024 · 0 comments
Labels
detector:nuget The NuGet detector type:feature Feature (new functionality)

Comments

@RushabhBhansali
Copy link
Contributor

RushabhBhansali commented Jul 5, 2024

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:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>ExamplePackage</id>
    <version>$version$</version>
    <authors>ExampleAuthor</authors>
    <owners>ExampleOwner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Example description</description>
    <releaseNotes>This release includes...</releaseNotes>
  </metadata>
</package>

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 
@RushabhBhansali RushabhBhansali added detector:nuget The NuGet detector type:feature Feature (new functionality) labels Jul 5, 2024
@RushabhBhansali RushabhBhansali changed the title Nuget Detection: Nuspec Version as Variable $version$ Nuget Detection: Nuspec Version as Variable $version$ (Dynamic Versioning) Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detector:nuget The NuGet detector type:feature Feature (new functionality)
Projects
None yet
Development

No branches or pull requests

1 participant