-
Notifications
You must be signed in to change notification settings - Fork 226
Integration tests with ASP.NET Core causes missing references from Razor files #1212
Comments
/cc @pranavkm |
Can anyone reproduce this with the sample I uploaded? |
Same problem here. With the previous Version it worked as I upgraded to the latest one I can not run integration tests anymore. Also tried your code and it does not work. |
@BrianVallelunga I can reproduce using the sample you provided. I also experienced the issue with @using in View not working with referencing dll directly. The dll was created in .net 4.6.1 and my web app is .net core 1.1.1 running in full .net framework in VS2017. I believe this is similar to issue 4686. |
Thanks for the confirmation. Hopefully we can get a workaround soon. This is holding up our move to VS 2017 right now. |
This looks like similar issues we encountered when migrating MVC. Give this a try. |
@NTaylorMullen I tried your suggestion and even manually copied the .deps.json file over to the test project. Unfortunately this did not fix the issue, though I agree that it seems like it could be related. |
Can someone from Microsoft please comment on this? |
@pranavkm @NTaylorMullen - any more suggestions here? |
@BrianVallelunga - Hi, I tried your project and was able to reproduce the failure, as well as fix it. These are a few known issues that we've already worked around in our (MVC team) functional tests. We need to do a better job getting this information out there. I've also started a conversation internally about how we can make this much much easier to figure out for simple MVC apps. Here's the complete project file with the fixes in place:
You also need to create an
The juicy workaround here is to get the |
I can confirm that this fixes my issue in my main codebase. Thank you for the help and I would encourage this information to be publicized. I'm astounded more people haven't run into this. |
We've made a decision to productize and harden the integration testing code that MVC is using to bootstrap our functional test websites. This will include validating common issues like the missing deps file. aspnet/Mvc#6233 I'm going to close this issue out. |
Closing this issue since we're following up elsewhere |
I tried the fix and it is still giving me the same error. Can you share the sample project after it is fixed? Thanks! |
See aspnet/Mvc#6613 |
…database. Also added black magic fix to make Startup from another project work. See aspnet/Razor#1212 A better way of doing this is coming in the future.
I think the main problem is that Visual Studio 15.3.3 asp.net core 2.0 xunit template creates a csproj file that is already broken. E.g. here is what it created in my project: And it gives the Razor compilation error in here: https://github.com/Ciantic/OksidiCom.AspNetCore/blob/fb11872b9e5ab9a015909dd34a76c737b05fbdce/test/OksidiCom.UserService.Test/Tests.cs#L120 (LoginIssuesToken test) If there is a simple fix by manipulating the csproj, the VS template for xunit test project should include it already. |
Hi, it looks like you are posting on a closed issue/PR/commit! We're very likely to lose track of your bug/feedback/question unless you:
Thanks! |
@rynowak
The test projects targets netcore2.0. It references Microsoft.AspNetCore.All, Microsoft.AspNetCore.TestHost, and Microsoft.NET.Test.Sdk. I checked that the output dir (bin\Debug\netcoreapp2.0) contains *.deps.json and xunit.runner.json. The error happens even for empty views - I have errors even if View's content is just |
Also please note that the issue was closed before .NET Core 2.0 was released. It could makes sense if it was going to be fixed in the upcoming release. But it's not. I'm having it in netcore2.0 rtm:
Please reopen the issue. The mentioned issue aspnet/Mvc#6233 is also closed. So it's pretty unclear what developers are supposed to do or expect. Here's a demo project - https://github.com/evil-shrike/aspnetcore-tests-bug |
@evil-shrike you'll need to target the Web Sdk ( |
@evil-shrike that would help. Would you like to send a PR for it? |
@pranavkm ok, I'll make a PR. |
Yup, it's definitely the minimum feature to enable to get view compilation working. |
@rynowak's solution to add the manual step to copy Details in this SO Q&A: https://stackoverflow.com/questions/46464373/asp-net-core-testserver-results-in-http-500-for-razor-views/46464374 |
Good news, looks like a fix for this is on the ASP.NET Core 2.1 roadmap: (emphasis mine)
|
@bgever : Optimally the solution will allow shadow copying |
Title
Integration tests with ASP.NET Core causes missing references from Razor files
Functional impact
When attempting to run an integration test against an ASP.NET Core 1.1.1 site using the full .NET Framework, Razor views are unable to resolve references to namespaces like
System
Minimal repro steps
IntegrationTestSample.zip
solution.
GetHomeReturnsOKAsync
testExpected result
The test should pass with a successful OK response from the server.
Actual result
The test fails with errors such as:
Further technical details
This seems to be a regression of #755 and aspnet/Mvc#4686
Unlike those other issues, there is no third project involved here. Just the site and test projects.
This was not an issue until we switched to VS 2017 from VS 2015 (with project.json and xproj).
The text was updated successfully, but these errors were encountered: