How can I disable the IIS Express launch profile for ASP.NET Core?

13,152

Solution 1

UPDATE:

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

Initial answer:

As mentioned in comments in ssmith answer, Visual Studio keeps restoring the settings on restart.

Since I could not find a better solution, I just denied the write permissions on launchsettings.json for Visual Studio. I left the instructions in my other answer for similar question, here is just a copy&paste:

  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.

Solution 2

I've created VS 2017 extension to deal with iis express launch settings https://marketplace.visualstudio.com/vsgallery/e09e0342-f9af-4306-8cf5-35238e34592d

The overall idea is to fix launchSettings.json for each .net core project before executing Build/Start/StartWithoutDebugging commands

Solution 3

So we've been struggling with this as well. What we ended up doing was having a copy of the launchsettings.json which was "clean", without the IIS Express stuff in it, and then having a pre build script which copies the clean version on top of the existing version.

  1. Create a new file. launchSettings.json.pristine in the same folder as your existing launch settings file.
    enter image description here

  2. Add a pre build script to copy the clean file overwritting the IIS settings.

    cd ..\..\..\Properties copy launchSettings.json.pristine launchSettings.json

Setting up a pre build event

This should effectively copy it over on build/run/etc.

Solution 4

Is it sufficient for you to simply delete the IIS Express option from the launchSettings.json file under Project properties?

Delete the stuff in the red box: enter image description here

Now only the other profile should appear: enter image description here

Note that I'm using VS2017 RC. It may be a bug in VS2015 that you're encountering. You might try editing and saving the launchSettings.json file with a separate text editor and see if that works for you. I can confirm this works fine in VS2017 RC, though.

Share:
13,152

Related videos on Youtube

Joe White
Author by

Joe White

Updated on September 15, 2022

Comments

  • Joe White
    Joe White over 1 year

    I'm writing an ASP.NET Core app (on the full .NET Framework) that uses WebListener, rather than Kestrel.¹ I'm using Visual Studio 2015 with Update 3, and ".NET Core 1.0.1 tools Preview 2" (the latest VS tooling on the download site as of this writing).

    Because I'm using WebListener, and because WebListener is not compatible with IIS Express, I would like to disable the "IIS Express" launch profile in Visual Studio, so that when my teammates open this solution, their Visual Studios will default to running the console app instead of IIS Express, and they'll be able to just hit Run and not get errors.

    But so far, I haven't been able to rid VS of the "IIS Express" launch profile. The Project Properties > Debug tab lets me edit the list of profiles, but when I select the "IIS Express" profile, the "Delete" button is disabled. If I edit launchSettings.json directly, and delete the "IIS Express" element from under "profiles", the File > Save operation silently inserts the "IIS Express" profile back into the JSON that it saves to disk!

    Apparently Microsoft really wants to always have an "IIS Express" launch profile, even though it isn't necessarily compatible with all ASP.NET Core projects. But it's worth asking: Has anyone found a way to disable the "IIS Express" launch profile in an ASP.NET Core project, and have only the self-host option(s) in the launch-profile selector?

    ¹ For the curious, I'm using WebListener because it will let me self-host in a Windows service and still support NTLM authentication, on a machine without IIS installed. Kestrel only supports NTLM when it's hosted in IIS, not when it's self-hosted.

  • Joe White
    Joe White about 7 years
    Does it actually save the file that way? In VS2015, when I hit Save, the file that actually gets written to disk has the IIS Express profile added back in. You won't see that change in the IDE, though, unless you close and reopen the file, or open it in an external editor.
  • ssmith
    ssmith about 7 years
    Just confirmed. It really does save it as shown. Closing and re-opening the file (in VS or otherwise) shows it saved as one would expect.
  • Joe White
    Joe White about 7 years
    Ok, cool. I wonder if they found some scenario where VS2015 couldn't work effectively without IIS Express, and enhanced VS2017 to cover that scenario (and so forced the IIS Express option in 2015 but not 2017). If you edit your answer to put "it works in VS2017, must be a VS2015 thing" more prominently at the top, I'll be happy to accept your answer.
  • ssmith
    ssmith about 7 years
    So today I reopened the project, and VS 2017 updated the launchSettings.json to add it back in. Apparently it does it on project load.
  • ttugates
    ttugates about 7 years
    +1 For launchSettings.json automatically re-adds IIS Express under settings. I am unable to find a way to make sure kestrel opens when we have 'multiple startup projects' and you click Start( as opposed to having the option to choose IIS Express, Kestrel, etc..).
  • Dave 5709
    Dave 5709 about 7 years
    @ssmith you may want to update the answer to indicate that the solution doesn't work after reloading
  • scottt732
    scottt732 almost 7 years
    This is a nice workaround if you never use IISExpress. The NTFS trick works but is annoying to opt-out at the project level. This one is a little more source team/control friendly (if it annoys you, install this. If not, don't). The behavior really should be configurable in VS Options (w/o any extensions). Open source, well designed. I'm in.
  • Charlie Kou
    Charlie Kou over 6 years
    "Is it sufficient for you to simply delete the IIS Express option" - sadly not. The blasted thing keeps adding them back in! Very fustrating!
  • Greg Gum
    Greg Gum over 6 years
    In VS 2017, V 15.3, this seems to be fixed. I tested and it does not add back in.