错误信息:
ERROR | Message:Failed to compile generated Razor template:
- (3:35) The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
- (3:63) Predefined type 'System.String' is not defined or imported
- (3:79) Predefined type 'System.Type' is not defined or imported
- (3:10) Predefined type 'System.Void' is not defined or imported
- (7:69) Predefined type 'System.Boolean' is not defined or imported
- (7:37) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
解决方法:
编辑csproj文件,在<PropertyGroup>新增:
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>