I'm setting up a new development machine with no internet access.
I've installed Visual Studio 2017 (15.8.9) with the ASP.NET and .NET Core workloads - including .NET Core 2.1 development tools and .NET Framework 4.6.1 development tools.
I've created a new "API" project with File > New Project > New ASP.NET Core Web Application and selected the "API" template with the full .NET Framework and ASP.NET Core 2.1.
This gives me a project file that looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.6" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
</ItemGroup>
</Project>
This seems fine. However, I get the following errors when trying to restore nuget packages:
NU1101: Unable to find package Microsoft.AspNetCore.
NU1102: Unable to find package Microsoft.AspNetCore.Mvc with version (>=2.1.3)
I didn't have this problem on my old machine with a slightly older versions of VS 2017 and .NET Core 2.1. The project was able to restore the ASP.NET core packages from a local cache of packages installed with the .NET Core SDK (I assume). Also, I don't have this problem on a similar machine that has internet access, presumably because it can download the packages it needs from nuget.org.
How should I go about troubleshooting and/or fixing this problem?
I ended up asking this question on the ASP.NET Core github project/repository. It turns out that "restoring packages in .NET Framework projects is not currently one of the scenarios supported by the offline cache." The solution is to make sure you have the correct versions of all the Microsoft.AspNetCore packages are available in a local nuget package source.