Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

DNX always chooses the highest framework #2333

@Kieranties

Description

@Kieranties

Scenario: I have a console application that may be ran in both dnx451 and dnx46

When running dnx . run the application is always ran as a dnx46 application. In the code base there has been an explicit decision to always run against the highest discovered framework version:

// Find the highest DNX desktop version, if any and map it to .NET version

Why is that? Would it be possible to provide a flag to dnx when executing for the target framework (e.g. dnx . run -fw dnx451)

Trivial example:

/* project.json */
{
  "userSecretsId": "aspnet5-ConsoleApp1-20150724092501",
  "version": "1.0.0-*",
  "description": "ConsoleApp1 Console Application",
  "authors": [ "kieranties" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
    "Microsoft.Framework.Runtime.Abstractions": "1.0.0-beta6-*"
  },

  "commands": {
    "ConsoleApp1": "ConsoleApp1"
  },

  "frameworks": {
    "dnx46": { },
    "dnx451": { }
  }
}
/* Program.cs */
using Microsoft.Framework.Runtime;
using System;

namespace ConsoleApp1
{
    public class Program
    {
        private readonly IApplicationEnvironment _appEnv;

        public Program(IApplicationEnvironment appEnv)
        {
            _appEnv = appEnv;
        }

        public void Main(string[] args)
        {
            Console.WriteLine(_appEnv.RuntimeFramework);
            Console.WriteLine(_appEnv.ApplicationBasePath);
#if DNX46
            Console.WriteLine(AppContext.BaseDirectory);
#endif
        }
    }
}
/* Current result */
> dnx . run
DNX,Version=v4.6
C:\dump\x\ClassLibrary1\src\ConsoleApp1
C:\Users\kieranties\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6-12231\bin\

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions