Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Continue generating RelatedAssemblyPart on assembly if GenerateAssemblyInfo=false #2257

@rockerinthelocker

Description

@rockerinthelocker

@rynowak @pranavkm, Setting

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

in the csproj file prevents Razor assembly info generation (affecting app.dll and app.Views.dll) and such MVC apps throw (see below) when deployed to production servers because views are not found.


Now listening on: http://127.0.0.1:28447
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://example.com/  
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Route matched with {action = "Index", controller = "Home"}. Executing action SimpleMvcApp.Controllers.HomeController.Index (SimpleMvcApp)
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method SimpleMvcApp.Controllers.HomeController.Index (SimpleMvcApp) - Validation state: Valid
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action method SimpleMvcApp.Controllers.HomeController.Index (SimpleMvcApp), returned result Microsoft.AspNetCore.Mvc.ViewResult in 0.0237ms.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[1]
      Executing ViewResult, running view Index.
fail: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[3]
      The view 'Index' was not found. Searched locations: /Views/Home/Index.cshtml, /Views/Shared/Index.cshtml
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action SimpleMvcApp.Controllers.HomeController.Index (SimpleMvcApp) in 0.4997ms
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLCVQKE7G6Q7", Request id "0HLCVQKE7G6Q7:00000002": An unhandled exception was thrown by the application.
System.InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
   at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 5.1816ms 500 

This happens because SimpleMvcApp.dll is missing


[assembly: RelatedAssembly("SimpleMvcApp.Views")]
[assembly: RazorLanguageVersion("2.1")]
[assembly: RazorConfigurationName("MVC-2.1")]
[assembly: RazorExtensionAssemblyName("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")]

(workaround: add above assembly attributes manually)

and SimpleMvcApp.Views.dll is missing

[assembly: ProvideApplicationPartFactory("Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor")]

(workaround: add <GenerateRazorTargetAssemblyInfo>true</GenerateRazorTargetAssemblyInfo> to the csproj file).

Dev Machine Setup:
Visual Studio 2017 15.7 Preview 3
dotnet-sdk-2.1.300-preview2-008530-win-x64

Hosting Server Setup:
Windows Server 2012 R2
dotnet-hosting-2.1.0-preview2-final-win

Steps to reproduce:

  1. Create default MVC 2.1 project.
  2. Add <GenerateAssemblyInfo>false</GenerateAssemblyInfo> to csproj file.
  3. Add custom 'assemblyinfo.cs' with some assembly attributes.
  4. Publish to server, enable logging, and browse the site.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions