Search code examples
.net-coreiis-expressasp.net-core-webapikestrel-http-server

Visual Studio keeps adding IIS Express back into my launchsettings.json


I am trying to remove the IIS Express profile from my .NET Core launch settings but every time i repoen the solution, Visual Studio adds it back in again. For example, in a new project my launch settings looks like this

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:55735/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyProject": {
      "commandName": "Project",
      "launchUrl": "http://localhost:5010",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

I remove the IIS sections

{
  "profiles": {
    "MyProject": {
      "commandName": "Project",
      "launchUrl": "http://localhost:5010",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

The solution runs fine. But as soon as I close and reopen the solution the IIS sections reappear.

Any ideas?


Solution

  • UPDATE:

    The issue should be fixed with the latest release (update) of Visual Studio 2017 (version 15.3.0).

    Initial answer:

    This is not a solution, but an ugly workaround. I figured that if I would just deny permissions to change the launchsettings.json file this will prevent Visual Studio from overwriting it every time. Since this file doesn't change much, it is more or less a satisfying solution for me.

    So:

    1. Update your launchsettings.json for the last time.
    2. Close Visual Studio.
    3. Open security settings (right-click on launchsettings.json in Explorer -> Properties -> Security)
    4. Click Advanced -> Change Permissions
    5. Select "Authenticated Users" (or other user group under which Visual Studio is running on your machine) from the "Permissions entries" list and click Edit ->
    6. Check Deny for "Create files / write data" permission.
    7. Click OK in all open dialogs and warnings to save changes.
    8. Reopen Visual Studio and see it fail to do it's update.

    Hope it helps.