ServiceStack as Windows Service with Razor - Setup Project - razor

I have a servicestack project using razor exposed through a windows service, and need to create a setup project to install it (as opposed to the batch files in the demo's I've seen).
Any suggestions on how to accomplish this with a packaged setup project? Looking at the folder where the windows service files were installed, it only has the dll's, not the razor views... so I coped those over, and now I see this:

Not sure why you're getting that error, can you double-check that you're deploying the orignal Razor source files and not some interim build.
Otherwise some other options for hosting Razor is to change them to Embedded Resources, that way the original Source files get compiled into your .dll so you don't need to deploy them to your project.
Or you can pre-compile Razor Views that way the implementation is compiled into the .dll.

Related

Razor "cshtml.g.cs" files not being generated

I created a brand new .net core 2.2 web application project, but I get this error when building:
I already reinstalled VS 2019 (16.3.10) and the .Net Core SDKs. Same project builds fine on other machines. Seems like razor has some global configuration for generating these cshtml.g.cs files, but reinstalling VS was not enough to fix it, these files are not being generated inside obj\Debug\netcoreapp2.2\Razor\Views folder.
What is the possible reason for this?

Changes to *.cshtml files not get autodetected on dotnet core 3.0

Steps to reproduce a problem:
Download and install dotnet core 3.0
Create a new project: dotnet new webapp -n MyApp
Run app dotnet run
Navigate to http://localhost:5000/Privacy
Edit Privacy page MyApp\Pages\Privacy.cshtml
Refresh
The changes do not get picked up by the toolkit and old page is rendered.
Same flow for dotnet core 2.2 (freshly installed) results in an updated page.
Is there a flag, which needs to be set somewhere within config to get autodetect working for 3.0 or is this a bug?
Use the dotnet CLI command to watch run your project:
dotnet watch run
Optionally you can watch run without hot reload enabled:
dotnet watch run --no-hot-reload
Add this instruction to the project file [ProjectName].csproj:
<ItemGroup>
<!-- extends watching group to include *.cshtml and *.razor files -->
<Watch Include="**\*.cshtml;*.razor;*.js;*.css" Exclude="**\obj\**\*;bin\**\*" />
</ItemGroup>
For further information see Microsoft DotNet 5.0 Documentation.
While searching the root cause of that issue i came accross with that SO question. To resolve that issue you need to add Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package to your project and modify your Startup.cs like below.
Inside ConfigureServices method of Startup.cs
For ASP.NET Core MVC:
IMvcBuilder mvc = services.AddControllersWithViews();
mvc.AddRazorRuntimeCompilation();
For ASP.NET Core Razor Pages:
IMvcBuilder mvc = services.AddRazorPages();
mvc.AddRazorRuntimeCompilation();
PS: Do not forget to use this feature 'dotnet-watch' for development environment only since it does not make sense for production environment for most cases.
Source: https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
2021 UPDATE (Better Solution): You do not need to execute AddRazorRuntimeCompilation method in Startup.cs. You can keep this feature running by adding a value to projects debug configuration.
Please add new Environment variable to Project Properties > Debug > Environment variables
Name: ASPNETCORE_HOSTINGSTARTUPASSEMBLIES
Value: Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
I'm not entirely sure this is the same issue, but ASP.NET Core 2.2 introduced an In Process IIS hosting model. This provides a lot of performance benefits in a production environment, but basically negates one of ASP.NET Core's most useful development features: automatic updates. If you're using the In Process model in development, you'll need to build after code changes, just like with older ASP.NET MVC sites. You can switch the hosting model back to the Out of Process model (the old way) either by going to your project properties or editing your csproj. In properties, there's a dropdown now on the Debug tab, which corresponds to the <AspNetCoreHostingModel> tag in the csproj.
UPDATE
For what it's worth, I've actually seen this behavior to be somewhat random actually. Some changes for me seem to kick off an automatic build like they used to, while other changes don't show up unless I manually build. There doesn't seem to be a lot of rhyme or reason to which changes required what either. It's possible that the tooling for this isn't quite there yet, and a future update to Visual Studio may make the In Process model behave consistently like the Out of Process model did with code changes in development. All I know is that switching to Out of Process definitely resolves all issues with this, so it's related to the In Process model in some way.

How do I import Primefaces 6.0 source as maven project in Eclipse?

I followed Building From Source https://github.com/primefaces/primefaces/wiki/Building-From-Source instructions. Building the SNAPSHOT version project from command works well.
However, importing it into eclipse using the Existing Maven Projects wizard gives me a lot of errors in the Problems view. I fixed the lifecycle mappings by setting all to ignore.
I realized the generated source code in the target/generated-sources/maven-jsf-plugin directory but it was not picked up by the m2e plugins as a source folder automatically. So I included it into the eclipse build path manually. But then again, many compile errors show up in the generated code.
Does anybody use eclipse as IDE for primefaces development? How do you setup the eclipse project to develop primefaces?
The eclipse project uses Java Compiler compliance level 1.5 derived from the pom.xml maven-compiler-plugin settings. Setting the Java Compiler compliance level to 1.6 solved the issue for me.

Any solution to make Browser Link work with ASP.NET Core RC2 project while using gulp?

I use Visual Studio 2015 Community with ASP.NET Core RC2. I have all the required tools installed and everything is working fine with one exception.
When I create a new ASP.NET Core Web Application or load a saved ASP.NET Core Web Application the View in Browser functionality of Browser Link loads a wrong address in the Web Browser.
If I type the correct address in the browser, the Browser Link Dashboard is updated and the application is listed as Unknown.
After a lot of reverse engineering and tinkering i found that the problem is linked to the Node.js module gulp in the node_modules folder of the project.
If I delete the gulp folder before loading the project Browser Link works just fine. It is still working after the gulp module is downloaded by the IDE back in the node_modules folder. If I reload the solution without deleting gulp, Browser Link doesn't work anymore.
Does anybody have a solution?

How do you define a default html in silverlight?

How do you define a default html in silverlight?
In the Microsoft Development Environment, Microsoft Visual Studio, when I build a silverlight project, the code auto-generates an HTML file in the Release directory (and in the Debug directory)
Yet, I have seen some projects that have a Default.html file among the project files. And when I run the program in debug mode, the default.html comes up.
How is this done? Where is the settings which tell Visual Studio which html to use when running or debugging. In another project, when I create a project from scratch, the program runs a generated html in the debug or release directory.
How do I include my own html in a silverlight project?
In the project settings, I found you can unselect the option to have the compiler auto-generate an html or use one that you define.