WPF .NET Core 3.1应用程序的发布单个文件(发布)失败 [英] Publish Single File (Release) fails for WPF .NET Core 3.1 application

查看:1030
本文介绍了WPF .NET Core 3.1应用程序的发布单个文件(发布)失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用针对win-x86的发布单个文件来发布针对.NET Core 3.1的WPF应用程序(到文件夹)。该应用程序可以很好地发布以进行调试,但是发布失败。如果我取消选择产生单个文件,则发布工作正常。我使用的是Visual Studio 2019(16.4.1和预览版16.5.1)



发布时遇到此一般错误:


发布遇到错误。发布遇到错误。我们
无法确定错误原因。检查输出日志
以获得更多详细信息。



诊断日志已写入以下位置:
C:\Users\username\AppData\Local\Temp\ tmpD176.tmp


加上一个不太有用的日志文件:



< pre.class = lang-none prettyprint-override> System.AggregateException:发生一个或多个错误。 ---> System.Exception:发布遇到错误。我们无法确定错误的原因。检查输出日志以获取更多详细信息。
-内部异常堆栈跟踪的结尾---
在System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
在System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,CancellationToken cancelestToken)Microsoft.Publish.Framework.Model.DefaultPublishSteps中的
。<> c__DisplayClass26_0。< IsBuildCompletedSuccessfully> b__2()
在System.Threading.Tasks.Task`1.InnerInvoke( )
在System.Threading.Tasks.Task.Execute()
-从上一个引发异常的位置开始的堆栈跟踪--
在System.Runtime.CompilerServices.TaskAwaiter .ThrowForNonSuccess(任务任务)
,位于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)
,位于Microsoft.Publish.Framework.Model.DefaultPublishSteps。< DefaultCorePublishStep> d__23.MoveNext()
---从上一个引发异常的位置开始的堆栈结束跟踪---
在System.Runtime.CompilerSer在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)
(在Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel。< RunPublishTaskAsync> d__156.MoveNext() )
---> (内部异常#0)System.Exception:发布遇到错误。我们无法确定错误的原因。检查输出日志以获取更多详细信息。 < ---

System.Exception:发布遇到错误。我们无法确定错误的原因。检查输出日志以获取更多详细信息。

我发现,表明该问题可能与Visual Studio超时有关,尽管该问题与Azure有关。我还发现了 Github问题,当我尝试使用ReadyToRun发布。



我们几周前发布成功,改动很小。这可能是Visual Studio的问题吗?我意识到这可能是引用和NuGet包的问题,​​但我真的不知道从哪里开始着手解决此问题的核心...发布并没有提供有关可能导致问题的任何有用信息。 。有任何想法吗?

解决方案

对我来说,该错误与自定义nuget源有关,例如Azure DevOps Artifacts。
有时,生成脚本会尝试从Azure DevOps还原nuget并失败,并显示(未经授权)错误,该错误会在发布中产生错误。



临时禁用自定义nuget源,无论使用哪个选项(如单个文件),都可以再次发布。


I'm trying to publish a WPF Application (to a folder) targeting .NET Core 3.1, using Publish Single File, targeting win-x86. The application publishes fine for Debug, but fails for Release. If I deselect Produce Single File, the publish works fine. I'm using Visual Studio 2019 (16.4.1 and preview 16.5.1)

I get this generic error when I publish:

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\username\AppData\Local\Temp\tmpD176.tmp"

Plus a not-so-helpful log file:

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__156.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. 

I found this question that suggests that it might be an issue with Visual Studio timing out, though that issue is related to Azure. I also found this Github issue that showed a similar when I tried publishing with ReadyToRun.

We published with success a few weeks ago, with minimal changes. Could this be an issue with Visual Studio? I realize that this may be an issue with references and NuGet packages, but I don't really know where to start to get to the core of this issue... publishing doesn't provide any helpful information on what might be causing the issue. Any ideas?

解决方案

For me the error has to do with custom nuget sources, like Azure DevOps Artifacts. Sometimes the build script tries to restore nugets from Azure DevOps and fails with a (Unauthorized) error, which produces the error in the post.

Temporarily disabling the custom nuget sources, makes publish work again regardless of the options used like single file.

这篇关于WPF .NET Core 3.1应用程序的发布单个文件(发布)失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