-
Notifications
You must be signed in to change notification settings - Fork 220
Integration tests with ASP.NET Core causes missing references from Razor files #1212
Description
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
- Build the attached
IntegrationTestSample.zip
solution. - Run the site and confirm the home index page works
- Use the Test Explorer to run the
GetHomeReturnsOKAsync
test
Expected result
The test should pass with a successful OK response from the server.
Actual result
The test fails with errors such as:
[xUnit.net 00:00:06.8955637] XUnitTestProject1.Tests.GetHomeReturnsOKAsync [FAIL]
[xUnit.net 00:00:06.8973988] Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException : One or more compilation failures occurred:
[xUnit.net 00:00:06.8978938] 0q2sc41d.qfp(10,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
[xUnit.net 00:00:06.8984156] 0q2sc41d.qfp(11,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
[xUnit.net 00:00:06.8988809] 0q2sc41d.qfp(12,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
[xUnit.net 00:00:06.8993828] 0q2sc41d.qfp(15,36): error CS0234: The type or namespace name 'ViewFeatures' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
[xUnit.net 00:00:06.8998931] 0q2sc41d.qfp(16,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
[xUnit.net 00:00:06.9003332] 0q2sc41d.qfp(18,86): error CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
[xUnit.net 00:00:06.9007670] 0q2sc41d.qfp(18,86): error CS0518: Predefined type 'System.Boolean' is not defined or imported
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).