CentralisedPackageConverter icon indicating copy to clipboard operation
CentralisedPackageConverter copied to clipboard

Handle imports that contain PackageReferences.

Open belav opened this issue 3 years ago • 3 comments

Within a csproj, include a line like

<Import Project="AnotherFile.props" />

And the content of AnotherFile.props

<Project>
    <ItemGroup>
        <PackageReference Include="Antlr" Version="3.4.1.9004" />
    </ItemGroup>
</Project>

Ideally AnotherFile.props would also be included in the conversion. Possibly by including *.props in the wildcard. Or by having an option like includedFiles=AnotherFile.props

This situation probably isn't that common, and it wasn't bad to just deal with in a manual way.

belav avatar Oct 07 '22 14:10 belav

@belav I use imports for common things like packages (e. g. analyzers) regularly.

Sadly, the majority of open-source tools around projects seems to just read the csproj as XML. I have no idea why. It seems like unnecessary work, when there is a perfectly good Microsoft.Build nuget package that does everything for you (including implicit and explicit imports) and will keep you up-to-date on new features without any changes to your own code.

The XML approach will become more and more broken as features like Directory.*.[props|targets] files and now central package management are added. It would be so easy to use the MSBuild library for this instead of manual XML reading, but for some reason hardly anyone seems to do that :-/

shuebner avatar Nov 22 '22 08:11 shuebner

@shuebner Feel free to refactor to use the MIcrosoft.Build library and submit a PR! :)

Webreaper avatar Nov 22 '22 09:11 Webreaper

@Webreaper I knew that that would be the response 😄

But no thank you. I am not using this tool and will spend my scarce free time elsewhere 😉

shuebner avatar Nov 22 '22 09:11 shuebner