0

Weird issue I've faced today.

Pre-requisites: Installed:

VS2019
.NET Core 3.0

Steps to reproduce the issue:

Create new "WPF App (.NET Core)"
To the MainWindow.xaml add single TextBlock:
    <TextBlock Text="WPF on Linux" TextWrapping="Wrap"/>
Create new Publish Profile like the following:

enter image description here

Then save and publish

Expected to see the application being published. But instead the following message pops up:

enter image description here

And here is the content of the mentioned in the error message file:

2019-10-28 19:39:43
System.AggregateException: One or more errors occurred. ---> System.Exception: Publishing failed.
   --- 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__202.MoveNext()
---> (Inner Exception #0) System.Exception: Publishing failed.<---

System.Exception: Publishing failed.

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

The question is.. What am I doing wrong and/or how to fix the issue?

Important note:

If Deployment Mode is set to "Framework Dependent", and the Target Runtime is "linux-x64" then the project is published into the directory with no issues.
If Deployment Mode is set to "Self-contained", but Target Runtime is "win-x64", then deployment works with no issues.
Anatolyevich
  • 671
  • 5
  • 14

1 Answers1

2

The error is in the build output window:

There was no runtime pack for Microsoft.WindowsDesktop.App.WPF available for the specified RuntimeIdentifier 'linux-x64'

WPF is not supported on Linux, only Windows.

geometrikal
  • 3,195
  • 2
  • 29
  • 40
  • Do you know if there is some intention to make it work also on linux ? (Like git issue, etc...) – TarmoPikaro Oct 23 '21 at 08:39
  • Here is useful comment: https://github.com/dotnet/core/issues/4743#issuecomment-634969157 – TarmoPikaro Oct 23 '21 at 08:45
  • 1
    @TarmoPikaro MAUI is one option for cross platform .NET apps, but for some reason Microsoft is leaving the Linux support up to the community. There is also Uni and Avalonia. I have used Avalonia to write desktops apps for Linux and it is good. – geometrikal Oct 24 '21 at 13:50