dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.02k stars 1.16k forks source link

ClickOnce Publish Fails in .NET 5.0 for WPF Application #3898

Open damien-c-d opened 3 years ago

damien-c-d commented 3 years ago
.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  5.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

image

Output Window Text: OutputWindowText.txt

Log File From Error Window: tmp6214.tmp.txt

Expected behavior: Publish Succeeded

Minimal repro:

  1. Create New WPF App (.NET) From VS Menu
  2. Open Project Properties
  3. Target Framework -> .NET 5.0
  4. Install NuGet Package System.Drawing.Common -> 5.0.0 (Issue happens with many other packages/assemblies/project references as well)
  5. Publish -> Folder -> ClickOnce -> Self Contained -> Win-x64 ->Produce Single File
  6. Publish Failed
daisyTian0517 commented 3 years ago

I tested my .Net5 WPF project with steps which you provided, but I can't reproduce your error and I can published it succeeded. My OS Version is 19042.630 and Visual Studio version is 16.8.3. My published steps refer to Publish a single file app - Visual Studio.Could you show me your project which published failed for me to analyze?

damien-c-d commented 3 years ago

I tested my .Net5 WPF project with steps which you provided, but I can't reproduce your error and I can published it ucceeded. My OS Version is 19042.630 and Visual Studio version is 16.8.3. My published steps refer to Publish a single file app - Visual Studio.Could you show me your project which published failed for me to analyze?

I can't share the original project I experienced this issue in. But here is one I created 5 minutes ago on a PC that had a fresh install of windows and VS over the weekend and was able to repro the issue.

TestApplication.zip

bitbound commented 3 years ago

I get the below error when attempting to publish your above TestApplication. If I set SelfContained to false, though, it succeeds.

1>The "GenerateBundle" task failed unexpectedly.
1>System.ArgumentException: Invalid input specification: Found multiple entries with the same BundleRelativePath
1>   at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
1>   at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore()
1>   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
1>   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
damien-c-d commented 3 years ago

I guess ClickOnce is not as functional in .NET 5.0 as it was said to be. If I change the project back to target .NET 3.1 then it publishes successfully self-contained.

carterlist commented 3 years ago

Does .Net 5 ClickOnce support Self-Contained apps?

According to https://devblogs.microsoft.com/dotnet/announcing-net-5-0/,

The primary deployment model we’re currently supporting is framework dependent apps. It is easy to take a dependency on the .NET Desktop Runtime (that’s the one that contains WPF and Windows Forms). Your ClickOnce installer will install the .NET runtime on user machines if it is needed. We also intend to support self-contained and single file apps.

I tried installing a .Net 5 Self-contained Clickonce application on a clean Windows 7 SP2 machine (.net 5 not installed). I disabled the prerequisite from downloading/bundling in the published folder. I get an error ("...The application requires your system to be updated to Microsoft Common Language Runtime 4.0xxxx") when i run the ClickOnce installer. I believe one of the problems Self-Contained apps is supposed to solve is requiring users to install .Net, especially when they do not have admin privileges. It's not working for me.