asp.net-mvcasp.net-coreproperties-file

2 launchsettings.json files in one project


I currently have a project that has 2 launchsettings.json files. One is under the properties folder and the other is under Views/Properties. I am very confused as this is the first time I've had this happen. I'm also trying to figure out which file is the correct one to use. Any help or explanation would be great.

Properties Folder

{
  "profiles": {
    "CoreApp": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:51523;http://localhost:51524"
    }
  }
}

Views/Properties

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:39278",
      "sslPort": 44353
    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "http://localhost:5136",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7125;http://localhost:5136",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}


Solution

  • To quote from the Development and launchSettings.json section of the docs:

    The environment for local machine development can be set in the Properties\launchSettings.json file of the project. Environment values set in launchSettings.json override values set in the system environment.

    So you should use one located in the Properties folder from the root (though probably you might need/want to copy something from the one somehow placed in the views folder).