Site icon Knarfalingus.net

ASP.NET 5 RC1 On Linux – Part IV – First App Analysis

Looking at the project.json from my last post

We see the following

{
  "version": "1.0.0-*",
  "description": "ConsoleApp1 Console Application",
  "authors": [ "knarfalingus" ],
  "tags": [ "hello", "world" ],
  "projectUrl": "https://www.knarfalingus.com",
  "licenseUrl": "https://opensource.org/licenses/MIT",

  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
  },

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

  "frameworks": {
    "dnxcore50": {
      "dependencies": {
       "Microsoft.CSharp": "4.0.1-beta-23516",
       "System.Console": "4.0.0-beta-23516",
      }
    }
  }
}

To simplify, we can actually remove the following

  "compilationOptions": {
    "emitEntryPoint": true
  }

This wasn’t required as the runtime will find the static Main() method.

Also we can remove the metadata, authors, projectUrl and licenseUrl etc. I added those arbitrarily anyway.

What is interesting is the commands

  "commands": {
    "ConsoleApp1”: “ConsoleApp1”
  }

The above is typical of what Visual Studio 2015 would create. The name “ConsoleApp1” doesn’t have to match the application/namespace, for example the following works just as well.

  "commands": {
    “xyz”: "ConsoleApp1”
  }

This can be explicitly run by executing

dnx xyz

The surprising part I found when trying this on Windows was, the value “ConsoleApp1” refers to the folder the app is in, not the namespace or application title. For example with this project.json

{
  "version": "1.0.0-*",

  "dependencies": {
  },

  "commands": {
    “xyz”: "ConsoleApp1"
  },

  "frameworks": {
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Console": "4.0.0-beta-23516",
      }
    }
  }
}

And the two files, project.json and Program.cs in a ConsoleApp1 directory, if I change into the directory from the parent directory using cd ConsoleApp1, dnx xyz works but if I do cd consoleapp1, in Powershell it doesn’t!, Powershell introduces case into the folder name see below. This doesn’t happen with the standard console.

I am not sure if this is a bug or not due to the fact that ASP.NET is targeting systems with case sensitive file systems whereas in Windows the file system is not case sensitive (by default).

Exit mobile version