Hot Reload For CSS Not Working With Blazor WebAssembly Hosted - visual-studio

I noticed the following behaviour in Visual Studio 2022 (version 17.0.0) with a .Net 6.0 Blazor project:
Create a new Blazor WebAssembly project and DO NOT select the 'ASP.NET Core hosted' option.
Run the application without debugging.
Ensure Hot Reload is enabled
Make a change to the CSS. You will notice the browser instantly displays the change without needing a refresh / reload.
Repeat the steps above but this time during step 1 select the 'ASP.NET Core hosted' option. Now the CSS hot reload functionality is not working, even though making a change to the razor page itself does still hot reload (such adding or changing a HTML element).
According to the documentation*, hot reload is supported by WebAssembly when running without a debugger. I can't understand why only the CSS hot reload does not work if the 'ASP.NET Core hosted' option is chosen. The CSS and server appear to be unrelated.
*https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights/

Ok, so this is what I did in order for an existing project (web assembly hosted version) to work with .net hot reload WITHOUT DEBUGGING:
Install Visual Studio 2022.
Download and install latest version of sdk and runtime. You could already have them but just to be safe:
SDK and Runtime
Make sure your solution is targeting .NET 6 or update the existing solution to .net 6. Follow the steps provided here: Update to .NET 6 from .NET 5
Go to Tools -> Options and check everything that is connected to hot reload including the CSS Hot Reload box like this:
Delete .bin and .debug folders from your solution, restart your PC and rebuild the solution after restart.

I was facing this problem while working with blazor server projects with .net 7 and this solution was very usefull for me and solved the problem for hot reloading on updating css files on blazor server projects.
Even you don't need to do refersh for your page.
https://www.nuget.org/packages/Toolbelt.AspNetCore.CssLiveReloader/1.1.4?_src=template
I hope this is useful for you.

Related

is it normal that Hot Reload VS 2022 rebuild my project?

I am new in .net core 6 because I just finished migrating my project.
I would like to know if this behavior is normal about the native hot reload in vs 2022.
I am on a .Net Core 6 Web App and when I modify a razor page while i'm running without debugging (ctrl +f5), the whole web project is rebuilt and this results in a reload of the application, which for me is not really a hot reload.
Did I miss something ? Or is it the normal behavior ?
I finally found the issue here, looks like a bug because my project configuration is not named "Debug"

How to avoid to recompile project every time I made a change to a view in .NET Core project?

I am new to .NET Core 6 project using Razor views. One problem I am having now is that, every time I make a minimal change to a page, I need to recompile so that I can see the change in the browser.
I am using IIS Express as the server. That way, I can develop while the server is still running, but there is a thing left to solve, and it is to avoid to recompile the project when I change a view.
I realized if I make a change to a view, change is not seen until I recompile the project.
Any help?
I think what you want is Hot Reload:
Supported ASP.NET Core Scenarios
For ASP.NET Core developers who are targeting .NET 6, there are additional capabilities not available for lower versions of .NET. These capabilities include:
CSHTML: Editing a Razor CSHTML file supports many types of edits.
Browser Refresh: Editing a razor file automatically refreshes the changes in your web browser when debugging. This feature was
previously only available when starting the app without the debugger.
CSS Hot Reload: You can change CSS files while the app is running, and changes are applied immediately to the running app as you type.
No Debugger: You get Hot Reload support when using Visual Studio to start your web app without the debugger (CTRL-F5).
You can enable Hot Reload by going to Tools → Options → Debugging → .NET / C++ Hot Reload:

ASP.NET Core precompiled views on publish

