question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The output of `dotnet publish` doesn't work on a machine without .NET Core installed

See original GitHub issue

Note: 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:

Visual Studio output

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:

dotnet publish output

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:

error message

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:closed
  • Created 8 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
christianspechtcommented, Jan 13, 2016

@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:

  1. create project in Visual Studio, publish via Visual Studio ⇒ the result works on a machine without .NET Core installed
  2. go to the command line (i.e. outside Visual Studio) and try to publish the same project via dotnet publish ⇒ the result does not work on a machine without .NET Core installed

By 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.

0reactions
christianspechtcommented, Jan 19, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The output of `dotnet publish` doesn't work on a machine ...
NET Core installed and execute it, it runs without errors. Now I'm trying to build the same project outside Visual Studio, via the...
Read more >
dotnet publish command - .NET CLI
dotnet publish - Publishes the application and its dependencies to a folder for deployment to a hosting system.
Read more >
net core - dotnet publish Not Deploying
I am trying to execute a Web Deploy on my .NET Core 2.0 Project. Deploying manually from within Visual Studio's "Publish" feature works...
Read more >
Publishing A Single EXE File In .NET Core 3.0
Publish the project from the current directory; Build the project to run on Windows 64 bit machines; Build in release configuration mode; Publish...
Read more >
How to publish .NET console app to single independent . ...
I've tried "dotnet publish -r win-x64 --self-contained true" and many other combinations of options and they all produce a /bin folder with an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found