aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 124 forks source link

Preview1 should not add IIS-Express profile and web.config when using just Kestrel #486

Closed cwe1ss closed 7 years ago

cwe1ss commented 8 years ago

Hi, we are using Kestrel without IIS to host our web app. We also want to use Kestrel for local development/debugging. However, with RC2-Preview1, Visual Studio always automatically adds a web.config and the IIS-Express profiles to launchsettings.json and it always starts IIS Express when I hit F5.

Can this be disabled?

cwe1ss commented 8 years ago

I found out that you have to set the project as the "Startup project" in order to be able to switch between the IIS Express and the Kestrel profile. If it's not the startup project, the "Debug -> Start Debugging" button only shows "Start" as a text. Would be good if this was made more visible.

However I still can't delete the IIS-Express profile.

sayedihashimi commented 8 years ago

TFS: 223023 I've added this to our internal TFS, we will reply back here soon.

am11 commented 7 years ago

@sayedihashimi, any update on this? :) We would really like to have our launchSettings.json to be more focused and look like:

{
  "profiles": {
    "Staging Profile": {
      "commandName": "Project",
      "commandLineArgs": "--port=3012",
      "launchBrowser": true,
      "launchUrl": "http://localhost:3012",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Staging"
      }
    },
    "Production Profile": {
      "commandName": "Project",
      "commandLineArgs": "--port=3012",
      "launchBrowser": true,
      "launchUrl": "http://localhost:3012",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      }
    }
  }
}

instead of the tool automatically adding iisSettings and profiles:IIS Express:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:23045/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Staging Profile": {
      "commandName": "Project",
      "commandLineArgs": "--port=3012",
      "launchBrowser": true,
      "launchUrl": "http://localhost:3012",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Staging"
      }
    },
    "Production Profile": {
      "commandName": "Project",
      "commandLineArgs": "--port=3012",
      "launchBrowser": true,
      "launchUrl": "http://localhost:3012",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      }
    }
  }
}

We cannot even change the default order, for example; launching VS with a clean solution or after git clean, we always get default selection as IIS Express. Reordering profiles in launchSettings.json doesn't help either for IIS Express profile. However, VS profile selector abides by the ordering for all other profiles.

If opting out of IIS specific settings is not on the near future roadmap, can we at least have default profile option for VS in upcoming RTM?

PS we literally have a note for devs to change the profile selection after git clean..

khayes commented 7 years ago

This still occurs in Visual Studio 2017 now that it has been released. This annoys me all the time, because I have no value in the IIS profile, no matter how you delete it if you reopen the solution it will just get re-created.

iluzyanin commented 7 years ago

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. At least until it won't be fixed for real.

BringerOD commented 7 years ago

Please fix this +1

sayedihashimi commented 7 years ago

Sorry for all the issues here. We are working on some updates in this area. We are planning on making the following changes.

FYI we already fixed the issue where web.config was created.

After these changes I think these scenarios will be significantly improved.

komby commented 7 years ago

I think that these will fix some of the issue. The other piece of this that I don't think these changes fix is when you have a launchsettings.json with both IIS and the Project setup as options for the launch setting. Steps: Open the properties open in visual studio Deselect IIS Express and select the project as the default Visual studio will not allow you to save your change of selection.
If you close it will not prompt you and will not persist that change.

If it did let you save it, where would it go?

Is it valid for a launchsettings.json file to have both options? If it is there should be some say of setting one as a default. In the json below how is it ever going to be "profiles" if the only setting that is honored is the IIS Express one?

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:21904/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5010",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:5010"
    }
  }
}
DMW007 commented 7 years ago

The workaround from @iluzyanin doesn't fit for me: When I try to permit writing, the dialog automatically disallow reading, too. So VS couldn't read the file any more, which gave me an exception. Seems like something to do with inherits. Its sad that the IIS annoys users who dont need and want them, and this bug exists for about a year now! I have the file in VCS to gave all my team members the same configuration. This would result me in having the wrong configuration selected, and I've to reset the file, so that the wrong version didn't get in VCS...

grokky1 commented 7 years ago

@sayedihashimi Will the fix be part of the next (15.3 I guess) VS update?

davidbfrogman commented 7 years ago

This is also affecting a large project I'm working on. Please fix ASAP. Thanks!

davenewza commented 7 years ago

This is still an issue.

craigfo commented 7 years ago

Still an issue ...

bjorn-ali-goransson commented 7 years ago

I'm not even doing anything requiring a server, just a class library with a single interface for net461. And still it adds this:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51351/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "loremipsum": {
      "commandName": "Project"
    }
  }
}
craigfo commented 7 years ago

Edit csproj and add this:

`

`

davidfowl commented 7 years ago

I'm not even doing anything requiring a server, just a class library with a single interface for net461. And still it adds this:

What SDK are you using? The Web SDK?