I've previously created an ASP.NET Core project with .NET Core 2.0 preview 1 and Visual Studio 2017 15.3 preview. Just the default stuff from the project template, no custom code yet. Then I used the Publish command and have everything copied to the directory bin\Release\PublishOutput. All nice and good. 5 MB, can be deployed to the production web server and it works.
Now I've tried the same thing with VS Code and just won't get anywhere. I created the project with dotnet new mvc and opened it in VS Code with code .. After closing and opening it a few times and editing .cs files, I think I've now jumped over all the hurdles that VS Code comes with. I can run the application locally.
But the publishing doesn't quite produce the desired result. I run dotnet publish -c Release manually because VS Code doesn't seem to offer anything here. I get tons of files in bin\Release\netcoreapp2.0, along with a subdirectory called publish. Both have a copy of MySite.dll and MySite.pdb, but no precompiled views DLL. Also, the publish directory has 54 MB of runtime DLLs that weren't required for what Visual Studio gave me.
What is the intended method to publish an ASP.NET Core MVC application with VS Code? Everything is the latest version, downloaded and installed today.
Do I need components from the full Visual Studio to get the complete publishing experience, with all the advertised features?
For the record, I have recently discovered in ASP.NET Core 2.0 preview 2 that this has been resolved. A project created with dotnet new mvc has the MvcRazorCompileOnPublish property set in the csproj file, and dotnet publish does the same as publishing through Visual Studio 2017 (15.3) now.

Visual Studio keeps requesting missing web components

When I open a particular mvc 3 website project in VS 2010 I get the following message:
The Web Project "X" requires missing web components to run with Visual Studio. Would you like to download and install them using the Web Platform Installer now?
ASP.NET Web pages with Razor syntax.
When I click yes
The web platform installer shows with the message that "0" items need to be installed.
My other mvc 3 projects do not show this behavior
Not a major inconvenience, but still...
thoughts any one?
I got the same error after reinstalling my computer.
I came to this conclusion, VS needs IISExpress to load my additional project. The addition projects has a webservice and it can run locally. Even if my endpoints points to a local address it still needs the IISExpress (standard IIS 7.5 does not respond the endpoint request) to open from VS (im running VS2010).
So after installing IISExpress i could reload my project in VS.
C.,
That shouldn't happen, and it would be interesting to figure out why. In the meantime, you should be able to turn this off by unchecking the "Package Restore" checkbox in Visual Studio's Options dialog. (Select "Package Manager" in the tree view to find it.)
If it's happening only for specific projects, you can solve this more surgically by removing the packages.config file for the affected project. In fact, if you want to do root cause analysis, you should look into why that file exists and how it got there.
HTH,
Clay

the application for project is not installed

