For my web application I need to provide the response right after deployment as fast as it possible. To achieve this goal I would like to add NGEN to my publish configuration. How can I do it via Visual Studio or by manual editing of all involved .CSPROJ
files?
If you want to know how to run command after the web application has published successfully.
I suggest you could consider adding below config into the csproj.
<Target Name="CustomPostPublishActions" AfterTargets="GatherAllFilesToPublish">
<Message Text="This is custom target" Importance="high" />
<Exec Command='yourcommand line codes'/>
</Target>
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
You could first start by hand and run ngen for all files found in your bin folder and see then, what happens. Most sources seems to tell it is not that significant.
I would start first to check what happens. If I remember you have "health checks" for that. Also I believe you can ask for launching the site once dpeloyed at least from VS.
Also it happens the time is spent in user code depending on what you are doing when the app starts...
I would look more closely at what happens for example you can still have a compilation step (even for a "precompiled app", you can still have some stuff being precompiled on the fly). If I remember you have "ASP.NET Health" events allowing to cach this kind
of things.
Sometimes it turns out just to be something being done explictely in the code and that is forgotten (loading images in a cache or whatever rather than waiting for the first use).
Member
3 Points
64 Posts
How to include NGEN's invoke in a publish process?
Oct 03, 2019 03:52 PM|Gatwick|LINK
For my web application I need to provide the response right after deployment as fast as it possible. To achieve this goal I would like to add NGEN to my publish configuration. How can I do it via Visual Studio or by manual editing of all involved .CSPROJ files?
All-Star
48510 Points
18071 Posts
Re: How to include NGEN's invoke in a publish process?
Oct 03, 2019 05:10 PM|PatriceSc|LINK
Hi,
I would perhaps try first few IIS settings if not done yet such as https://www.nickedeye.com/iis-keep-website-alive-always-running/
Member
3 Points
64 Posts
Re: How to include NGEN's invoke in a publish process?
Oct 03, 2019 08:28 PM|Gatwick|LINK
Hi,
Tried this , didn't help too much. I still need to find a way of running NGEN while publishing my app. Any ideas?
Star
9831 Points
3120 Posts
Re: How to include NGEN's invoke in a publish process?
Oct 04, 2019 02:26 AM|Brando ZWZ|LINK
Hi Gatwick,
If you want to know how to run command after the web application has published successfully.
I suggest you could consider adding below config into the csproj.
Best Regards,
Brando
Member
3 Points
64 Posts
Re: How to include NGEN's invoke in a publish process?
Oct 04, 2019 10:37 AM|Gatwick|LINK
Ok, in this case the next step comes down to these
yourcommand line codes
Do you have any ideas what I should write there? I want to avoid explicit mentioning of all produced DLLs.
All-Star
48510 Points
18071 Posts
Re: How to include NGEN's invoke in a publish process?
Oct 04, 2019 11:18 AM|PatriceSc|LINK
You could first start by hand and run ngen for all files found in your bin folder and see then, what happens. Most sources seems to tell it is not that significant.
I would start first to check what happens. If I remember you have "health checks" for that. Also I believe you can ask for launching the site once dpeloyed at least from VS.
Also it happens the time is spent in user code depending on what you are doing when the app starts...
All-Star
48510 Points
18071 Posts
Re: How to include NGEN's invoke in a publish process?
Oct 04, 2019 01:05 PM|PatriceSc|LINK
ngen is described here: https://docs.microsoft.com/en-us/dotnet/framework/tools/ngen-exe-native-image-generator
For now you could just try this manually in your bin folder but accordng to https://www.eidias.com/blog/2017/1/4/does-it-make-sense-to-ngen-compile-your-aspnet-mvc-application it doesn't seems to make a significant difference.
I would look more closely at what happens for example you can still have a compilation step (even for a "precompiled app", you can still have some stuff being precompiled on the fly). If I remember you have "ASP.NET Health" events allowing to cach this kind of things.
Sometimes it turns out just to be something being done explictely in the code and that is forgotten (loading images in a cache or whatever rather than waiting for the first use).