Closed Liero closed 6 years ago
Hi @Liero. What are you trying to do? WebJobs supposed to be running in background and have no UI. Why are you trying to do that?
@mkArtakMSFT: In fact, I do have an application, that is supposed to be running on the background without UI, just like the Mvc.RenderViewToString sample does, but I'm forced to use the Web SDK anyway in order to make it work.
My WebJob is supposed to send email reminders in background, but in order to use Razor as "mail templates" I had to reference the web sdk
@pranavkm, can you please look into this one? Thanks!
but then I get runtime exception when I try to invoke the razor view.
What's the exception you're seeing? You likely need to set <PreserveCompilationContext>true</PreserveCompilationContext>
in your app - my guess is Razor compilation cannot find reference assemblies to compile against.
@pranavkm, you are right about the exception and setting PreserveCompilationContext does help indeed.
This solves my situation (feel free to close the issue), but:
it's still unclear to me, why project using Microsoft.NET.Sdk cannot compile the views without PreserveCompilationContext and Microsoft.NET.Sdk.Web can. What are side effects of PreserveCompilationContext.
are you sure that the project SDK should determine how the app will be published? If yes, it would be good to have an workaround.
are you sure that the project SDK should determine how the app will be published?
The Web.Sdk is opinionated about the kind of target you're deploying it and shows a dialog best suited for their targets. Not sure if there's a way to change this behavior - you could try asking at https://github.com/aspnet/websdk.
Hi, I have a console app that I want to deploy as web job. It's based on Entropy/samples/Mvc.RenderViewToString/ sample.
The problem is, that is uses
Microsoft.NET.Sdk.Web
rather thanMicrosoft.NET.Sdk
in order to render the razor views although it is not web application.When I invoke the publish dialog, it publishes it as web app, not as web job. When I replace
Microsoft.NET.Sdk.Webwith Microsoft.NET.Sdk, it shows the correct web job publish dialog, but then I get runtime exception when I try to invoke the razor view.