从ASP.Net Core 2 API删除PrecompiledViews.dll [英] Deleting PrecompiledViews.dll from ASP.Net Core 2 API

查看:113
本文介绍了从ASP.Net Core 2 API删除PrecompiledViews.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET Core 2 Web API应用程序中,MS VS 2017中的发布到文件夹功能产生:

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



所以我删除了 PrecompiledViews.dll 并测试了我的API,它看起来可以正常工作,没有任何警告或异常。



如果API不使用任何剃刀视图,删除PrecompiledViews.dll和pdp是否安全?如果是,VS 2017中是否可以选择停止发布未使用的PrecompiledViews?

解决方案

您是正确的,预编译步骤始终会发出一个程序集,并且不检查是否实际存在视图。您可以通过将其放入csproj文件来禁用预编译步骤:

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

然后将激活正常的编译上下文保存( refs 子文件夹)。要同时停用此功能,请添加

 < PreserveCompilationContext> false< / PreserveCompilationContext> 

到物业组。


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?

解决方案

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.

这篇关于从ASP.Net Core 2 API删除PrecompiledViews.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