You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enable opt-in "GeneratePathProperty" metadata on a PackageReference to generate a per package MSBuild property to "Foo.Bar\1.0\" directory #6949
The Foo package only has a tool folder with an EXE that I want to execute but the package author did not include any build\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.
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.
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.
Let's remember that, and understand if we should continue to enhance that existing feature … first.
I believe that may solve the same problem.
(cannot recall right now...but can dig into this soon...)
We discussed in person with @jeffkl and msbuild team...
Decided:
Given id of My.Package, if it had a tool folder, $(PackageToolDir_My_Package_Name) would be created in *.nuget.g.props
That would be true of all projects that transitive reference that package.
We'd also support a ExportPathVariable="PackageDir_MyFolder" attribute on PackageRef that would enable the user to request that a PackageDir prop, of the given name, be created.
More work needed:
Would PR project system need any changes?
Would PR nomination from SDK team flow the data correctly?
There should be a block on normal project PackageReference a PackageType=DotnetTool? So how could user use it in their csproj? Or all these internal package don't have the PackageType
changed the title [-]Generate MSBuild property that has the path to a package[/-][+]Enable opt-in "GeneratePathProperty" metadata on a PackageReference to generate a per package MSBuild property to "Foo.Bar\1.0\" directory[/+]on Nov 26, 2018
Activity
jeffkl commentedon May 18, 2018
FYI @AndyGerlicher @kingerja
AndyGerlicher commentedon May 18, 2018
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.
rrelyea commentedon May 18, 2018
There is something like this that NuGet already does. But only in some cases.
Let's remember that, and understand if we should continue to enhance that existing feature … first.
I believe that may solve the same problem.
(cannot recall right now...but can dig into this soon...)
rrelyea commentedon Jun 14, 2018
See previous work here: #5975
We discussed in person with @jeffkl and msbuild team...
Decided:
Given id of My.Package, if it had a tool folder, $(PackageToolDir_My_Package_Name) would be created in *.nuget.g.props
That would be true of all projects that transitive reference that package.
We'd also support a ExportPathVariable="PackageDir_MyFolder" attribute on PackageRef that would enable the user to request that a PackageDir prop, of the given name, be created.
More work needed:
Would PR project system need any changes?
Would PR nomination from SDK team flow the data correctly?
jeffkl commentedon Jun 15, 2018
@rrelyea et al, can we close on the name of the attribute you want to use? Options we've discussed:
jainaashish commentedon Jun 18, 2018
one more option
PkgPathPropertyNamejainaashish commentedon Aug 15, 2018
PR# NuGet/NuGet.Client#2271 has been merged to dev. Once approved, will also merge into 15.9.
jeffkl commentedon Aug 27, 2018
@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.
jainaashish commentedon Aug 27, 2018
@jeffkl I'm not sure what is the whole process to get this approve for 15.9... may be @DoRonMotter can help here?
wli3 commentedon Aug 30, 2018
There should be a block on normal project PackageReference a
PackageType=DotnetTool? So how could user use it in their csproj? Or all these internal package don't have the PackageTypedasMulli commentedon Sep 10, 2018
Did this happen?
jainaashish commentedon Sep 10, 2018
Yes, this has been merged for VS 15.9 with NuGet/NuGet.Client@e082b2b
[-]Generate MSBuild property that has the path to a package[/-][+]Enable opt-in "GeneratePathProperty" metadata on a PackageReference to generate a per package MSBuild property to "Foo.Bar\1.0\" directory[/+]