When I create new projects for Visual Studio, it is a lot less effort to just copy an existing project and modify the project/solution/config files, rather than cut and paste a whole bunch of files, and then have to set the build actions for each.
This works well, apart from the IIS debug settings.
If I leave them the same, then I can only debug one project at a time, because the port will be in use.
However if I change the ports in launchSettings.json (I'm using Asp Net Core, so Kestrel has a port, and there's also an SSL port), nothing works. I'm in this situation now, having copied a project and altered both port numbers to new random ports, and in the project in question, when selecting 'Start without debugging' from the menu, I don't even get a webserver starting up (though I do get a browser).
In a project created by VS, I at least get a new output window started by 'ASP NET Core Web Server' with the Kestrel output.
I appreciate that VS probably has to do a few things, like register a self-signed SSL cert and perhaps mod the IIS Express setup files, but it would be good to be able to do these things myself.
I have tried deleting the solution .vs
folder and looking at the IIS Express folder in the Windows Documents
folder (there doesn't appear to be any project/solution specific stuff in there).
Here's the launchSettings.json
(all I do is change the port numbers and project profile name, eg My_AspMvc)
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost: 62649/",
"sslPort": 44315
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "https://localhost: 44315/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"My_AspMvc": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost: 62649/"
}
}
}
and here's the setup:
UPDATE: it looks like another key file is [SolutionFolder]\.vs\config\applicationhost.config
:
<site name="My_AspMvc" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\MySoln\My_AspMvc" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:62649:localhost" />
<binding protocol="https" bindingInformation="*:44315:localhost" />
</bindings>
</site>
Two important elements to the puzzle:
if you create a new ASP NET Core project, start it up and then copy the SSL port to your existing project, that port will work from then on. It is clearly being registered somewhere global to the system. Without creating the new project, the port won't work.
note that an easy way to mimic this whole process is to just open the launchSettings.json
in an existing, working process and randomly change the SSL port number by a few digits. It won't work.
OK, finally found this: Where do I specify my SSL port for IISExpress?
Noting that in: https://learn.microsoft.com/en-us/iis/extensions/using-iis-express/running-iis-express-without-administrative-privileges
... the SSL port must be between 44300 and 44399. My problem was, I was not keeping to this range.
Just a quick summary of all these findings:
C:\Users\[UserName]\Documents\IISExpress\config\applicationhost.config
[SolutionFolder]\.vs\config\applicationhost.config
[SolutionFolder]\.vs\config\applicationhost.config
[ProjectFolder]\Properties\launchSettings.json
[SolutionFolder]\.vs\
and it will be rebuilt on the next debug launch (so this is an option rather then editing)