aspnet / Templating

[Archived] ASP.NET Core templates for .NET CLI and Visual Studio. Project moved to https://github.com/aspnet/AspNetCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NET Framework 2.1 Web project doesn't restore

seancpeters opened this issue · comments

Create a new project in Visual Studio with settings:

  • On the new project dialog, select: "ASP.NET Core Web Application". Click ok.
  • On the second screen, select: ".NET Framework", "ASP.NET Core 2.1", "Web Application". Click ok.

The project creates, and attempts to restore. The error list is as follows:
image

@seancpeters can you share the .csproj file VS generated?

Strange, I'm now getting only subsets of those errors.

For a .NET Framework ASP.NET Core 2.1 Web app with no auth, here's the .csproj:

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

  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <DebugType>full</DebugType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1"/>
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
  </ItemGroup>

</Project>

And the errors:
image

And for a .NET Framework ASP.NET Core 2.1 Web app with individual auth, here's the .csproj file:

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

  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <UserSecretsId>aspnet-WebApplication168-84BE6A75-DF6A-4C63-BAD4-3BC5CED1F7CF</UserSecretsId>
    <DebugType>full</DebugType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1"/>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="2.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.3" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.4" PrivateAssets="All" />
  </ItemGroup>

</Project>

And the errors:
image

I'm not able to reproduce this. Restore on these files works just fine for me. Can you run dotnet restore /bl from the command line and share the msbuild.binlog file?

By chance, do you have a Directory.Build.props or .targets file somewhere in the solution or a parent directory?

I've just made a new no auth project with the same issue, in a new directory, directly off my c:\ dir, and checked that there is no Directory.Build.props or .targets file in play. I ran restore with /bl (attached in a zip - so I can upload it here)
[msbuild.zip] https://github.com/aspnet/Templating/files/2426010/msbuild.zip
and got this output:

c:\isolated\WebApplication1>dotnet restore /bl
C:\Program Files\dotnet\sdk\2.2.100-preview1-009345\MSBuild.dll -nologo -maxcpucount -target:Restore -verbosity:m /bl .\WebApplication1.sln
  Restoring packages for c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj...
c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.Hosting from 2.1.2 to 2.1.1. Reference the package directly from the project to select a different version.  [c:\isolated\WebApplication1\WebApplication1.sln]
c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj : error NU1605:  WebApplication1 -> Microsoft.AspNetCore 2.1.3 -> Microsoft.AspNetCore.Server.Kestrel 2.1.3 -> Microsoft.AspNetCore.Hosting (>= 2.1.2)  [c:\isolated\WebApplication1\WebApplication1.sln]
c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj : error NU1605:  WebApplication1 -> Microsoft.AspNetCore 2.1.3 -> Microsoft.AspNetCore.Hosting (>= 2.1.1) [c:\isolated\WebApplication1\WebApplication1.sln]
c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Caching.Memory from 2.1.2 to 2.1.1. Reference the package directly from the project to select a different version.  [c:\isolated\WebApplication1\WebApplication1.sln]
c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj : error NU1605:  WebApplication1 -> Microsoft.AspNetCore.Mvc 2.1.2 -> Microsoft.AspNetCore.Mvc.TagHelpers 2.1.2 -> Microsoft.Extensions.Caching.Memory (>= 2.1.2)  [c:\isolated\WebApplication1\WebApplication1.sln]
c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj : error NU1605:  WebApplication1 -> Microsoft.AspNetCore.Mvc 2.1.2 -> Microsoft.Extensions.Caching.Memory (>= 2.1.1) [c:\isolated\WebApplication1\WebApplication1.sln]
  Generating MSBuild file c:\isolated\WebApplication1\WebApplication1\obj\WebApplication1.csproj.nuget.g.props.
  Restore failed in 548.12 ms for c:\isolated\WebApplication1\WebApplication1\WebApplication1.csproj.

I tried, still can't reproduce. No clue what's going on. It almost seems as if NuGet has a bug, but I don't think much would have changed between 2.2.100-preview1-009345 and 2.1. Also, our unit tests would have caught something as bad as this.

Can you try clearing your NuGet caches? Maybe there was some sort of corruption there.

Good call about clearing my nuget cache, that seems to have fixed it.

I think that's also the reason I had more errors in my first post. I had cleared my nuget cache between then and when I repro'd it with fewer errors.

Strange.

commented

Closing as there are no pending actions here.