Home > Back-end >  System.AggregateException Error When Publishing Website in ASP.NET
System.AggregateException Error When Publishing Website in ASP.NET

Time:12-29

I decided to publish the ASP.NET MVC project to test it locally using IIS Manager. Therefore, after opening the necessary windows features, I created a new folder in the C:\inetpub\ directory on IIS Manager:

enter image description here

In the Visual Studio IDE I right clicked on the solution and clicked "Publish..." and specified that the target was "Folder":

enter image description here

When I clicked the Next button, I specified in the next window that the "Target" location was the C.\inetpub\TechnologyArticle directory. Then when I clicked the "Publish..." in the Visual Studio IDE, I encountered an error that I did not receive in Debug mode:

System.AggregateException: One or more errors occurred. 
---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed.

---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed.

---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed.

How can I solve this problem? Is the reason why I got this error in Release mode, which I did not receive in Debug mode, due to programming?

CodePudding user response:

This error is not due to programming. The reason for this error is trying to publish the website in the C:\inetpub\ directory, which is made visible and/or created by a service that you have activated by "Turn Windows features on or off" to publish the ASP.NET website locally. The user has no right to modify the C:\inetpub\ directory. Therefore, the current user's right to modify the C:\inetpub\ directory must be declared manually in the Windows 10 operating system.

When the ASP.NET website is published, the project outputs (such as *.dll files, style files, scripts, Views) compiled in Release mode will be extracted to the target directory, so the user must have the right to write to the C:\inetpub directory.

To resolve this issue, follow the steps below:

  • Open the properties of the C:\inetpub folder (With the folder selected, use the ALT ENTER shortcut).
  • Switch to the Security tab and click the Edit button.
  • Define "Full Control" right for current user and confirm settings by clicking OK button.
  • You repeat the publish procedure to publish your website.

enter image description here

  • Related