-
Notifications
You must be signed in to change notification settings - Fork 695
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
add version-suffix to P2P references for dotnet pack #1688
Conversation
This only adds the version suffix and does not really evaluate |
@dasMulli i don't see how that would be any useful to do it again as PackageVersion and PackageId are already being read by restore into the assets file. |
@rohit21agrawal the problem is that it needs a double-restore then. It should not read from the assets file to pack, that's the problem. |
The idea is if you had a logic like: <VersionPrefix>1.2.3</VersionPrefix>
<ReleaseLabel>beta2</ReleaseLabel>
<Version>$(VersionPrefix)-$(ReleaseLabel)-$(BuildNumber.PadLeft(5,'0'))</Version> (where Then |
@dasMulli / @onovotny the problem you describe can also be solved using --version-suffix ( which is the same as msbuild property
|
@rohit21agrawal not if the version itself is calculated. It's not just the suffix, but the whole version that may change. I don't have any hard-coded versions anywhere. They are all generated on-the-fly as part of the MSBuild targets. |
I believe it is dangerous to assume that all project references share the same |
@onovotny what you describe is different issue, and a much bigger task at hand. this PR fixes the problem as described by the OP. The ask was to bring back the behavior which preview2 tooling had with project.json, and this is what this PR is aiming to fix. |
This is related to and should be the same fix as NuGet/Home#4790 |
Support for a VersionSuffix to fix up versions at pack time is unrelated to allowing packages contribute to restore inputs I would say.
Reading the project to project graph and finding all of the information needed for pack again in a different for pack is non-trival. The current approach is that restore captures the dependency graph, and pack packs up everything to match that which keeps everything consistent. To solve the double restore problem restore really needs a way to load new props/targets during the restore. Currently this doesn't work due to limitations with msbuild. |
@emgarten I'm not suggesting they need to contribute restore inputs. Rather, that pack should not be reading the assets file at all since it's stale. Sometimes the version is calculated per commit. Could be time of day. Point is, the only way to get the version is to evaluate the versions during the pack step. |
/cc @AArnott |
I think the "fix" should be one of:
I believe 2 is actually okay since |
Still project A: <VersionPrefix>1.2.3</VersionPrefix>
<VersionSuffix>beta2</VersionSuffix> with a pkg ref to project B: <Version>2.0.0</Version> would then incorrectly emit a dependency on project B using |
Reading only PackageVersion again based on the project references already found in the assets file could work. PackageId would be a problem if for example the id was changed to conflict with something else in the graph. |
@emgarten I'm completely ok with not reevaluating the |
I also think Context: I ran into it while taking some time do diagnose dotnet/msbuild#2463 - the idea was that a project would generate both signed and unsigned versions based on an MSBuild property with the package id adding |
Evaluating on pack is the only way I see that issue getting fixed 😄 ExcludeRestorePackageImports protects against needing potentially endless restores, and with no one way to know you are done until the last two results are the same, along with a host of other problems such as a package adding a reference to a project inside the package to override something else. |
@dasMulli that is an interesting scenario for PackageId, I could see using that. |
It seems reasonable to directly re-evaluate these properties, which would allow git versioning to work. My main concern was re-walking projects in msbuild which is difficult since some projects are empty or do not contain the expected targets. These projects paths are in the asset file and could be used to reduce differences between restore and pack. |
512e191
to
3709146
Compare
Agreed. If you're packing a dependency tree of projects, each project will pack its own version based on the current MSBuild properties -- not the assets file. So for a referencing pack to use the assets file means you're using the wrong data. If you want the package to reference another project's package, ask the project what the version of the package will be rather than assuming some stale cache has it right. :) I understand that this PR was focused on a smaller problem. But as @dasMulli said:
I believe fixing this subset may be hazardous. Also, since fixing the full problem (NuGet/Home#4790) will also fix this one, and in what I believe is a safe way, it seems prudent to focus on fixing that issue. |
Closing based on the earlier discussion on this. |
Bug
Link: NuGet/Home#4337
Regression: No
If Regression then when did it last work: N/A
If Regression then how are we preventing it in future: N/A
Fix
Details: This fix adds the passed in version suffix to the project references if they don't already have it. These project references get added to the resulting nupkg as package references with the given version suffix.
Testing/Validation
Tests Added: Yes
Reason for not adding tests: Tests added
Validation done: Added automated functional tests, and verified locally.