bjorn-ali-goransson commented 7 years ago
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputType>Library</OutputType>
  </PropertyGroup>
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
    <OutputTypeEx>library</OutputTypeEx>
    <Authors>Björn Ali Göransson</Authors>
    <Company />
    <Description>Installs (...) on your project.</Description>
    <Copyright>Björn Ali Göransson</Copyright>
    <PackageLicenseUrl>https://www.gnu.org/licenses/gpl-3.0.en.html</PackageLicenseUrl>
    <AssemblyVersion>1.0.8.0</AssemblyVersion>
    <Version>1.0.8.0</Version>
    <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
    <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
    <BuildOutputTargetFolder>lib\net461</BuildOutputTargetFolder>
  </PropertyGroup>
  <ItemGroup>
    <Content Remove="Properties\launchSettings.json" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Properties\launchSettings.json" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="(...).Core" Version="1.0.5" />
    <PackageReference Include="(...).Admin" Version="1.0.10" />
    <PackageReference Include="(...).JsonStore.FileBased" Version="1.0.3" />
  </ItemGroup>

</Project>

The two first ItemGroup I added to prevent it getting packaged. But the problem existed before, of course.

I started from scratch with this project, it's actually completely empty, I'm only using it for adding the deps in a simple way.

davidfowl commented 7 years ago

That's the Web SDK. If you wanted a regular class library then you made the wrong kind of application. What options did you choose that lead you to a web project?

bjorn-ali-goransson commented 7 years ago

Oh fair enough. Didn't know about the sdk part.

I had been fiddling around but could not get vs to create the new kind of slim csproj for class libraries, so I just tried to change it by hand...

Den 5 jul 2017 05:24 skrev "David Fowler" notifications@github.com:

That's the Web SDK. If you wanted a regular class library then you made the wrong kind of application. What options did you choose that lead you to a web project?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aspnet/Tooling/issues/486#issuecomment-312987603, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoyAFSSxE1IDXv5Wb3RoOyVsX7wuLNUks5sKwIDgaJpZM4IgE0g .

grokky1 commented 7 years ago

So if it's a console project that runs a web server, does it need to be Microsoft.NET.Sdk or Microsoft.NET.Sdk.Web? I thought the latter?

davidfowl commented 7 years ago

Web projects are - Microsoft.NET.Sdk.Web Console projects are - Microsoft.NET.Sdk Class libraries are - Microsoft.NET.Sdk

Web projects make assumptions about a couple of things:

bjorn-ali-goransson commented 7 years ago

Well, one of these class libraries actually have views that will be packaged into a TAR, used by a custom IFileProvider to leverage Views to Mvc ... but I digress. Understand that a Web project needs to set a port number.

On 5 July 2017 at 17:01, David Fowler notifications@github.com wrote:

Web projects are - Microsoft.NET.Sdk.Web Console projects are - Microsoft.NET.Sdk Class libraries are - Microsoft.NET.Sdk

Web projects make assumptions about a couple of things:

  • It assumes you'll want IIS/IIS Express (you can just switch the profile if you don't want to launch that way)
  • It turns on Server GC by default
  • It has excludes for client side package managers (node_modules, jspm, bower components)
  • It understands wwwroot as the static file folder and publishes that content to the output
  • It turns on a bunch of other web project system capabilities in the IDE like the Razor editor experience and other things that I won't go into...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aspnet/Tooling/issues/486#issuecomment-313129725, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoyACA4PJu_GmwNnAC9HW9fRqm3CEynks5sK6U9gaJpZM4IgE0g .

manigandham commented 7 years ago

Please reconsider the priority on this - it's becoming increasingly frustrating to deal with when opening any solutions in Visual Studio and having these IIS entries added, changing the running environment and also being accidentally checked into source control.

davidfowl commented 7 years ago

@manigandham are you checking in this file after manually deleting the IIS configuration?

jjcole commented 7 years ago

@manigandham as a workaround, when it adds it in, move it to the end of the profiles list and commit that. It will still be in the profiles list but at least it won't be the default selection when you open the solution.

manigandham commented 7 years ago

@davidfowl Yes, the file is checked in without the IIS configs, this is all we have:

{
  "profiles": {
    "ndweb": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost/"
    }
  }
}

@jjcole tried that (moved the IIS Express profile to end) but VS 2017 Enterprise still launches IIS Express:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:55138/",
      "sslPort": 0
    }
  },
  "profiles": {
    "ndweb": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost/"
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
MovGP0 commented 7 years ago

I am really annoyed by this bug. I made those files readonly, which gives me popups, but still better than having to undo the changes on an hourly basis. hope it gets fixed soon.

MovGP0 commented 7 years ago

the profile that Visual Studio generates is not working in my case, since I wrote self-hosted services and depend on the proper port numbers. VS makes IIS host everything on the wrong port and with a false configuration.

kevinbrydon commented 7 years ago

This issue looks like it has been resolved in Visual Studio 2017 version 15.3.0. Very much appreciated. Thanks!

davidfowl commented 6 years ago

Turns out there's a setting you can add to the csproj to disable the default launch profile:

<NoDefaultLaunchSettingsFile>True</NoDefaultLaunchSettingsFile>
Van-Dame commented 6 years ago

This was driving me nuts. Thanks for the setting key @davidfowl 👍