Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompiled views not happening for self-contained apps #2268

Closed
Petermarcu opened this issue Nov 5, 2017 · 11 comments
Closed

Precompiled views not happening for self-contained apps #2268

Petermarcu opened this issue Nov 5, 2017 · 11 comments

Comments

@Petermarcu
Copy link
Member

I noticed startup time was absolutely terrible for my self-contained mvc application. I created a empty mvc project to try to repro.

dotnet new mvc

When I dotnet publish I get a folder with a PrecompiledViews.dll and the app starts really fast.
When I dotnet publish -r win-x64 I don't see the PrecompiledViews.dll and my app takes 3-4 seconds to start each time.

What do I need to do to get precompiled views for my self contained mvc application?

I tried adding:

<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<PreserveCompilationContext>true</PreserveCompilationContext>

To my project and that didn't seem to have any effect.

@pranavkm
Copy link
Contributor

pranavkm commented Nov 5, 2017

@Petermarcu was this initially reported in a different repo?

@Petermarcu
Copy link
Member Author

Not that I know of. I found this as I was trying to prototype a solution for some customers.

@pranavkm
Copy link
Contributor

pranavkm commented Nov 5, 2017

Ahh, I assumed you were porting this from a different repo and forgot to link it. We took out support for precompilation in 2.0.0 for standalone applications. This is fixed as part of 2.1.0 (aspnet/MvcPrecompilation#102).

@Petermarcu
Copy link
Member Author

Is there a reason it was pulled out in 2.0? There is a doubly bad problem for self contained apps in 2.0. First, pre-compilation doesn't work. Second, self-contained apps are using a Roslyn that is not crossgen'd.

@Petermarcu
Copy link
Member Author

I see, its related to being able to do the right thing based on the target rid (cross publish). Is that fix something that will show up for me as long as I use the newer SDK even if I target .NET Core 2.0?

@pranavkm
Copy link
Contributor

pranavkm commented Nov 6, 2017

Is that fix something that will show up for me as long as I use the newer SDK even if I target .NET Core 2.0?

Unfortunately not. The fix was made in the package's target so you'd have to update to our nightly to get it. The workaround we've been recommending for the 2.0.0 release is to publish it as a portable application and copy the precompiled binary to the standalone publish directory:

dotnet publish -c Release -o dir1
dotnet publish -c Release -r win7-x64 /p:MvcRazorCompileOnPublish=false -o dir2
cp dir1/AppName.PrecompiledViews.dll dir2/

@Petermarcu
Copy link
Member Author

Ok, I can probably do that for now. The company I'm working with is writing their own CLI tool chain as well so they will probably need to automate this workaround for their customers in their tools.

@pranavkm
Copy link
Contributor

pranavkm commented Nov 6, 2017

Great. Feel free to message me if you run in to issues. I'll close this since there's nothing further to do here.

@pranavkm pranavkm closed this as completed Nov 6, 2017
@Petermarcu
Copy link
Member Author

Petermarcu commented Nov 6, 2017

Is there any way to get the fix into something that doesn't ship in the newer packages and instead is delivered with the sdk so people don't have to jump to the latest target framework just to get this? These types of fixes seem like they should be sdk fixes that apply to all runtimes and not tied to a runtime version.

@pranavkm
Copy link
Contributor

pranavkm commented Nov 6, 2017

We could consider porting the fix to a patch release. There weren't any API changes, just changes to how we invoke the precompilation tool so it's a low risk change. cc @Eilon for thoughts on this.

@Petermarcu
Copy link
Member Author

Alternatively, is there a way for me to pull a package in that just has these targets and not move everything in MVC up to 2.1?

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants