【问题标题】:Visual Studio 2019 publish project does not workVisual Studio 2019 发布项目不起作用
【发布时间】:2021-05-18 03:23:57
【问题描述】:

我想在 Visual Studio 2019(版本:16.9.5)中发布我的 WPF 应用程序。

我在解决方案资源管理器中右键单击该项目,单击Publish 并打开一个新选项卡。该选项卡应显示发布设置,但会无休止地加载。

我尝试使用空白/新控制台应用程序,但我遇到了同样的问题。

发布步骤:Tutorial: Publish a .NET console application using Visual Studio

编辑:关于发布者的 Visual Studio 日志:

Microsoft.ServiceHub.Framework.ServiceActivationFailedException: Activating the "Microsoft.Publish.Framework.PublishProfilesService (1.0)" service failed. ---> System.ComponentModel.Composition.ImportCardinalityMismatchException: No exports were found that match the constraint: 
	ContractName	Microsoft.Publish.Framework.Nexus.IPublishProfilesService
	RequiredTypeIdentity	Microsoft.Publish.Framework.Nexus.IPublishProfilesService
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
   at Microsoft.Publish.Framework.Nexus.PublishProfilesService.<CreateAsync>d__0.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.VisualStudio.PublishPackage.<<InitializeAsync>b__7_1>d.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 System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.VisualStudio.Utilities.ServiceBroker.GlobalBrokeredServiceContainer.ProfferedServiceFactory.<InvokeFactoryAsync>d__32.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.VisualStudio.Utilities.ServiceBroker.GlobalBrokeredServiceContainer.ProfferedServiceFactory.<GetProxyAsync>d__28`1.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 System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
   at Microsoft.VisualStudio.Utilities.ServiceBroker.GlobalBrokeredServiceContainer.View.<GetProxyAsync>d__19`1.MoveNext()
   --- End of inner exception stack trace ---

【问题讨论】:

  • 您是否尝试使用安装程序清除缓存或修复 VS?
  • 这个问题发生在VS19 v16.9.4,所以我刚刚更新到16.9.5,但同样的问题。我也删除了缓存,但还是一样
  • 您尝试修复了吗?
  • 是的,我试过了。没有影响
  • 你试过检查 VS 日志吗?是否启用了任何扩展?我还读到 AntiVirus 可能会导致 VS 挂起。虽然我没有经历过,但不确定。

标签: c# visual-studio visual-studio-2019 publishing


【解决方案1】:

如果您认为这是一个错误,您可以创建一个问题 here

或者你也可以尝试使用 cli publish-with-cli

dotnet publish -c Release

【讨论】:

  • 是的,这行得通。但是发布工具提供了一个安装程序,如果尚未安装,它可以安装 .Net。这个解决方案没有,不是吗?
  • 我在没有 .Net 的机器上试过。如果您启动应用程序,它会显示如下内容:“.Net 是必需的。您要下载吗?”。它并不完美,但很有效。
  • 你可以使用self contained deployment dotnet publish -c Release -r --self-contained true 并指定RID
猜你喜欢
  • 1970-01-01
  • 2020-06-03
  • 2017-07-23
  • 2020-11-23
  • 1970-01-01
  • 2020-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多