Declare App Dependencies

Page last updated:

App Cloud recognizes an app as .NET Core by the existence of a project.json file in the root directory.

The demo app you deployed already has a project.json, and it looks something like this:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "copyToOutput": {
      "include": [
        "wwwroot",
        "Areas/**/Views",
        "Views",
        "appsettings.json"
      ]
    }
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        },
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.1"
        "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
      },
      "imports": "dnxcore50"
    }
  }
}

The project.json file determines both the version of .NET Core that will be used to run your application on App Cloud, as well as the dependencies that should be installed with your application. When an app is deployed, App Cloud reads this file and installs the appropriate .NET Core version together with the dependencies using the dotnet restore command.

Run this command in your local directory to install the dependencies, preparing your system for running the app locally:

$ dotnet restore
log  : Restoring packages for /.../project.json...
log  : Installing System.Diagnostics.Contracts 4.0.1.
log  : Installing System.Text.Encodings.Web 4.0.0.

...

Once dependencies are installed, you will be ready to run your app locally.

Upon running cf push, we will also push our whole project folders bin and obj. Since Cloud Foundry runs dotnet restore anyways, this is redundant and should be omitted to save bandwidth and even more importantly: time. You can create a .cfignore file which works just like a .gitignore file and which tells Cloud Foundry what files should be excluded when pushing. Let’s create a .cfignore file and exclude these folders and some files we don’t need in the cloud:

bin
obj
README.md
I’ve installed the App dependencies locally
View the source for this page in GitHub