0

I create a new C# project WPF Application - A project for a .NET Core WPF Application. Framework: .NET Core 3.1.

Project loaded. (you have an empty form) Right click on your project and check that you have "Output type" Windows application. (It means when you click on build it creates an EXE file in BIN folder of your project) Then add a new project to the solution : Setup Wizard by extension Microsoft Visual Studio Installer Projects. Then follow steps as is here -> https://stackoverflow.com/a/6090929/15917420

In the end it packages DLL into installator file instead EXE.

So if you take setup.exe and install it, it installs DLL. Do you have same problem or am I missing something?

If I create WPF with .NET Framework I dont have this problem.

Thank you

EDIT: recorded video: https://drive.google.com/file/d/11ElC0F62klxQOI-beOn6LhcZbyOb7QDT/view?usp=sharing

Michael Rovinsky
  • 6,807
  • 7
  • 15
  • 30
  • What is the name of the exe created and included in the setup project, what is the name of the dll installed, and what are the properties of the object added to the setup project? If you creates an exe and added it, I don't understand you getting a dll instead... –  May 13 '21 at 15:01
  • @OlivierRogier it doesn't matter just create the simple project with empty form. – Bestije Hitsu May 13 '21 at 16:19

2 Answers2

3

I had the same issue. Microsoft has published this: https://learn.microsoft.com/en-us/visualstudio/deployment/installer-projects-net-core?view=vs-2019

Basically is says that for .NET Core projects, you have to use the "published items" instead of "primary output" when building the setup project. It also has a couple of other hints too.

mly
  • 51
  • 5
  • You have posted this answer *at least* four times: https://stackoverflow.com/a/69301507/10871073 https://stackoverflow.com/a/69301592/10871073 https://stackoverflow.com/a/69301729/10871073. – Adrian Mole Sep 23 '21 at 15:53
  • Yes, because the answer applies to all four issues. Not sure what I could have done differently with my limited functionality. – mly Sep 23 '21 at 23:25
1

When targetting .NET Core, the "main" project (the one that is the application) gets two files, a dll and an exe file. The exe file is only a stub loader that locates the dotnet runtime and transfers control to the corresponding dll. Simply put, the exe of a .NET core project is executing the dotnet <dll-with-the-same-name>-command.

With this in mind, you need to make sure that your installer installs both the dll and the exe (and any other similarly named files, such as <Application>.deps.json).

PMF
  • 14,535
  • 3
  • 23
  • 49
  • How do you do that? – Toby Jul 26 '23 at 13:51
  • @Toby That depends on your installer application. Typically it means that you have to add both the exe and the dll to the list of files to install. – PMF Jul 26 '23 at 13:59
  • Yes, but how do you actually do that? the only option is add>Project output then publish items. It doesn't allow me to select the specific file to include, and that option seems to miss out adding the .exe file – Toby Jul 26 '23 at 14:14
  • @Toby Oh, I'm talking about an _installer generator_, something like Inno Setup, not the project settings. If you want to directly distribute a folder generated from dotnet publish, then simply copy everything that's in the output folder to the target machine. – PMF Jul 26 '23 at 15:58