0

Problem

While publishing my ASP.NET MVC project using Visual Studio 2022, I ran into errors.

Similar errors appeared for:

  • Newtonsoft.Json.xml
  • System.Web.Helpers.xml
  • System.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.

  1. Right-click on the project → Unload project

  2. Right-click again → Edit Your project file

  3. 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 bin folder:

     <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>).

this screen shot help you

  1. List item
  2. Save the file
  3. Right-click the project → Reload Project
  4. Then publish again
1
  • Welcome to Stack Overflow. Please take the tour. SO is a question-and-answer site, not a discussion forum or blogging platform. While self-answers are welcome here, all posts must follow the Q&A format. Please edit your question to remove the answer and post it as an answer below. Commented Jun 18 at 23:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.