DNT icon indicating copy to clipboard operation
DNT copied to clipboard

switcher - support for GeneratePathProperty

Open crystalgreen opened this issue 2 years ago • 4 comments

Problem A <PackageReference> element can have extra attributes such as GeneratePathProperty. This attribute (and maybe others like Aliases?) get lost when switching to project references and back.

Example:

<PackageReference Include="MyLib" Version="1.3.7" GeneratePathProperty="true" />

After switching to projects and back to packages, I get:

<PackageReference Include="MyLib" Version="1.3.7" />

crystalgreen avatar Feb 04 '23 09:02 crystalgreen

Not only that but custom targets that depend on the $(PkgMyLib) property will now fail because the property is not defined.

doxxx avatar Mar 16 '23 15:03 doxxx

Not only that but custom targets that depend on the $(PkgMyLib) property will now fail because the property is not defined.

I work around this by using a condition like

Condition="Exists('$(PkgMyLib)\content\MyLib.md')"

If I want to build with project references, I need to reference them with a path to the project. Since that path is also there for package build, I need to remove/comment it when I want to build with package refs. That's not very convenient.

It would be cool if the path properties like $(PkgMyLib) would also be defined in project reference mode but this time it should reference the file in the project folder. This may not be easy to do as the path within the project may not be known. Extra config may be needed.

crystalgreen avatar Mar 17 '23 07:03 crystalgreen

Yeah, I was thinking about this some more after I posted my reply and I realized that it would be nearly impossible to provide the $(PkgMyLib) property since the contents of the package will most likely not exist in the source or build output in exactly the correct folder structure.

doxxx avatar Mar 17 '23 11:03 doxxx

Have you tried looking in the SwitchToProject method in SwitchPackageToProjectsCommand ? item in line 111 might have that info and if so, it could be stored in the restore information (dnt already keeps tabs of what it replaced)

ssteiner avatar Jul 20 '23 12:07 ssteiner