Home > OS >  Unexpected csproj itemgroup/NativeLibs Remove entry on file rename
Unexpected csproj itemgroup/NativeLibs Remove entry on file rename

Time:11-10

I am getting an unexpected ItemGroup entry for each rename.

If I start with interface public interface IDoStuff and rename it to IDoStuffRename I get this in my csproj on save:

<ItemGroup>
   <NativeLibs Remove="IDoStuffRename.cs" />
</ItemGroup>

It does not happen on delete or move. This heavily pollutes the csproj file over time after continuous refactoring.

Any idea why this is happening and how I can avoid that extra entry?

I currently undo it manually.

CodePudding user response:

Confirmed, it's indeed nuget package ABCPdf that's causing this behavior. I can repeatably reproduce it by adding the package (or not). I get it on a dotnet core solution with version 11x and 12x.

Manually removing these references for now.

PS: If someone can elaborate what NativeLibs Remove means for the build I would appreciate it.

CodePudding user response:

It is difficult to see how the ABCpdf NuGet package could cause this issue because ultimately the NuGet package is just a set of files in a zip.

It is Visual Studio that puts these files in different places depending on what it sees in the NuGet package. But even that only happens at the point of installation.

When it comes to refactoring the only culprit here can be Visual Studio because it is the only one that can change the project file and indeed there is no installation occurring.

So in short - this is a bug or perhaps a feature of Visual Studio which you will see with a variety of NuGet packages when performing similar tasks.

The solution will be to upgrade Visual Studio and hope that Microsoft resolve the issue.

  • Related