-
Notifications
You must be signed in to change notification settings - Fork 252
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
Enable opt-in "GeneratePathProperty" metadata on a PackageReference to generate a per package MSBuild property to "Foo.Bar\1.0\" directory #6949
Comments
I think this is a really good compromise. We're seeing bigger repos try to migrate to PackageReference internally and it's causing a lot of pain for little things like this, especially when a package hasn't been updated in years and the owner has no interest in conforming. I'd heard the proposal of making every package have a property available, but I think that could lead to worse behavior by default. I like this a lot. |
There is something like this that NuGet already does. But only in some cases. |
See previous work here: #5975 We discussed in person with @jeffkl and msbuild team... Decided: More work needed: |
@rrelyea et al, can we close on the name of the attribute you want to use? Options we've discussed: <PackageReference Include="PackageA" Version="1.0.0" PropertyName="PkgPackageA" /> <PackageReference Include="PackageA" Version="1.0.0" MSBuildPropertyName="PkgPackageA" /> <PackageReference Include="PackageA" Version="1.0.0" ExportProperty="PkgPackageA" /> <PackageReference Include="PackageA" Version="1.0.0" ExportMSBuildProperty="PkgPackageA" /> <PackageReference Include="PackageA" Version="1.0.0" ExportVariable="PkgPackageA" /> <PackageReference Include="PackageA" Version="1.0.0" CreateMSBuildProperty="true" /> <PropertyGroup>
<NuGetGeneratePackageProperties>true</NuGetGeneratePackageProperties>
</PropertyGroup> |
one more option |
PR# NuGet/NuGet.Client#2271 has been merged to dev. Once approved, will also merge into 15.9. |
@jainaashish how do we get approval for 15.9? We need to get this in ASAP but haven't figured out how you want to go about it. |
@jeffkl I'm not sure what is the whole process to get this approve for 15.9... may be @DoRonMotter can help here? |
There should be a block on normal project PackageReference a |
Did this happen? |
Yes, this has been merged for VS 15.9 with NuGet/NuGet.Client@e082b2b |
Problem Statement
Some packages' layout does not conform to the best practices. Consumers of these packages can guess the path with something like this:
The
Foo
package only has a tool folder with an EXE that I want to execute but the package author did not include anybuild\Foo.props
that sets a property to the path of the package. So I have to derive the path based on the version. This causes some headaches when we update versions because the version value is in two places. You can use properties instead but that break Visual Studio Package Manager.Proposal
Add a
CreateProperty
metadata item to<PackageReference />
which is the name of an MSBuild property to create that points to the root of the expanded package.The
.g.props
file would then contain:And the above example can become:
This would only be useful for packages that are non-standard which should be a minority. I am concerned that if we add this feature that it will just perpetuate bad packages. However, the reality is that we have countless code bases which consume packages that could benefit from this feature.
It would not work for transitive dependencies. If you wanted a property you would need to add an explicit package reference.
I am willing to contribute this and have a prototype already coded up.
The text was updated successfully, but these errors were encountered: