Christian Gollhardt
Christian Gollhardt

Reputation: 17024

How to dotnet publish with precompiled views for a non portable target?

I have this script:

# common paths
$buildFolder = (Get-Item -Path "./" -Verbose).FullName
$slnFolder = Join-Path $buildFolder "../"
$outputFolder = Join-Path $buildFolder "build"
$webMvcFolder = Join-Path $slnFolder "ConversioIt.Conmania"

# clear existing folder
Remove-Item $outputFolder -Force -Recurse -ErrorAction Ignore
New-Item -Path $outputFolder -ItemType Directory

# restore nuget
Set-Location $slnFolder
dotnet restore

# publish
Set-Location $webMvcFolder
dotnet publish --output (Join-Path $outputFolder "Portable")
dotnet publish --output (Join-Path $outputFolder "Win") -c Release -r win-x64
dotnet publish --output (Join-Path $outputFolder "Linux") -c Release -r linux-x64
dotnet publish --output (Join-Path $outputFolder "OSX") -c Release -r osx-x64
pause

My portable output (the first dotnet publish) does precompile the views.

However my Windows, Linuxs and OSX builds do not precompile the views. Instead I get the Areafolder with all the views in the publishing output.

I also set the MvcRazorCompileOnPublish property per this answer:

<PropertyGroup>
  <TargetFramework>netcoreapp2.0</TargetFramework>
  <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
  <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
</PropertyGroup>

Which does nothing change. I also use the AspNetCore.All Metapackage (2.0), which should automaticly define everything needed for precompilation, if I understood it correct?

So how can I make a standalone build (Which is runnable without .net, e.g. Linux/Win builds) to precompile the views?

Upvotes: 0

Views: 462

Answers (1)

J. Doe
J. Doe

Reputation: 2747

Razor view precompilation is currently unavailable when performing a self-contained deployment (SCD) in ASP.NET Core 2.0. The feature will be available for SCDs when 2.1 releases. For more information, see View compilation fails when cross-compiling for Linux on Windows.

Upvotes: 3

Related Questions