Deleting PrecompiledViews.dll from ASP.Net Core 2 API

我的未来我决定 提交于 2019-12-02 08:03:21

问题


In .NET Core 2 Web API app, Publish to folder feature in MS VS 2017 produce:

<ProjectAssembly>.PrecompiledViews.dll
<ProjectAssembly>.PrecompiledViews.pdb

Offical docs says that PrecompiledViews related to precompiling Razor Views, but my API doesn't contain any views or static files, just REST endpoints that return json.

Using .Net reflector I found the PrecompiledViews.dll empty.

So I deleted PrecompiledViews.dll and tested my API and it seems to work fine without any warnings or exceptions.

Is it safe to delete PrecompiledViews.dll and pdp if the API not using any razor views? If yes, Is there option in VS 2017 to stop publishing unused PrecompiledViews?


回答1:


You are right, the precompile step always emits an assembly and doesn't check if there are actually views. You can disable the precompilation step by putting this into your csproj file:

<PropertyGroup>
  <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>

This will then activate the normal copilation context preservation (refs subfolder). To deactivate this as well, add

<PreserveCompilationContext>false</PreserveCompilationContext>

to the property group.



来源:https://stackoverflow.com/questions/46700399/deleting-precompiledviews-dll-from-asp-net-core-2-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!