首页 > 解决方案 > Visual Studio 2019 发布项目不起作用

问题描述

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

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

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

发布步骤:教程:使用 Visual Studio 发布 .NET 控制台应用程序

编辑:关于发布者的 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 ---

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

解决方案


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

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

dotnet publish -c Release

推荐阅读