dotnet / wpf

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

Error publishing ClickOnce application while adding Microsoft.EntityFrameworkCore.SqlServer #3920

Open UseMuse opened 3 years ago

UseMuse commented 3 years ago

Create a new WPF application with TargetFramework netcoreapp3.1 or net5.0-windows, it doesn't matter.

  1. Start immediately, it works!
  2. Create a publication Folder -> ClickOnce, with the default settings - click next, further, further, further ...
  3. Publish
  4. Run the setup.exe file along the path ... \ bin \ publish (this is the default path)
  5. The application has been installed. I launch the application from the shortcut, it starts, it opens.

All right

I add to the application via NuGet Microsoft.EntityFrameworkCore.SqlServer 5.0.1

I run it locally - everything works

I publish!

I launch the application from the shortcut, it is updated, but no longer opens!

The problem is solved by manually copying the runtimes folder, this does not suit me

The application worked fine until I added Microsoft.EntityFrameworkCore.SqlServer 5.0.1 and republished

Actual behavior:

I caught the error text:

Description: A .NET Core application failed. Application: WpfApp1.exe Path: C: \ Users \ .... \ AppData \ Local \ Apps \ 2.0 \ GKP1YVXQ.DT4 \ QT7Y2ENE.D3P \ test..tion_0000000000000000_0001.0000_d72842864688dda2 \ WpfApp1.exe Message: Error: An assembly specified in the application dependencies manifest (WpfApp1.deps.json) was not found: package: 'Microsoft.Data.SqlClient', version: '2.0.1' path: 'runtimes/win/lib/netcoreapp3.1/Microsoft.Data.SqlClient.dll'

Expected behavior:

I want the application after adding Microsoft.EntityFrameworkCore.SqlServer 5.0.1 and publications were updated and launched

Minimal repro:

WpfApp1.zip

UseMuse commented 3 years ago

the same if you add EntityFramework (not core)

Rand-Random commented 3 years ago

Did you check in the settings step of the publish wizard. image

If the *.dll is marked as "Include" in the "Application Files"? image

Your minimal repo "WpfApp1.zip" doesn't seem to have a reference to "Microsoft.EntityFrameworkCore.SqlServer" the *.csproj file looks like this:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

As a side note, your publish profile contains <SelfContained>False</SelfContained> so your publish would rely that the .net core 3.1 or .net 5 runtime to be installed on the machine you want to install the application.

Maybe this is helpful https://docs.microsoft.com/en-us/dotnet/core/deploying/

Check the difference of deployment of "framework-dependent" and "self-contained".

UseMuse commented 3 years ago

@Rand-Random create a new project, add Microsoft.EntityFrameworkCore.SqlServer, publish and your project won't open