Aspnetcore.docs: Build successful, but I'm having reference issues

Created on 6 Oct 2018  Â·  10Comments  Â·  Source: dotnet/AspNetCore.Docs

I keep getting these errors

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code
One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.

The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
+
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(RazorPagesMovie.Pages.Index_Page), @"mvc.1.0.razor-page", @"/Pages/Index.cshtml")]
The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
+
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"472eba6082c4cfd9087bb1b0a55099908614d006", @"/Pages/Index.cshtml")]
The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
+
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5bffd98f02597e6a09295a2131188dc64093be78", @"/Pages/_ViewImports.cshtml")]


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P4 Source - Docs.ms

Most helpful comment

I think this sample is slated for update on the sample update tracking issue #5495. We'll get to it as soon as we can.

All 10 comments

@khozanai What's the output when you execute ...

dotnet --version

... at a command prompt?

You may need to get the latest SDK :point_right: https://www.microsoft.com/net/download (Download .NET Core SDK under the macOS tab)

@khozanai What's the output when you execute ...

dotnet --version

... at a command prompt?

You may need to get the latest SDK 👉 https://www.microsoft.com/net/download (Download .NET Core SDK under the macOS tab)

when I run dotnet --version, I get this version: 2.1.4

You might want to go ahead and get 2.1.403 on there and see if that resolves the errors.

Unfortunately, I'm buried in a topic right now or else I'd get on my Mac and see what's what.

If you haven't figured out the problem by later this afternoon, I'll get on the Mac and see if I can repro your errors here.

Alright, thank you. I'll download the newer SDK and then test again.

I just ran the app again after the updated SDK, and got the same errors, twice. Here is a screenshot of the errors.

screen shot 2018-10-07 at 17 41 01

I'll try to repro that here in a few hours when I'm free. It's a slightly older 2.0-era app; so if I get the same result you're getting, the first thing I'll try to do is update the app to 2.1. I'll get back to you later today or this evening. Otherwise, @Rick-Anderson might recognize what's going wrong and let us know. He sees dev feedback on this set of topics and may have encountered this happening earlier.

Thank you for all your efforts in assisting to resolve this

For a quick check to see if upgrading the app will help, try using the following project file (RazorPagesMovie.csproj) and see what happens. It might still :boom: for other reasons, but it also might improve the situation ...

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" />
  </ItemGroup>

</Project>

Yup changing to 2.1, that made the app run, and its working fine now.

Thanks for the help

`<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
<!--        <TargetFramework>netcoreapp2.0</TargetFramework>-->
  </PropertyGroup>
  <ItemGroup>
       <!-- <PackageReference Include="Microsoft.AspNetCore.App" />-->
<!--    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />-->
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.5" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
    <!-- <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" /> -->
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Models\" />
  </ItemGroup>
    <ItemGroup>
   <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final" /> 
<!--        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />-->

</ItemGroup>
</Project>`

I think this sample is slated for update on the sample update tracking issue #5495. We'll get to it as soon as we can.

Was this page helpful?
0 / 5 - 0 ratings