The output of `dotnet publish` doesn't work on a machine without .NET Core installed
See original GitHub issueNote: I posted this as a question on Stack Overflow first, because I thought I was doing something wrong.
My example project is here: https://github.com/christianspecht/CoreTestVisualStudio
- I created a new project in Visual Studio Community Edition: “New Project” ⇒ “Web” ⇒ “Console Application (Package)”
- I created a new publish profile inside Visual Studio (“Build” ⇒ “Publish” in the menu)
Then, I do “Build” ⇒ “Publish” in the menu again, and Visual Studio builds my app.
The result is about 115 MB, (1138 files in 804 folders), and looks like this:
When I copy this on another Windows machine without .NET Core installed and execute it, it runs without errors.
Now I’m trying to build the same project outside Visual Studio, via the command line:
dotnet publish "%~dp0\src\CoreTestVisualStudio" -c Release -r win7-x64 -o "%~dp0\release\cli"
The result looks different than the first one - only 25 MB / 162 files, all in the same folder:
Initially the result was even smaller because I forgot to add Microsoft.NETCore.Runtime
as a dependency, but even after doing that, it still does not run on my second machine without .NET Core installed:
English translation:
Can’t start the program because MSVCP140.dll is missing on this computer. Re-install the program to fix the problem.
Apparently MSVCP140.dll
belongs to the C++ runtime.
But: when I do “Build” ⇒ “Publish” in Visual Studio, the output does not contain this DLL, and it works on the other machine anyway.
Maybe I’m still doing something wrong (and I understand that parts of .NET Core are moving targets at the moment), but unfortunately, the docs about building console apps are not finished yet.
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (6 by maintainers)
@piotrpMSFT: unfortunately, I’m not able to re-open the issue myself. But IMO it should be re-opened.
I did try to publish via the command line interface. Here’s the short version of the long text in my issue:
dotnet publish
⇒ the result does not work on a machine without .NET Core installedBy the way, it’s not related to the fact that I originally created the project in Visual Studio. When I follow the steps in this tutorial and do
dotnet publish
in the end, the result doesn’t work on a machine without .NET Core either.Please don’t get me wrong, I wasn’t complaining. I don’t care about the size increase. It’s rather the opposite - I had expected that the size would increase more by including the C++ runtime.