ASP.NET web application fail to publish in Visual Studio 2019

Viewed 7748

The application which I'm working now was developed in VS 2015. I'm trying to run the same in VS 2019, the build succeeded but fails when trying to publish via FTP / to the local folder as well.

A diagnostic log has been written to the following location .tmp file.

System.AggregateException: One or more errors occurred.

System.Exception: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.WebTools.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass43_0.b__3()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.d__213.MoveNext()

(Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.

System.Exception: Build failed. Check the Output window for more details.

The following are the details in the Output window.

1>------ Build started: Project: EmpDetails.BAL, Configuration: Release Any CPU ------
1>  EmpDetails.BAL -> C:\Test\Projects\source\repos\Project\EmpDetails.BAL\bin\Release\EmpDetails.BAL.dll
2>------ Build started: Project: EmployeeDetails, Configuration: Release Any CPU ------
2>  EmployeeDetails -> C:\Test\Projects\source\repos\Project\EmployeeDetails\bin\EmployeeDetails.dll
3>------ Publish started: Project: EmployeeDetails, Configuration: Release Any CPU ------
3>Connecting to C:\Test\Projects\ProjName\Published Website...
3>
========== Build: 2 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

I googled the same and tried the following

  1. run Visual studio in administrator mode.
  2. Give read/write privileges to the destination folder.
  3. Shorter the URL path
  4. Set "Build + Intellisense" in Error list.

Nothing works.

But when I created the sample application in VS 2019 and I'm able to publish it.

Just a thought, do I have to change/update anything in Web.config file.

I'm struggling to fix this issue for past two days. How to fix it?

2 Answers

May be helpful for someone. I had this same issue when i publish my application also. And the weird thing is it solved when i added this to my package reference in .csproj file

    <PackageReference Include="EFCore.BulkExtensions" Version="5.2.8" />

After adding this package reference, when i rebuild and publish, it is working.

In my case this error because of some files that are exist in project(csproj) but were deleted physically. remove them from project and publish again.

In addition in output window show the error's description.

Related