How can I tell Visual Studio to build against multiple runtimes?
I've created a simple .NET Core (1.0) console application (Hello World with HTTP download). I want to build it for multiple RIDs (win7-x64, win10-x64, etc) so that I can publish it and include the dependencies for a stand-alone application running on Windows 2008 R2 (win7-x64). But my developer machine where I'm building this is Windows 10, so VS picks win10-x64 so my publish task doesn't find any files for win7-x64. I also want to build specifically for win10-x64, so even if I can force it by removing the rest of the RIDs, I want the option to build against multiple.
I know I can do this with MSBuild and dotnet cli, but I'd like to know how to do it from within VS.
project.json:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": "1.1.0",
"System.Net.Http": "4.1.0"
},
"runtimes": {
"win10-x64": {},
"win81-x64": {},
"win8-x64": {},
"win7-x64": {}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
Note that I'm using System.Net.Http which requires different dependencies in win7 vs win10 to test. If I run the win10-x64 on Win2k8 then it will fail because it's missing dependencies for the runtime on win7.
It shouldn't matter, but for reference here's the main code block, program.cs:
using System;
namespace TestOnWindows2008
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World");
using (var httpClient = new System.Net.Http.HttpClient())
{
string result = httpClient.GetStringAsync("https://www.microsoft.com/en-us/").Result;
Console.WriteLine(result.Substring(0, 200));
}
Console.WriteLine("Done");
}
}
}