Debug and build web success but publish fail visual 2019

Viewed 5236

I'm using visual 2019, ASP.NET MVC core 2.2.0

My project debug ok, build no error but when I publish it give me an error like this

enter image description here

Detail file in AppData\Local\Temp\tmp76C2.tmp

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.

How can I fix it?

7 Answers

Check out the output window of visual studio when publishing, read all lines to find any error, then fix it. For example it might be a problem for copying files to publish folder after building. So you won't get any error on build as well.

Look for something like this: enter image description here

I ran into this error in VS 2019/Core 3.1. In my case, the Publish displayed a bunch of errors with the Bundler, which a regular build didn't show. Eventually found the Web Publish Activity window gave a clue: it shows line numbers for errors it finds, and the first error with the Bundler there was the problem, apparently. Turned out it didn't like an async function in the JS file. I removed that and it published OK.

For me the problem was that I updated de .net core version (2.2 to 5) of my project and forgot to change the .net version target on my publish profile.

Update Microsoft.Net.Compilers package.

enter image description here

It could also be due to a problem with the signature in your deployment options. Make sure to select a valid certificate.

I encountered this problem in Visual Studio 2022 when try to publish Blazor project. I tried many things (Clean, Rebuild, clear Nuget Cache etc) but nothing worked. Finally I used this command on the solution folder with Powershell (run as Admin)

dotnet workload install wasm-tools

Then I reopened Visual Studio and publish worked

I have also encountered this problem when I was going to publish my API.After that, I found my publishing folder does not exist in my local PC.
enter image description here

Related