【发布时间】:2018-01-14 14:59:00
【问题描述】:
我有一个使用 .NET Framework 4.5.1 构建的 Web 应用程序
当我从 VS2017 发布它时,VS2017 添加了不需要的 dll,未在参考文献中列出,它们是:
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.Webpages.Deployment.dll
System.Web.Webpages.Razor.dll
当我尝试从 VS2013 发布时,它给出了运行时错误(剃刀丢失),我的项目没有任何 cshtml 文件,当然它没有使用任何剃刀视图。
为什么 VS2013 需要 razor,有什么方法可以阻止 VS2017 在发布时添加 razor 和其他不需要的 dll?
谢谢!!
**编辑:** 通过研究,我发现在我的 csproj 文件中添加 <PreserveCompilationContext>false</PreserveCompilationContext> 会阻止 VS2017 添加剃须刀,但现在发布后我收到运行时错误 Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
【问题讨论】:
标签: c# razor visual-studio-2013 visual-studio-2017