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

Adding version override. #18

Closed
wants to merge 1 commit into from
Closed

Adding version override. #18

wants to merge 1 commit into from

Conversation

lroling8350
Copy link

I need the ability to override the version to be different than either the project or nuspec version. This allows me to use a custom version which allows us to programmatically create snapshot versions before release.

@gluck
Copy link
Contributor

gluck commented Jul 28, 2015

Hi !

Supposedly you can already do the same with:

nuget {
    nuspec {
        metadata() {
            delegate.version '1.0.0'
        }
    }
}

That doesn't work out for you ?

@gluck
Copy link
Contributor

gluck commented Jul 28, 2015

Scratch that, I missed the "different than the nuspec version" part, that's what I get for commenting too early :)

@gluck
Copy link
Contributor

gluck commented Jul 28, 2015

I didn't know you could upload packages to nuget with a version different than the nuspec one, may I ask how it works and how you manage snapshots like that ?

@lroling8350
Copy link
Author

Our gradle build sees that it is a non release build and creates a unique version by appending a timestamp to the form of "-SNAPSHOT-" which is then used at the nuget version. Since nuspec is simply a template to build the nupkg we would rather configure the version outside of the nuspec otherwise we have to handle updates to the nuspec in version control which is more complicated than specifying a version in gradle plugin. Note that this means the nuspec version doesn't have to match the assembly version in the csproj file.

@gluck
Copy link
Contributor

gluck commented Jul 28, 2015

Ok, but then in the nupkg, the version from your nuspec is no longer there (only remains the version you passed as argument) no ?

@lroling8350
Copy link
Author

Any fields you specify on the command that override a value in the nuspec, such as version, are written into the nuspec stored in the nupkg. So the version shows up correctly in the nupkg. I don't care that the version in the nupkg, which is the version passed in the command line, differs from the nuspec in source control because that is maintained by the gradle build.

@gluck
Copy link
Contributor

gluck commented Jul 28, 2015

But then in that case my earlier comment is still valid, if you do:

nuget {
    nuspecFile = 'foo.nuspec'
    nuspec {
        metadata() {
            delegate.version '1.0.0'
        }
    }
}

then it'll achieve the same, no ?

@lroling8350
Copy link
Author

I am rather new to groovy but unless I am mistaken the method getNuspec looks for a nuspecFile and if it exists returns this files content and does not look at any information in the nuspec provided in the gradle build. I also tried testing this and the version used is the one from the nuspecFile.

@gluck
Copy link
Contributor

gluck commented Jul 28, 2015

Right, the entire nuspec block is ignored if you provide a file, my bad.
Shouldn't we instead change that and make it so that when you specify both, it takes the nuspec file as a base and enriches it with the provided block ?
(if it can be achieved) ?

@lroling8350
Copy link
Author

I'll take a look into that, I would also like a way to modify the in gradle nuspec after evaluation.

@lroling8350
Copy link
Author

My one concern though is when i want to call nuget directly on a csproj but change the version. That would get interesting because in that case a nuspec doesn't exist at all.

@gluck
Copy link
Contributor

gluck commented Dec 23, 2015

That's now implemented, I'll close this PR !

Thx

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

Successfully merging this pull request may close these issues.

2 participants