Problem
While publishing my ASP.NET MVC project using Visual Studio 2022, I ran into errors.
Similar errors appeared for:
Newtonsoft.Json.xmlSystem.Web.Helpers.xmlSystem.Net.Http.Formatting.xml
These .xml files are usually XML documentation files generated by NuGet packages. They are optional and not required for deployment. However, Visual Studio was still trying to copy them, even though they didn’t exist in my bin folder.
Solution
I solved the issue by editing the .csproj file of the project.
Right-click on the project → Unload project
Right-click again → Edit Your project file
Paste this snippet inside the first
<PropertyGroup>tag (or create one at the top if it doesn’t exist):<PropertyGroup> <ExcludeFilesFromDeployment> bin\EntityFramework.xml; bin\Newtonsoft.Json.xml; bin\System.Web.Helpers.xml; bin\System.Net.Http.Formatting.xml </ExcludeFilesFromDeployment> </PropertyGroup>To exclude all .xml files in the
binfolder:<PropertyGroup> <ExcludeFilesFromDeployment>bin\**\*.xml</ExcludeFilesFromDeployment> </PropertyGroup>If you still face issue you can try one more thing paste this above code snippet (one of them) just after the last close tag
ItemGroup(</ItemGroup>).
- List item
- Save the file
- Right-click the project → Reload Project
- Then publish again