Skip to content
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

Augment PackageReference with InstallPath metadata #4064

Closed
kzu opened this issue Dec 7, 2016 · 4 comments
Closed

Augment PackageReference with InstallPath metadata #4064

kzu opened this issue Dec 7, 2016 · 4 comments
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue Resolution:Question This issues appears to be a question, not a product defect
Milestone

Comments

@kzu
Copy link

kzu commented Dec 7, 2016

Some packages may need to consume tools provided by other packages. One concrete example: ilmerge (the nuget package). That package provides the ILMerge.exe tool, but no MSBuild target to expose its location for other nuget packages to consume (or the project itself).

To avoid hardcoding versions (i.e. $(NuGetPackageRoot)ILMerge\2.14.1208\tools\ILMerge.exe) when invoking the tool, it would be great if the NuGet targets automatically augmented the PackageReferece with the determined version's install path, so that a consuming project could do, for example:

<ItemGroup>
    <ILMergeReference Include="%(PackageReference)" Condition="'%(Identity)' == 'ilmerge'" />
</ItemGroup>
<PropertyGroup>
    <ILMergePath>%(ILMergeReference.InstallPath)\tools</ILMergePath>
</PropertyGroup>

This mechanism may be useful for referencing other package's assets too, like samples, docs, etc.

Granted, this isn't impossible to solve today, by just modifying the package providing the tools so that it exposes a property for its own current location (i.e. ILMergePath property in an ilmerge.props), but this mechanism would make all package assets available reliably for anyone regardless of how well authored the package is.

@emgarten
Copy link
Member

emgarten commented Dec 7, 2016

This would be really handy, but today NuGet has no rules for the format of the tools folder. It is just a place that NuGet doesn't read where authors can put things that the user needs to reference themselves. So trying to read this from existing packages would be difficult I think, for example if there were multiple exes like in xunit console runner it would be unclear what properties to create.

Do you think it would work to have generic helpers in MSBuild for working with NuGet packages? If you could get the root path of the package version that NuGet used from the package id, you could then just append the rest of the path as needed.

@kzu
Copy link
Author

kzu commented Dec 26, 2016

Well, I think just including the root install path for the package is enough. The author's/consumers can figure out how to chdir into tools or whatever.

Updated the example XML to showcase that the install path should be the root. I can figure out to to under tools myself of course.

@zhili1208 zhili1208 added this to the 4.5 milestone Oct 17, 2017
@zhili1208 zhili1208 added the Resolution:Question This issues appears to be a question, not a product defect label Oct 17, 2017
@kzu
Copy link
Author

kzu commented Oct 19, 2017

More examples where this is generally useful but package authors have to manually provide this:

I'd like at least the InstallPath to be present so that via MSBuild you can reach artifacts inside installed packages without resorting to hacks or PRs to package authors ;)

@kzu kzu reopened this Oct 19, 2017
@zhili1208 zhili1208 modified the milestones: 4.5, Backlog Oct 19, 2017
@rrelyea rrelyea added the Resolution:Duplicate This issue appears to be a Duplicate of another issue label Jun 14, 2018
@rrelyea
Copy link
Contributor

rrelyea commented Jun 14, 2018

Closing...as the approach in this issue feels better=: #5975
and Dupe like.

@rrelyea rrelyea closed this as completed Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue Resolution:Question This issues appears to be a question, not a product defect
Projects
None yet
Development

No branches or pull requests

4 participants