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

8

7

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?

Comparative answered 8/8, 2020 at 17:49 Comment(4)
it says Build failed. Check the Output window for more details. -- did you do that? Take the text from the Output window and copy and paste it in your question.Stereotropism
@Stereotropism , As you suggested, I have updated the question with the details of Output window.Comparative
Here is a workaround. Maybe you can refer to it.Cicerone
Your original message says build failed but your output window says all builds succeeded. Are you able to determine whether a build failed?Fides
C
4

Recently I came across a similar issue in Visual Studio 2022. At the end of the publish process, I got an error with a build failed and ask me to check temp file generated for more details, and it looks like the below,

 System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---

Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.

===================

In the output window, it was showing that there was an issue with copying a few files because the system wasn't able to find those files even though the files were there in the directory.

In my case, the issue was, the paths were too long for those files. So I changed the root folder short and it published successfully.

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

Microsoft Documentation: Maximum Path Length Limitation

Creamcups answered 19/11, 2022 at 13:23 Comment(0)
H
2

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.

Headreach answered 19/6, 2022 at 4:36 Comment(0)
R
1

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.

Ramentum answered 16/8, 2021 at 7:47 Comment(0)
G
1

In my case I have Image directory and which has containing large files, So I just exclude from solution and republish then it's publish successfully.

Gabriellegabrielli answered 28/1, 2023 at 16:0 Comment(0)
C
1

In my case, I upgraded Visual Studio to the latest version, and changed my solution to reference .Net Framework 8.0.

I got exactly the same error when publishing, as I did before.

I published to a Framework-Dependent executable, and this worked. Then I switched back to a Self-Contained executable, and it now works.

Nothing else has changed. I was about to try some of the suggestions in this post, but it seems I don't need to.

Chromatophore answered 1/12, 2023 at 10:50 Comment(0)
O
1

for me the problem was to select Linux-x64 platform because I wanted to publish to Linux based Azure Web app.

Turning back to portable or choosing Windows runtime and destination was solving the issue.

also worth checking output types of depending projects in the solution to be class library and nothing else

Oppression answered 30/1, 2024 at 20:38 Comment(0)
B
1

For me, This happened after switching from .net7 to .net 8 in ASP.Net project. The error occurred when trying to publish the project to IIS. The solution was to switch the “target framework” in the publishing configuration (.pubxml) in the “Publish” tab. Publish tab

Badr answered 4/3, 2024 at 6:39 Comment(0)
A
0

In my case, the origin of the "Microsoft.WebTools.Shared.Exceptions.WebToolsException" was trivial (after some research...): my password stored in the project was simply no longer up to date.

Ari answered 5/9, 2024 at 13:49 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.