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