-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Invalid order with NuGet pack leading to invalid outputs #675
Comments
Created also an issue on NuGet NuGet/Home#11617 to request for a better way to integrate auto-versioning helpers like MinVer into NuGet. |
@xoofx thanks for the detailed write up! I'm having difficulty understanding the actual behavioural problem though. Are you saying that any project which multi-targets ends up with the wrong version? If I build this test solution, it works fine: |
So, the problem is that the packaging is working fine only because the final NuGet task is still going to use the version that is computed just before if you do a verbose log of That means that the output recorded in In the details, this is the order of the target executed by msbuild:
MinVer is executed after <Target Name="_GetOutputItemsFromPack"
DependsOnTargets="_GetAbsoluteOutputPathsForPack"
Returns="@(_OutputPackItems)">
<!-- 'PackageOutputAbsolutePath' and 'NuspecOutputAbsolutePath' will be provided by '_GetAbsoluteOutputPathsForPack' target -->
<GetPackOutputItemsTask
PackageOutputPath="$(PackageOutputAbsolutePath)"
NuspecOutputPath="$(NuspecOutputAbsolutePath)"
PackageId="$(PackageId)"
PackageVersion="$(PackageVersion)"
IncludeSymbols="$(IncludeSymbols)"
IncludeSource="$(IncludeSource)"
SymbolPackageFormat="$(SymbolPackageFormat)">
<Output
TaskParameter="OutputPackItems"
ItemName="_OutputPackItems" />
</GetPackOutputItemsTask>
</Target> |
To show the problem with a HelloWorld. If you run twice pack on an HelloWorld library:
You can see that on the second run, Now, add MinVer to the HelloWorld project, tag the commit with
You can see that on the second run, it still creates the |
@xoofx thanks! That's clear now. I'll take a closer look at the details a little later. |
Hey,
Thank you for MinVer. I'm starting to use it in all my projects and it simplifies a lot what I was doing manually! 👍
Version(s)
2.5.0
Problem
I'm developing a tooling that simplifies the whole build/publish process for .NET libraries/apps on GitHub (dotnet-releaser) and I discovered a weird behavior while using MinVer on a multi-targeting version (It seems that it doesn't affect packages with only one target framework).
I'm calling msbuild directly with a special logger from which I can extract results from msbuild and I discovered that the version used to name output files in msbuild with MinVer when packing is wrong.
For example, below, you have a screenshot of msbuild log:
It is supposed to create the package
Tomlyn.0.11.0.nupkg
and the pack command does it, but actually, when you look in the details, msbuild will think that it needs to generateTomlyn.1.0.0.nupkg
and will always re-run even if you build it just before.Reason is that the file output is calculated in the target
_GetOutputItemsFromPack
which called by_CalculateInputsOutputsForPack
(code here) but MinVer runs only just beforeGenerateNuspec
(as you can see in the screenshot above), but not before_GetOutputItemsFromPack
.Expected behaviour
NuGet msbuild tasks should get the version calculated from MinVer in order to correctly compute output packages.
Actual behaviour
NuGet is originally thinking that the version is
1.0.0
instead the version calculated by MinVer. If you run multiple times NuGet pack with MinVer, it will always have to repack the package thinking that it doesn't exist (because 1.0.0 is not created in the end)Workarounds
No great workaround as I would have to make my tooling MinVer aware to force MinVer to insert before
_GetOutputItemsFromPack
.Fix Suggestion
Add a msbuild dependency to
_GetOutputItemsFromPack
instead of onlyGenerateNuSpec
.Hacking MinVer locally and it is now correctly generating the correct versions:
I will make a PR with this suggestion fix.
The text was updated successfully, but these errors were encountered: