ASP.NET 5 - beta8: no rebuild in background - asp.net-core

Before beta8 it was possible to start a Web Application, change some of the code (e. g. the ViewBag.Message of the About-View), save and refresh the browser - voilá, the new Message is displayed without rebuilding the project.
Now when creating a new Web Application with beta8 which uses DNX and Kestrel this seems no longer to work. Any idea why?

Beta8 contains a new library called 'dnx watch' which monitors your project files for changes during execution and automatically rebuilds the project. Install it by running the following from a command prompt:
dnu commands install Microsoft.Dnx.Watcher
Additionally, make sure you've installed the beta8 web tools for Visual Studio.
Finally, make sure you're not running in debug mode as code changes will not reload projects while running with the debugger attached. CTRL+F5 will start your web project without the debugger.
You can read up on this and the other changes in beta8 here:
http://blogs.msdn.com/b/webdev/archive/2015/10/15/announcing-availability-of-asp-net-5-beta8.aspx

Related

VS2022: how to make ASP.NET Core 5 app show it's console window

In VS2019, when I start my ASP.NET Core 5 app, which just exposes an API, if that matters, a console window pops up for that app. There used to be some setting to decide whether to run it as a console / standalone app or host it in IIS Express. I always preferred the console / standalone version because it lets me see the logs in realtime.
In VS2022, when I start the very same project, no window appears at all, and, interestingly, neither do I see IIS Express starting up.
How can I get back to having the project start as a console app? (Except starting it from the command-line and then attaching the debugger.)
UPDATE:
ok, so at long last I noticed that, strangely, a minimized console window is being created and because I start a dozen projects (microservices), I didn't notice before, and procexplorer telling me that the executable had no window added to the confusion. So this is much less problematic, albeit still weird - why does this one particular application not start un-minimized? The only difference it has to all the other executables is that it uses ASP.net core while the others (all background services communicating via messagequeue) don't.
and this only in VS2022, in VS2019 all executables including this one start unminimize
You have to make sure, that you selected "IIS Express" as your debug profile
VS 2022 debug profile
I believe you are looking for this. Follow the steps highlighted in in each image:
Go to your project properties:
Then you will see that the console is open in the task bar.
In Visual Studio 2022 this is currently NOT POSSIBLE

Publishing web app from Visual Studio doesn't update views

I'm trying to publish changes to a .NET Core 3.1 web app from Visual Studio 2019 using FTP, however the process doesn't update my .cshtml views.
The app works properly on my local machine, I deleted the contents of the 'bin' directory before publishing, and my publish settings delete all of the existing files on the server before copying new ones over, so this process appears to be somehow copying over views which are no longer available anywhere?! I've not changed any of the 'build action' properties and most of the configuration in Startup is the default MVC template.
Microsoft docs reference a NuGet package (Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation) and using AddRazorRuntimeCompilation() in Startup, but this didn't seem to have any effect.
I find it incredibly bizarre that views aren't updated during a publish by default. I also find it bizarre that in this day and age SFTP appears to be unsupported (wth). Hopefully I'm just doing something wrong rather than this process being silly. Any ideas?
Restarting the Kestrel service used by my server seems to have resolved it...there has to be a more obvious solution though as this method requires shell access.

Attaching to process over SSH with VS2019 and ASP.NET core not working

I am running an asp.net docker container remotely. I have enabled SSH, mapped the port and also installed VSDBG in the container.
In visual studio I am able to attach to process over SSH. I choose my project dll file. There are no error alerts and it appears to be debugging but on every breakpoint there is this message:
The breakpoint will not currently be hit. The breakpoint is pending and will be resolved when debugging starts.
Also if I open modules window there is no entries.
What is going on? Why is remoe debugging not working?
There are usually two reasons:
1. project publication made with release instead of debug configuration
2. the projects are not consistent. There is a difference between the project on the local machine and the server.

Seamless compilation on file change on Visual Studio for Mac (ASP .Net Core)

When compiling a ASP .Net Core project without debugging in Visual Studio for Windows, subsequent changes to C# files trigger a new seamless compilation when reloading the website.
I tried it under VS Mac, but unfortunately it does not work. I either have to manually recompile the project, which open an unnecessary new browser window or lauch the command line "dotnet watch run" but it runs a compilation each time a file change an not each time I reload the website and there is at least 1 file change.
Is there a way to achieve the same behavior of VS Win or is it a feature of IIS Express?

Can Asp.net Core automatically detect View changes in a custom directory?

I have got a custom location configured for some views. e.g. /MyCustom/Views/Index.cshtml. The application can correctly find the views from /MyCustom/Views folder using this solution https://stackoverflow.com/a/36772778/1593334.
The only issue is that I have to build the application each time I change a view to reflect the changes in the browser. Is there a way to make the asp.net automatically detect these changes ?
There is a tool called dotnet watch.
dotnet watch is a development time tool that runs a dotnet command when source files change. It can be used to compile, run tests, or publish when code changes.
Basically, you add the Microsoft.DotNet.Watcher.Tools NuGet package to the tools section of your project.json and run the application using dotnet watch.
Here you can find the command arguments for running dotnet watch.
Then, while the application is running with dotnet watch, simply modify the source code of the application. The watcher will detect the change, recompile and rerun the application.
Best regards!