-
Notifications
You must be signed in to change notification settings - Fork 650
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
Project Nuspec References #1286
Comments
My team hit the same issue. Here's what appears to be happening: When NuGet restores a "vs2017 light-weight" project it generates the
When I attempted to work-around by setting ExcludeRestorePackageImports. Before either the So there's two problems;
I attempted a second work-around; Importing the package import targets directly from the <Import Project="$(UserProfile)\.nuget\packages\gitversiontask\4.0.0-beta0012\buildMultiTargeting\GitVersionTask.targets" Condition=" '$(ExcludeRestorePackageImports)'=='true' " /> Obviously this assumes the location of the At this point I can't see a way to use a NuGet package to control the version of a project that is correctly reflected when that project is referenced by another. |
This is currently an issue tracked against NuGet: NuGet/Home#4790 @AArnott documents a workaround for his "NerdBank.GitVersioning" project under the issue tracking the problem; dotnet/Nerdbank.GitVersioning#113 |
Since a workaround exists and this is a bug in NuGet, I'm not sure there's much we can do in GitVersion? Can this be closed? |
According to the nuget 4790 issue this problem has been resolved in vs 15.6 but I tried on the latest version of visual studio (15.6.6 with nuget package manager 4.6.0) and the references are still incorrectly 1.0.0 if I use gitversion. I tested using NerdBank.GitVersioning and the version is correctly being set in the nuspec files without any workarounds. I would normally switch over to something that works but we have integrated gitversions tag/branching strategy into our release cycle (which I prefer over NerdBanks strategy) |
For reference, here is the same project as I attached above (which still doesn't work) but with the updated NerdBank reference (which does work): Building using vs 15.6.6 will generate the correct dependency versions |
Yes, VS 15.6 fixed the issue, but NB.GV still had a change to make to "opt in" to the new supported feature of 15.6. GitVersion may still need to make a similar change. |
Thanks for confirming AArnot. I noticed you’d asked everyone to upgrade to the latest to get it working. Based on there still needing a change and to respond to asbjornu, can we leave this open and find out if/when a fix can be applied to gitversion? |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions. |
I have been facing an issue with ProjectReference versions when packing nuget package over the last few days. After some investigation I've found that it seems to be a logged issue with NuGet github project but thought it may be worth posting this here to make this project aware of the discussions. The reason for notifying you is that I think the use case that GitVersion uses may be affected as well. Here are the related issues I found on the nuget github project:
NuGet/Home#5540
NuGet/Home#4337
NuGet/Home#5525
NuGet/Home#3953
Here is an outline of the issue:
Setup:
Expected behavior:
When I build the solution and pack the nuget packages (manually or as part of the build using msbuild), both projects produce a nupkg:
Looking at the content for each package, The relevant assembly and packge versions are corrrect:
Unexpected behavior:
Looking at the dependencies in ProjectA.4.3.6.nupkg, ProjectB shows as >= 1.0.0. This causes an issue when resolving the dependency (especially using prerelease versions as we do in development as part of our workflow)
Cause:
Looking into the cause of the issue, it seems to be down to the way that a project reference is handled by visual studio. When ProjectB is added as a dependency to ProjectA, it will update the project.assets.json file automatically and will only use the value specified in the version project property. If I provide a value in the version property for ProjectB, it works as expected.
Something also worth noting is that if I add ProjectB as a PackageReference, the dependency version is correct
How do I think it relates to GitVersion:
Using GitVersionTask, I don't need to specify any version information and the task will auto-generate all of the version information for the assembly and the package (great :)), but how will this affect the project.assets.json file as this file is generated into the obj folder when the projects are saved, not at compile time. It may be that the GitVersionTask will need to also update the project.assets.json file? Or hook into any solutions the links above come up with?
I appreciate that this isn't directly a GitVersion issue but looking at some of the suggestions about using project variables (one suggestion was to add a PackageVersion to each ProjectReference) I think this may be relevant to know about new properties relating to versions so that the GitVersionTask can also update these values on compile.
Also, if anyone has a suggestion about how I can get around this for the moment - besides having to add a hard version each time - that would be great? I've tried setting the version parameter to the SemVer variable but as the project.assets.json file is generated before compiling, it doesn't have an effect.
Here is a test project showing the issue:
ProjectReference.zip
The text was updated successfully, but these errors were encountered: