Itiviti / gradle-nuget-plugin

Executes NuGet from a gradle build
Apache License 2.0
22 stars 29 forks source link

Adding version override. #18

Closed lroling8350 closed 8 years ago

lroling8350 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

gluck commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

lroling8350 commented 9 years ago

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 commented 8 years ago

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

Thx