Reputation: 978
I have recently changed some projects from IIS ASP NET projects to Console Applications, using a custom web server. In both kinds of project, we ran the project as a console aplication (so we didn't actually use IIS),
However, as a web project, the profiler does not work. So we changed the project to be a console application, which makes the profiler work. Unfortunately, this removed the option to run a web browser and attach the debugger automatically. This appears in visual studio like so:
Console Application:
Web Project:
Is there a way to get this back whilst still being a console application?
I've tried adding this to the .csproj:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>52826</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:53107/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
<servers defaultServer="SelfHostServer">
<server name="SelfHostServer" exePath="" cmdArgs="-c http://localhost:52826/" url="http://localhost:52826" workingDir="" />
</servers>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
But this didn't seem to help. The more modern .net core apps seem to be console applications as well, but they somehow can start the browser and attach the debugger. We are using visual studio 2017, but we will happily upgrade to 2019 to fix the problem. The JetBrains Rider IDE also seems to be able to start a web browser and debug on any kind of project as well.
Upvotes: 4
Views: 2740
Reputation: 9195
Easy solution (uncertain if will work, let me know):
Since you mentioned upgrading to VS2019, I'm going to suggest that as the nicest solution.
Update all the project files to the new format. And all of them should have in the Properties>Debug the option to launch a browser.
Also the reason that it works in DotNetCore is because DotNetCore did away with the notion of running inside of IIS or similar, Kestral is hooked up from a Main
entry method just like console applications, allowing less confusion for situations such as yours. And VS2019 should support that arrangement no matter what your target framework is.
Upvotes: 4