0

项目文件已经从this answer推荐了这样做的方法。但是,这对我们的案例来说还不够。我们碰巧在另一个项目中共享了视图。一些文件使用共享的 .master 页面,在尝试使用 aspnet_compiler 时会导致编译错误。

我尝试以这种方式完成它:

<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
  <PropertyGroup>
    <TempFolder>$(ProjectDir)\..\temp</TempFolder>
  </PropertyGroup>
  <AspNetCompiler VirtualPath="temp" TargetPath="$(TempFolder)" PhysicalPath="other views location" />
  <AspNetCompiler VirtualPath="temp" TargetPath="$(TempFolder)" PhysicalPath="$(ProjectDir)" />
</Target>

事实证明 aspnet_compiler 要求TargetPath文件夹为空,所以这是不行的。VirtualPath仅使用and no尝试它TargetPath不起作用,因为它VirtualPath是临时的并且不会延续到第二个编译器调用。

有没有办法做到这一点?我们显然可以将母版页复制到该项目中,但这并不是一个好的解决方案。

4

1 回答 1

0

执行此操作的唯一方法是将 Razor 视图编译到 DLL 中,以便任何引用该 DLL 的应用程序都可以使用它们。Razor 团队为此创建了Razor Generator 。

于 2013-06-20T19:54:28.717 回答