2

我的 ASP.NET MVC 应用程序的 ASP.NET 预编译在部署到 AppHarbor 时失败,表面上是因为在 Razor 视图中引用了不存在的类型。这可能是正确的,但哪个文件有误!?

Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.17929
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.

d:\temp\0kxqxggv.qii\temp\root\aecd3928\90d8ef26\App_Web_24m5b001.0.cs(36): error CS0234: The type or namespace name 'User' does not exist in the namespace 'MyApp.Models' (are you missing an assembly reference?)

[HttpCompileException]: d:\temp\0kxqxggv.qii\temp\root\aecd3928\90d8ef26\App_Web_24m5b001.0.cs(36): error CS0234: The type or namespace name 'User' does not exist in the namespace 'MyApp.Models' (are you missing an assembly reference?)
   at System.Web.Compilation.AssemblyBuilder.Compile()
   at System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(AssemblyBuilder builder)
   at System.Web.Compilation.WebDirectoryBatchCompiler.<CompileNonDependentBuildProviders>b__0(AssemblyBuilder assemblyBuilder)
   at System.Web.Compilation.CompilationUtil.CompileParallel(ICollection assemblyBuilders, Action`1 action)
   at System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(ICollection buildProviders)
   at System.Web.Compilation.WebDirectoryBatchCompiler.Process()
   at System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors)
   at System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors)
   at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallback callback, IEnumerable`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
   at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
   at System.Web.Compilation.Precompiler.Main(String[] args)




Website precompilation failed with exit code 1. Precompilation can optionally be disabled in application settings
4

2 回答 2

0

您是否尝试过在 Visual Studio 上启用视图编译?如果您启用它,您可以在您的 ide 上调试错误

在项目内的 .csproj 文件中将 MvcBuildViews 更改为 true -> 属性组

<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <PropertyGroup>
  <MvcBuildViews>true</MvcBuildViews>
 </PropertyGroup>

在 ASP.NET MVC 中编译视图

于 2014-03-21T12:51:50.413 回答
0

这可能很旧,但它可能会帮助其他人知道如何阅读这种日志以及将来在哪里查找错误。

因为它位于错误日志的第 4 行。

d:\temp\0kxqxggv.qii\temp\root\aecd3928\90d8ef26\App_Web_24m5b001.0.cs(36): error CS0234: The type or namespace name 'User' does not exist in the namespace 'MyApp.Models' (are you missing an assembly reference?)

有足够的信息可以知道错误发生的位置原因。

哪里:在这个名为的文件上App_Web_24m5b001.0.cs位于d:\temp\0kxqxggv.qii\temp\root\aecd3928\90d8ef26\App_Web_24m5b001.0.cs在线(36)

为什么: The type or namespace name 'User' does not exist in the namespace 'MyApp.Models' (are you missing an assembly reference?)

注意如果您使用源代码控制部署到 appharbor,可能是您已更改User并忘记包含导致此错误的提交更改。至少那是发生在我身上的事情。

于 2017-01-10T10:10:15.027 回答