I'm opening a solution that was apparently built on Visual Studio 2003 (not sure, I don't know anything about it) and trying to migrate to 2010. When trying to migrate I get the message:
the application for project '' is not installed make sure the application for the project type (.csproj) is installed.
If I open each one of the single projects of the solution they migrate fine but not the solution itself.
Right-click on the project file, then "Reload"
If your solution opens, but your project is showing as "incompatible", it may need to just reload. This worked for me when running an update from VS, and it did not recognize my njsproj
I know this is an old question, but it is still occurring in VS 2013.
I had an old VS 2003 web application. I opened it in VS 2013 (Ultimate) and had the error message:
Could not find the server on the local machine.
Creating a virtual directory is only supported on the local IIS server
along with
The application for project is not installed.
Yes, I am upgrading, and yes, I don't have some other elements ready. Giving me errors is fine - but why are you not completing the migration/load of the project. I can't fix the other issues if you don't LOAD ANYTHING! You loaded the subprojects, and then you told me that I should choose a later .NET Framework. Great, I did that. So why didn't you just finish loading the main project and let me fix the errors?
Lots of attempts to fix this failed. My final solution, just to get the project loaded was {arrow pierces chest, dies with Arghhhhhh on his lips}...
I located the {project}.csproj file. I found the <Reference> sections. The paths to the .NET Framework components were no longer valid and referred to old versions no longer installed (yeah, upgrading, remember?). I manually changed the paths to refer to .NET Framework 4.5 components. The project still didn't load.
Then I located the {project}.csproj.webinfo file. It referred to http://localhost/{stuff}/{project}.csproj, so I just set it to {project}.csproj. No luck. Then I just renamed the webinfo file to hide it. Eureka, the project was hot!
The project loaded, I got the "You have completed the first step in converting your Visual Studio .NET 2003 web project. To complete the conversion, please select your project in the Solution Explorer and choose the 'Convert to Web Application' context menu item." Which, of course, is not present, but is present as the very last item in the Project menu. Then I got the "This action will add designer and code behind files required for converting Web site projects to Web application projects. Do you want to continue?" You bet your posterior I want to continue! And now I have a project I can actually start to fix. Thanks, Microsoft, for the informative error messages.
If your projects individually migrate fine, then create a new blank visual studio 2010 solution, and add new projects individually (right click on solution->add->existing project)
But I'm not sure that your projects will load fine individually. There are project types that require some additional software to be installed in order to be supported. The most frequent problems I face are old projects built with old versions of asp.net mvc (1 or 2) and I have asp.net mvc 3 installed...or really old projects built with asp.net ajax...In those cases, you have to install that additional software and then import project, or find a tool to upgrade that project type to a newer version.
I found a solution that worked for Visual Studio 2017.
In Visual Studio, go to Tools > Extensions and updates. At the upper-right search box, search for "integration". It should come up with Analysis or Diagnostic Tools (or similar). Click Disable, then Enable. Exit the dialog, and close Visual Studio. Relaunch and open your solution again. Your projects will still complain they can't be loaded because of incompatibilities, but now you can right-click them individually and select "Reload Project" and they should load fine.
Credit goes to Paul Potter and Paul Shaughnessy at https://developercommunity.visualstudio.com/content/problem/216061/project-incompatible-application-not-installed.html - I just did the verification work, condensing the information, and delivery :)
Adding this answer as reference for people who landed here for missing ".smproj" file.
This issue can arise due to various project files missing. For me, it was because of ".smproj" file missing which is Project file for SQL Server Analysis Services(SSAS). I re-installed SQL Server Data Tools (SSDT) and restarted the Visual studio.
Originally Answered here
Sometimes the SSIS or SSAS Extension in "Manage Extension" is disabled in the settings and must be Enabled manually. And then restart Visual Studio
It happened to me as wel.
You usualy do really need only to reload project in the solution. But in some cases you maybe:
didn't install SQL Server Data Tools (SSDT) for VS
have to enable SQL Server Data Tools manualy in the Extensions
If you have both things settled then try to reload project again. This happened to me when I moved from VS2019 to VS2022 and extension was somehow disabled.
I am using visual studio 2019 and I was faced with this issue when I reopened my ASP.Net webform App in visual studio after modifying for install SSDT.
this problem happens when Visual studio packages will modify (Especially when SSDT will be installed).
To solve this problem you have to go to you project folder and looking for the folder that named '.vs', this folder is hidden.
Deleting these folder will solve the problem because after that when you will open your project with visual studio, it will create the folder again.
Adding this for those who face issues for SSRS projects in VS2017 from earlier version as this comes up in google search.
In Visual Studio, go to Tools > Extensions and updates. Download the below :
Microsoft Reporting Services Projects
Microsoft RDLC Report Designer
In SSIS 2017, t the upper-right search box, search Microsoft Integration Services Projects.
go to Tools > Extensions and updates.
Enable -"Microsoft Integration Services Projects"
This will help to resolve the issue re-launch the SSIS
For my case, I disabled this extension and turns out, it is needed.
Enabling it resolved my problem.
In VS2019 Before you try any of the above right click the solution and click "Resolve Errors" no kidding that made my tabular model solution being available again.
For me what worked was a variation of #vapcguy solution.
Go to #vapcguy link for Paul Potter and Paul Shaughnessy solution: https://developercommunity.visualstudio.com/content/problem/216061/project-incompatible-application-not-installed.html - I
Follow comment on Paul Potter's post by Albert Romeo
Integration Services Plugin was disabled(as explained before: Goto Tools > Extensions and updates > and search for integration/analysis/reporting and enable application
I had to enable integration services, then reload project. I don't know why since I've been using the same SSIS project several times a week for months.

Resources