title: Constant errors in asp.net core project
body: <p>I made a new asp.net project via cli, like this: dotnet new Angular.</p>
  
  <p>So I could run the site. Now I have added a dbContext, like this:</p>
  
  <pre><code> public void ConfigureServices(IServiceCollection services)
   {
      services.AddDbContext&lt;VegaDbContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString("Default")));
      services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  
      // In production, the Angular files will be served from this directory
      services.AddSpaStaticFiles(configuration =&gt;
      {
         configuration.RootPath = "ClientApp/dist";
      });
   }
  </code></pre>
  
  <p>But now I can't run the application anymore because I get these errors:</p>
  
  <blockquote>
    <p>D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error
    NU1107: Version conflict detected for
    Microsoft.Extensions.Caching.Abstractions. Install/reference
    Microsoft.Extensions.Caching.Abstractions 2.2.0 directly to project
    aspnetAngular to resolve this issue. 
        D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1107:  aspnetAngular -> Microsoft.EntityFrameworkCore 2.2.2 ->
    Microsoft.Extensions.Caching.Memory 2.2.0 ->
    Microsoft.Extensions.Caching.Abstractions (>= 2.2.0) 
        D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1107:  aspnetAngular -> Microsoft.AspNetCore.App 2.1.1 ->
    Microsoft.Extensions.Caching.Abstractions (>= 2.1.1 &amp;&amp; &lt; 2.2.0).</p>
  </blockquote>
  
  <pre><code>The build failed. Please fix the build errors and run again.
  </code></pre>
  
  <p>And this is how my csproj file looks like:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.1&lt;/TargetFramework&gt;
      &lt;TypeScriptCompileBlocked&gt;true&lt;/TypeScriptCompileBlocked&gt;
      &lt;TypeScriptToolsVersion&gt;Latest&lt;/TypeScriptToolsVersion&gt;
      &lt;IsPackable&gt;false&lt;/IsPackable&gt;
      &lt;SpaRoot&gt;ClientApp\&lt;/SpaRoot&gt;
      &lt;DefaultItemExcludes&gt;$(DefaultItemExcludes);$(SpaRoot)node_modules\**&lt;/DefaultItemExcludes&gt;
  
      &lt;!-- Set this to true if you enable server-side prerendering --&gt;
      &lt;BuildServerSideRenderer&gt;false&lt;/BuildServerSideRenderer&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.sqlServer" Version="2.2.2" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;!-- Don't publish the SPA source files, but do show them in the project files list --&gt;
      &lt;Content Remove="$(SpaRoot)**" /&gt;
      &lt;None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "&gt;
      &lt;!-- Ensure Node.js is installed --&gt;
      &lt;Exec Command="node --version" ContinueOnError="true"&gt;
        &lt;Output TaskParameter="ExitCode" PropertyName="ErrorCode" /&gt;
      &lt;/Exec&gt;
      &lt;Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /&gt;
      &lt;Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /&gt;
    &lt;/Target&gt;
  
    &lt;Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"&gt;
      &lt;!-- As part of publishing, ensure the JS resources are freshly built in production mode --&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " /&gt;
  
      &lt;!-- Include the newly-built files in the publish output --&gt;
      &lt;ItemGroup&gt;
        &lt;DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" /&gt;
        &lt;DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" /&gt;
        &lt;ResolvedFileToPublish Include="@(DistFiles-&gt;'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"&gt;
          &lt;RelativePath&gt;%(DistFiles.Identity)&lt;/RelativePath&gt;
          &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
        &lt;/ResolvedFileToPublish&gt;
      &lt;/ItemGroup&gt;
    &lt;/Target&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>So my  question is: how to solve this?</p>
  
  <p>Because it looks like if I am in a loop when I install de missing libraries - Microsoft.Extensions.Caching.Abstractions 2.2.0</p>
  
  <p>I do that. and then I will get a other error.</p>
  
  <p>Thank you</p>
  
  <p>Oke, I installed donet version .NET Core 2.2 SDK - Windows x64 Installer (v2.2.104)</p>
  
  <p>But I still get this errors:</p>
  
  <pre><code>Starting OmniSharp server at 2/22/2019, 4:58:53 PM
      Target: d:\Mijn Documents\UDEMY\aspnetAngular
  
  OmniSharp server started.
      Path: C:\Users\User.USER-PC\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe
      PID: 12764
  
  [info]: OmniSharp.Stdio.Host
          Starting OmniSharp on Windows 6.2.9200.0 (x64)
  [info]: OmniSharp.Services.DotNetCliService
          DotNetPath set to dotnet
  [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
          Located 3 MSBuild instance(s)
              1: Visual Studio Community 2017 15.9.28307.105 - "D:\Program Files (x86)\VisualStudio_2017\MSBuild\15.0\Bin"
              2: Visual Studio Enterprise 2017 15.0.26228.64 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
              3: StandAlone 15.0 - "C:\Users\User.USER-PC\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
  [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
          Registered MSBuild instance: Visual Studio Community 2017 15.9.28307.105 - "D:\Program Files (x86)\VisualStudio_2017\MSBuild\15.0\Bin"
  [info]: OmniSharp.Cake.CakeProjectSystem
          Detecting Cake files in 'd:\Mijn Documents\UDEMY\aspnetAngular'.
  [info]: OmniSharp.Cake.CakeProjectSystem
          Could not find any Cake files
  [info]: OmniSharp.WorkspaceInitializer
          Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
  [info]: OmniSharp.MSBuild.ProjectSystem
          No solution files found in 'd:\Mijn Documents\UDEMY\aspnetAngular'
  [info]: OmniSharp.MSBuild.ProjectManager
          Queue project update for 'd:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj'
  [info]: OmniSharp.Script.ScriptProjectSystem
          Detecting CSX files in 'd:\Mijn Documents\UDEMY\aspnetAngular'.
  [info]: OmniSharp.Script.ScriptProjectSystem
          Could not find any CSX files
  [info]: OmniSharp.WorkspaceInitializer
          Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
  [info]: OmniSharp.MSBuild.ProjectManager
          Loading project: d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj
  [info]: OmniSharp.WorkspaceInitializer
          Configuration finished.
  [info]: OmniSharp.Stdio.Host
          Omnisharp server running using Stdio at location 'd:\Mijn Documents\UDEMY\aspnetAngular' on host 14556.
  [warn]: OmniSharp.MSBuild.ProjectLoader
          Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore 2.2.2 was resolved.
  [warn]: OmniSharp.MSBuild.ProjectLoader
          Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.Abstractions (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.Abstractions 2.2.2 was resolved.
  [warn]: OmniSharp.MSBuild.ProjectLoader
          Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.Analyzers (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.Analyzers 2.2.2 was resolved.
  [warn]: OmniSharp.MSBuild.ProjectLoader
          Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.Relational (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.Relational 2.2.2 was resolved.
  [warn]: OmniSharp.MSBuild.ProjectLoader
          Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.SqlServer (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.SqlServer 2.2.2 was resolved.
  [fail]: OmniSharp.MSBuild.ProjectLoader
          Version conflict detected for Microsoft.Extensions.Caching.Abstractions. Install/reference Microsoft.Extensions.Caching.Abstractions 2.2.0 directly to project aspnetAngular to resolve this issue. 
   aspnetAngular -&gt; Microsoft.EntityFrameworkCore 2.2.2 -&gt; Microsoft.Extensions.Caching.Memory 2.2.0 -&gt; Microsoft.Extensions.Caching.Abstractions (&gt;= 2.2.0) 
   aspnetAngular -&gt; Microsoft.AspNetCore.App 2.1.1 -&gt; Microsoft.Extensions.Caching.Abstractions (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0).
  [warn]: OmniSharp.MSBuild.ProjectManager
          Failed to load project file 'd:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj'.
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj(0,0): Error: Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore 2.2.2 was resolved.
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj(0,0): Error: Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.Abstractions (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.Abstractions 2.2.2 was resolved.
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj(0,0): Error: Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.Analyzers (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.Analyzers 2.2.2 was resolved.
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj(0,0): Error: Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.Relational (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.Relational 2.2.2 was resolved.
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj(0,0): Error: Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.SqlServer (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0) but version Microsoft.EntityFrameworkCore.SqlServer 2.2.2 was resolved.
  d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj(0,0): Error: Version conflict detected for Microsoft.Extensions.Caching.Abstractions. Install/reference Microsoft.Extensions.Caching.Abstractions 2.2.0 directly to project aspnetAngular to resolve this issue. 
   aspnetAngular -&gt; Microsoft.EntityFrameworkCore 2.2.2 -&gt; Microsoft.Extensions.Caching.Memory 2.2.0 -&gt; Microsoft.Extensions.Caching.Abstractions (&gt;= 2.2.0) 
   aspnetAngular -&gt; Microsoft.AspNetCore.App 2.1.1 -&gt; Microsoft.Extensions.Caching.Abstractions (&gt;= 2.1.1 &amp;&amp; &lt; 2.2.0).
  
  [fail]: OmniSharp.MSBuild.ProjectManager
          Attemped to update project that is not loaded: d:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj
  </code></pre>
  
  <p>I don't understand. I get this error:</p>
  
  <pre><code>error: Package Microsoft.AspNetCore.App 2.2.2 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.AspNetCore.App 2.2.2 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)
  error: Package 'Microsoft.AspNetCore.App' is incompatible with 'all' frameworks in project 'D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj'.
  </code></pre>
  
  <p>But if I do this: dotnet --version</p>
  
  <p>I get the correct verison back: 2.2.104</p>
  
  <p>Oke did that. See:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.2&lt;/TargetFramework&gt;
      &lt;TypeScriptCompileBlocked&gt;true&lt;/TypeScriptCompileBlocked&gt;
      &lt;TypeScriptToolsVersion&gt;Latest&lt;/TypeScriptToolsVersion&gt;
      &lt;IsPackable&gt;false&lt;/IsPackable&gt;
      &lt;SpaRoot&gt;ClientApp\&lt;/SpaRoot&gt;
      &lt;DefaultItemExcludes&gt;$(DefaultItemExcludes);$(SpaRoot)node_modules\**&lt;/DefaultItemExcludes&gt;
  
      &lt;!-- Set this to true if you enable server-side prerendering --&gt;
      &lt;BuildServerSideRenderer&gt;false&lt;/BuildServerSideRenderer&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.EntityFrameworkCore.sqlServer" Version="2.2.2" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;!-- Don't publish the SPA source files, but do show them in the project files list --&gt;
      &lt;Content Remove="$(SpaRoot)**" /&gt;
      &lt;None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "&gt;
      &lt;!-- Ensure Node.js is installed --&gt;
      &lt;Exec Command="node --version" ContinueOnError="true"&gt;
        &lt;Output TaskParameter="ExitCode" PropertyName="ErrorCode" /&gt;
      &lt;/Exec&gt;
      &lt;Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /&gt;
      &lt;Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /&gt;
    &lt;/Target&gt;
  
    &lt;Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"&gt;
      &lt;!-- As part of publishing, ensure the JS resources are freshly built in production mode --&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" /&gt;
      &lt;Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " /&gt;
  
      &lt;!-- Include the newly-built files in the publish output --&gt;
      &lt;ItemGroup&gt;
        &lt;DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" /&gt;
        &lt;DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" /&gt;
        &lt;ResolvedFileToPublish Include="@(DistFiles-&gt;'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"&gt;
          &lt;RelativePath&gt;%(DistFiles.Identity)&lt;/RelativePath&gt;
          &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
        &lt;/ResolvedFileToPublish&gt;
      &lt;/ItemGroup&gt;
    &lt;/Target&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>But if I run the project I still get this error:</p>
  
  <pre><code>D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.SpaServices.Extensions from 2.2.0 to 2.1.1. Reference the package directly from the project to select a different version. 
  D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1605:  aspnetAngular -&gt; Microsoft.AspNetCore.App 2.2.0 -&gt; Microsoft.AspNetCore.SpaServices.Extensions (&gt;= 2.2.0 &amp;&amp; &lt; 2.3.0) 
  D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1605:  aspnetAngular -&gt; Microsoft.AspNetCore.SpaServices.Extensions
  (&gt;= 2.1.1)
  </code></pre>
  
  <p>And so I found a 'solution' for that - that you have to remove the PacketReference so I did that, but now I get this error:</p>
  
  <pre><code>D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.Razor.Design
  from 2.2.0 to 2.1.2. Reference the package directly from the project to select a different version. 
  D:\Mijn Documents\UDEMY\aspnetAngular\aspnetAngular.csproj : error NU1605:  aspnetAngular -&gt; Microsoft.AspNetCore.App 2.2.0 -&gt; Microsoft.AspNetCore.Razor.Design (&gt;= 2.2.0 &amp;&amp; &lt; 2.3.0)
  </code></pre>