0

I am trying to run a first helloword app with .net 5 and visual studio code.

If I enter dnvm list I have this:

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
       1.0.0-beta4       clr     x64          win
       1.0.0-beta4       clr     x86          win
       1.0.0-beta4       coreclr x64          win
       1.0.0-beta4       coreclr x86          win
       1.0.0-beta4-11566 clr     x64          win
       1.0.0-beta4-11566 clr     x86          win
       1.0.0-beta4-11566 coreclr x64          win
       1.0.0-beta5       clr     x86          win
       1.0.0-beta5       coreclr x86          win
  *    1.0.0-rc1-update1 clr     x64          win             default
       1.0.0-rc1-update1 clr     x86          win
       1.0.0-rc1-update1 coreclr x64          win
       1.0.0-rc1-update1 coreclr x86          win

And my project.json is simple:

{
    "frameworks": {
        "dnx451":{}
    }
}

But when I run the app with DNX RUN on the folder I get this error

System.InvalidOperationException: The current runtime target framework is not compatible with 'HelloWorld'.
Current runtime target framework: 'DNXCore,Version=v5.0 (dnxcore50)'
 Version:      1.0.0-rc1-16231
 Type:         CoreClr
 Architecture: x64
 OS Name:      Windows
 OS Version:   10.0
 Runtime Id:   win10-x64

Please make sure the runtime matches a framework specified in project.json
   at Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)

d:\P\HelloWorld>
Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
  • Could you just provide the full project which you use? What kind of project you used (console application or web application)? How exactly you tried to started the application? You wrote about "DNX RUN", but it's not full clear what you did exactly. – Oleg Jan 10 '16 at 17:33
  • its visual studio code, so there is no full project just a project.json and a program.cs file with a main method with a console.writeline – Luis Valencia Jan 10 '16 at 17:57
  • http://screencast.com/t/jLFfi7IuW2nP – Luis Valencia Jan 10 '16 at 17:58
  • One can see that the program have `program.cs`. Which code you use? I repeat my questions: 1) what kind of program you try to write (console application, ASP.NET 5 Web application, ...) 2) how you tried to start it? You wrote about "DNX RUN" without any additional parameters. Your `project.json` is definitively wrong. You should define at least `"commands"` part and some other standard property (see [the documentation](https://github.com/aspnet/Home/wiki/Project.json-file)). Typically one use either [Yeoman](https://docs.asp.net/en/latest/client-side/yeoman.html) or Visual Studio Community. – Oleg Jan 10 '16 at 18:26
  • You can run `dnx "Microsoft.Dnx.ApplicationHost" --version` to see, which version will be used as default in command line (see `Type: Clr` or `Type: CoreClr`). If `dnvm list` really display `* 1.0.0-rc1-update1 clr x64 win default` in the commend prompt then you can change directory to the directory with `project.json` and to type `dnx run`. The program should work. – Oleg Jan 10 '16 at 18:45

1 Answers1

0

When I run the program with dnx run on a new console command it doenst work. However when I run the program with dnx run on the vs 2015 command prompt where I used the dnvm use command it works perfectly fine.

It looks to me that the dnvm use with the -p persistent parameter is not working properly because in the second command prompt it tries to use the coreclr even when the default and active framework is clr only.

and to answer Yeoman, the project.json is totally fine, I didnt modify anything to run

Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
  • you should open new console command prompt and to type `dnvm list` inside the command prompt. If you really see `* 1.0.0-rc1-update1 clr x64 win default` then `dnx run` in the same command prompt should work too (you need change current directory before) – Oleg Jan 10 '16 at 18:48
  • but in the first console I used dnvm use with the -p parameter which is suposed to make it work in any new console – Luis Valencia Jan 10 '16 at 19:33
  • Do you know that every process has it's own environment space, which holds the environment variables including the `PATH`? The application inherit environment space from the parent process. Using -p you can change the `PATH` of user for *new processes** or for processes. It just modify `PATH` in registry under `HKEY_CURRENT_USER\Environment` and send `WM_SETTINGCHANGE` message to all on top windows. Explorer wait for `WM_SETTINGCHANGE` and update environment space, but not previously started cmds. If you would start *new* cmd from Explorer then you will get updated PATH (can start `dnvm list`) – Oleg Jan 10 '16 at 20:15
  • I think this may be part of an issue being tracked for [Visual Studio Code's "omnisharp"](https://github.com/OmniSharp/omnisharp-vscode/issues/88) – Brent Arias Mar 22 '16 at 16:19