Assembly Remapping warning on Package Reference project

42 views Asked by At

I have projects that have been converted to the package reference format. In the process, the web.config and packages.config files have been removed from the project and deleted from the file system. And yet, I am getting that annoying message to consider app.config remapping of assemblies in Visual Studio 2022. This happens on some of the projects, but some are clean without that warning, and I have not been able to figure out the difference. The entire packages folder has been removed from the solution, so there is absolutely no reference to the older version of the assemblies that I can find in the project.

For example, in one of my projects, I am getting this warning, and the only project referenced by that compiles cleanly, so I know it is not the referenced project that is causing this warning.

Hoping someone here can offer some insight!

1

There are 1 answers

0
Gary Williams On

It turns out this is because the project are .NET 4.8 web application projects. As part of the conversion to package reference format, the original import of the Microsoft.WebApplication.targets was included in the project file, which generated the warnings. The Sdk attribute of the Project node was Microsoft.NET.Sdk.

Changing the Sdk attribute of the Project node to Microsoft.NET.Sdk.Web, removing the import of the Microsoft.WebApplication.targets cleared up the warnings.

Because each of these projects also included .config files, it was necessary to make sure each .config file had "Copy to Output Directory" set to "Copy always" (or "Copy if newer"), set the EnableDefaultContentItems property to false.