2

I want to create a self contained web application using .NET Core. I want to target any version of Windows and have this in my project.json:

"runtimes": {
  "win10-x64": { },
  "win8-x64": { },
  "win7-x64": { }
}

When I run dotnet publish --runtime win10-x64 I can only specify a single runtime to publish at a time. I then have to maintain three copies of my binaries.

Is it possible to publish my app for all three runtimes and copy that folder around as a completely self contained application?

Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311
  • That makes no sense to me. When you run publish command you publish it to **ONE** system. This system runs only a single OS version. You just execute the publish command for each target system you deploy to. – Tseng Jun 15 '16 at 16:38
  • @Tseng In RC1. you could target windows, in RC2 you have to target a version of windows which makes deployment more complicated. @svick has the right idea by targetting `win7-x64` we can support all versions of windows. – Muhammad Rehan Saeed Jun 16 '16 at 07:38
  • Well it doesn't really make deployment more complicated because you always deploy to one machine/OS and there you add it as parameter. You can do exactly the same as before with dnx, but you have to make a portable app. This require you to install the runtimes manually (this you had to do with dnx too) on your windows machines – Tseng Jun 16 '16 at 07:57

1 Answers1

6

When you create a self-contained application, it contains all dependencies it needs to run. As far as I can tell, the only different between publishing to the various versions of Windows is that for older versions, some dependencies that are built-in in the newer versions have to be bundled in.

This means that if you want to have one version of your self-contained application that runs on all supported versions of Windows, you can: just use the oldest version of Windows (win7-x64).

The same approach probably won't work on Linux, since Linux generally does not maintain binary compatibility between versions.

svick
  • 236,525
  • 50
  • 385
  • 514
  • It certainly worked with Mono on Linux - if you built Mono on an old enough Linux system, it runs on any newer version of Linux, RHEL, CentOS, Debian, SUSE, Ubuntu, whatever - I'd love a way to do this with .NET Core without having to publish a package for each distro :( – Cocowalla Oct 28 '16 at 20:41