RicoSuter / DNT

DNT (DotNetTools): Command line tools to manage .NET projects and solutions.
MIT License
414 stars 64 forks source link

switcher - support for GeneratePathProperty #128

Open crystalgreen opened 1 year ago

crystalgreen commented 1 year ago

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" />
doxxx commented 1 year ago

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

crystalgreen commented 1 year ago

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.

doxxx commented 1 year ago

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.

ssteiner commented 1 year ago

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)