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

new - Token replacement with in nuspec should more closely match nuget #2100

Open
asears opened this issue Aug 13, 2020 · 3 comments
Open

new - Token replacement with in nuspec should more closely match nuget #2100

asears opened this issue Aug 13, 2020 · 3 comments

Comments

@asears
Copy link

asears commented Aug 13, 2020

What You Are Seeing?

Within the scaffolded .nuspec template generated by a command such as choco new -n bob, there are some tokens for replacement. Since choco uses nuget pack, I was able to successfully replace the default token REPLACE with $version$ and remove the need to edit/substitute the file.

What is Expected?

  • Editing or token-substitution should be handled by the build tooling.
  • Tokens should be named for ease of replacement
  • Tokens should follow nuspec standards
  • Command-line should be used for all steps in pipeline

Should the default choco new command scaffold a valid nuspec with proper tokens, and verify on pack that all tokens are set?
This might require a feature flag to ensure backwards compatibility in builds and updates to tutorials and help.

https://docs.microsoft.com/en-us/nuget/reference/nuspec#replacement-tokens

There is some variations between nuspec and csproj behavior, not sure if fixed.
NuGet/Home#1795

I got here from following the tutorial
https://chocolatey.org/courses/creating-chocolatey-packages/nuget-packages-and-nuspec

How Did You Get This To Happen? (Steps to Reproduce)

choco new -n bob
choco pack -build .\bob\bob.nuspec --outputdirectory .\build --version=0.0.1-alpha

Output Log

Chocolatey v0.10.15
'__REPLACE__' is not a valid version string.
Parameter name: version
Full Log Output

PLACE LOG CONTENT HERE - WE NEED _ALL_ DETAILED OUTPUT BASED ON THE ABOVE TO BE ABLE TO PROVIDE SUPPORT (YOU WILL FIND THAT IN THE $env:ChocolateyInstall\logs\chocolatey.log between the `=====`)

@ferventcoder
Copy link
Member

As long as we have the understanding that while Chocolatey builds on NuGet, they are not one and the same and there are likely going to be differences between how the two behave, I think this could be a good change indeed.

@ferventcoder ferventcoder added this to the 0.10.19 milestone Aug 22, 2020
@ferventcoder ferventcoder changed the title Token replacement with choco new generated .nuspec new - Token replacement with choco new generated .nuspec Aug 22, 2020
@ferventcoder ferventcoder changed the title new - Token replacement with choco new generated .nuspec new - Token replacement with in nuspec should more closely match nuget Aug 22, 2020
@ferventcoder
Copy link
Member

Updated the title, I think that makes sense. Thoughts?

@ferventcoder ferventcoder modified the milestones: 0.10.19, 0.10.x Apr 14, 2021
@vexx32 vexx32 modified the milestones: 0.11.x, Future, Future_ Apr 1, 2022
@gep13
Copy link
Member

gep13 commented Dec 20, 2022

Looking into this a little bit, using a nuspec with the following:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
  <metadata>
    <id>bob</id>
    <version>$version$</version>
    <title>bob (Install)</title>
    <authors>__REPLACE_AUTHORS_OF_SOFTWARE_COMMA_SEPARATED__</authors>
    <tags>bob SPACE_SEPARATED</tags>
    <summary>__REPLACE__</summary>
    <description>__REPLACE__MarkDown_Okay </description>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
  </files>
</package>

If you run choco pack you get the following output:

The replacement token 'version' has no value.

And using the following nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
  <metadata>
    <id>bob</id>
    <version>__REPLACE__</version>
    <title>bob (Install)</title>
    <authors>__REPLACE_AUTHORS_OF_SOFTWARE_COMMA_SEPARATED__</authors>
    <tags>bob SPACE_SEPARATED</tags>
    <summary>__REPLACE__</summary>
    <description>__REPLACE__MarkDown_Okay </description>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
  </files>
</package>

And then you run choco pack you get the following output:

'__REPLACE__' is not a valid version string.
Parameter name: version

So in both of these places, the output is similar.

The difference comes in when you run the command:

choco pack --version 1.2.3

For the first nuspec file, a file called bob.1.2.3.nupkg is created. However, with the second nuspec file, you once again get the output:

'__REPLACE__' is not a valid version string.
Parameter name: version

We should have better handling in this area, so that either one of two things is changed:

  1. The default template for a nuspec is changed to use the $version$ nomenclature
  2. If --version is passed in, the value that is currently contained within the version XML element is replaced, regardless of whether it is currently a valid version number or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants