adamralph / bau

The C# task runner
MIT License
152 stars 17 forks source link

Specify version in pack command to eliminate need for nuspec rewrite #218

Closed eatdrinksleepcode closed 9 years ago

eatdrinksleepcode commented 9 years ago

The "pack" task of the build currently rewrites all of the nuspecs in order to include the generated version number. We can avoid the need to rewrite the nuspecs by specifying the version as an argument to the NuGet pack command instead.

eatdrinksleepcode commented 9 years ago

CI failure is the Xunit race condition we have seen before. Is there a way for me to retrigger the build without rebasing the branch?

adamralph commented 9 years ago

@eatdrinksleepcode unfortunately this won't work. The reason for nuspec rewrite is that the version number of the dependencies needs to be specified as well. E.g. Bau.Exec depends on Bau, and if we are building version 0.1.0, then Bau.Exec needs to depend on Bau 0.1.0. You'll notice that, without the rewrite, Bau.Exec ends up depending on Bau 0.0.0.

There are a few other projects which do something very similar in their build scripts, e.g. https://github.com/NancyFx/Nancy/blob/a8841e0c33d5ef9169f874da0eba7bcea4d7f1ca/rakefile.rb#L116-L148

Incidentally, one of the ideas I have for Bau.NuGet is to wrap up all this re-writing in a custom task.

eatdrinksleepcode commented 9 years ago

Ah, yeah I missed that. I was wondering why the MSBuild and NuGet projects were both specifying Version with the command line switch and core wasn't :)

It's unfortunate that all of this nuspec rewriting is the only way to achieve these linked version numbers. It makes the build script very messy. Wrapping it into a task will help, but I still can't help feeling that there should be a better way.

adamralph commented 9 years ago

There should definitely be a better way. A very simple way to achieve it is to use the version passed in with -Version to replace all occurrences of $version$ in the nuspec. However, this is not how replacement tokens work in nuget.exe (at least the last time I checked).