Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET MVC 5 Razor View Errors with Multi Target Project References #2500

Open
wjchristenson2 opened this issue Apr 21, 2020 · 1 comment
Open

Comments

@wjchristenson2
Copy link

@wjchristenson2 wjchristenson2 commented Apr 21, 2020

Versions

  • Visual Studio version: 16.5.4
  • ASP.NET MVC 5.2.7
  • MVC 5 project = .NET Full 4.7.2
  • Class Library projects are dual targeted: NetCore 3.1 and Full 4.7.2

What happened

In an effort to start migration to .NET Core, we converted our class library projects to dual target NetCore 3.1 and Full 4.7.2. We've added our dual target class libraries as project references to the 4.7.2 MVC 5 web project. Everything compiles and runs fine. However, when editing our Razor views in Visual Studio, we get .NET Core errors when referencing objects in our dual target projects. The razor view editor appears to be using the NetCore 3.1 target instead of 4.7.2... If you drill-into an object reference in the razor view, it goes to the Core 3.1 flavor of our object instead of our full framework version.

Errors like: "The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runetime, Version=4.2.2.0....'. The type 'HttpRequest' is defined in an assembly that is not referenced... 'Microsoft.AspNetCore.Http.Abstractions'. etc. All related to our web project not having .NET Core references which shouldn't be a thing.

Our web project is targeting 4.7.2. We have manually edited the web projects' project references to utilize the AdditionalProperties="TargetFramework=net472" and SetTargetFramework to TargetFramework=net472. We have 4.7.2 set in the web.config for compliation and httpRuntime.

<ProjectReference Include="..\..\..\Shared Components\.NET\xxx.Web\xxx.Web.csproj" AdditionalProperties="TargetFramework=net472"> <Project>{079c59ed-768b-4176-b189-56c8e53c329b}</Project> <Name>xxx.Web</Name> <SetTargetFramework>TargetFramework=net472</SetTargetFramework> </ProjectReference>

Any help would be much appreciated. Thank you.

@wjchristenson2
Copy link
Author

@wjchristenson2 wjchristenson2 commented Jul 23, 2020

This is still an issue. Anyone have any insight into how to resolve? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.