question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Exception: Publish has encountered an error

See original GitHub issue

I’m facing an issue with dotnet publish command. I’m able to compile XX times and then without a valid reason I’m not able to publish the exe anymore. Also deleting bin and obj nothing change. Another strange thing is that after the first broken publish I need administrator permissions to delete bin folder. Here the errors

Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 

A diagnostic log has been written to the following location:
"C:\Users\enricobenedos\AppData\Local\Temp\tmp616C.tmp"

.tmp file content

2/10/2020 8:02:07 AM
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log 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.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.<IsBuildCompletedSuccessfully>b__2()
   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.Model.DefaultPublishSteps.<DefaultCorePublishStep>d__23.MoveNext()
--- 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.<RunPublishTaskAsync>d__213.MoveNext()
---> (Inner Exception #0) System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---

System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 

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

and with PowerShell the result is the same

dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 725.51 ms for C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerCore\FCSInstallerCore.csproj.
  Restore completed in 725.48 ms for C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj.
  FCSInstallerCore -> C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerCore\bin\Release\netcoreapp3.1\FCSInstallerCore.dll
  FCSInstallerGUI -> C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\bin\Release\netcoreapp3.1\win-x64\FCSInstallerGUI.dll
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018: System.ArgumentException: Invalid input specification: Found multiple entries with the same BundleRelativePath [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018:    at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs) [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]
C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(868,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\Projects\FCSSystem\Supervisore.NET\FCSInstallerGUI\FCSInstallerGUI\FCSInstallerGUI.csproj]

These are the main project references image

Ans these are the referenced project dependencies image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:50 (21 by maintainers)

github_iconTop GitHub Comments

12reactions
9ParsonsBcommented, Oct 30, 2020

Is there any update on this? Looking through Verbose build logs just to see which file is attempting to be copied twice is a huge pain.

Could we atleast get a better error message if this cannot be easily fixed?

11reactions
cabbruzzesecommented, Apr 20, 2020

Based on the feedback of the conflicting nuget dependencies I was able to create a bare bones azure function with the same functionality as before and got it to publish.

I think the real issue here is that since conflicting dependencies is a measurable error, then “We were unable to determine the cause of the error” is not valid error text. There needs to be a better error message, especially since this error reportedly also hides VS timing out. It leaves the actual root cause up to a lot of guessing and hits on several historic (and closed) github issues from multiple repositories.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish has encountered an error. We were unable to ...
This error occurs when publishing a project to “Folder Profile”. The error is very unhelpful, but I found the cause:
Read more >
Resolved - Publish failed. Check output for more details.
I only want to publish the project to my Documents folder, and the project ... Exception: Publish has encountered an error · Issue...
Read more >
Error when trying to publish an azure function from Visual ...
System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details....
Read more >
Help!!! Encountered Error during publish : r/VisualStudio
I'm trying to publish winforms application through visual studio 17.6. I get this popup states Publish has encountered an error.
Read more >
VS2019 Publishing Error : Load an assembly in ...
WebToolsException : Publish has encountered an error. We were >unable to determine the cause of the error. Check the output log for more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found