Skip to content

Paths to the package folder(GeneratePathProperty feature) should be generated for all libraries in the project graph #7851

Open

Description

@bording

When Visual Studio 2019 RC came out, I switched over to using it full time, so I'm now using a version of VS that actually works correctly with the new GeneratePathProperty feature in NuGet/NuGet.Client#2271.

Now that I can properly see it in action, I think it's current behavior is confusing and too difficult to use. Sometimes you have to opt-in to having the property with GeneratePathProperty="true" on your package reference and sometimes you don't. Based on NuGet/NuGet.Client#2271 (comment) it turns out this is controlled by whether or not the package has a tools folder in it.

This means I have to know the internal package structure of the package I'm consuming to know whether I need to add GeneratePathProperty="true" or not. I could just always add it, but then what's the benefit of it sometimes automatically happening?

This feature should either be completely opt-in or completely opt-out. Having it sometimes be opt-in and sometimes opt-out means I can never really trust it, and always have to explicitly opt-in to it even if it might be redundant.

Why is this tied to the tools folder anyway? I have several places where I'd find having the package path helpful, but none of them are related to the tools folder. They are primarily around advanced packaging scenarios, where I need to be able to reference items inside packages to include them in other packages.

Here are two examples of that sort of thing:

I've had to get fancy to avoid hardcoding the package version, so they are both places where I'll be able to use the new path property.

Activity

  1. changed the title [-]GeneratePathProperty feature shouldn't rely on tools folder[/-] [+]GeneratePathProperty feature shouldn't rely on tools folder to determine behavior[/+] on Mar 4, 2019
  2. nkolev92 commented on Mar 5, 2019

    @nkolev92
    Member
  3. changed the title [-]GeneratePathProperty feature shouldn't rely on tools folder to determine behavior[/-] [+]Paths to the package folder(GeneratePathProperty feature) should be generated for all libraries in the project graph[/+] on Mar 6, 2019
  4. jeffkl commented on Mar 8, 2019

    @jeffkl
    Contributor

    Some historical context around the current design:

    We hoped that this feature would rarely be used and would only be useful for two reasons:

    1. You are consuming a package with a command-line tool in your build. The package has no build\packageid.props that declares a property to the package path so you need to know the path.
    2. You are consuming a package that has a non-supported layout. This includes putting files at the root of the package or using folder names that don't follow conventions like build, lib, or ref.

    Both scenarios worked okay with packages.config because the path to the package was relative to the project. Users could manually consume the package by guessing the path. However, updating the package in Visual Studio required updating the version in the relative path manually. Since PackageReference uses the global package folder, the paths are harder to derive. You can use something like $(NuGetPackageRoot)\packageid\version\tools\mytool.exe but its not very discoverable.

    Internally at Microsoft we are migrating large codebases that consume a handful of non-conformant packages and we are using an internal-only solution to generate these properties. In order to move away from the internal-only tool we needed this feature as an escape hatch to consume packages that were poorly put together and could not be updated.

    Generating a property for each package could potentially slow down MSBuild evaluations in large repositories since the properties are for each project. So we didn't want it on by default. After a discussion, we decided that if a package had a tools folder then there was a high likelihood that the user would want to run the tool during a build so it was made automatic.

  5. added
    Priority:3
    and removed on Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Style:PackageReferenceType:Feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions