Reputation: 381
I am trying to resolve nugget packages with dotnet restore
, but am getting the following error:
Unable to resolve 'Microsoft.NETCore.App (>= 2.1.0)' for '.NETCoreApp,Version=v2.1'
Here's my .csproj
file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.5.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Autofac.Extras.Moq" Version="4.2.0" />
<PackageReference Include="BCrypt.Net-Core" Version="1.4.0" />
<PackageReference Include="Easy.MessageHub" Version="3.2.1" />
<PackageReference Include="hangfire" Version="1.6.17" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.5.2" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0-rc1-final" />
<PackageReference Include="MongoDB.Driver" Version="2.4.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
</ItemGroup>
<Target Name="ApplyXdtConfigTransform" BeforeTargets="_TransformWebConfig">
<PropertyGroup>
<_SourceWebConfig>$(MSBuildThisFileDirectory)Web.config</_SourceWebConfig>
<_XdtTransform>$(MSBuildThisFileDirectory)Web.$(Configuration).config</_XdtTransform>
<_TargetWebConfig>$(PublishDir)Web.config</_TargetWebConfig>
</PropertyGroup>
<Exec Command="dotnet transform-xdt --xml "$(_SourceWebConfig)" --transform "$(_XdtTransform)" --output "$(_TargetWebConfig)"" Condition="Exists('$(_XdtTransform)')" />
</Target>
</Project>
I have installed dotnet-sdk-2.1.300-rc1-008673-win-x64 and I am using Visual Studio 2017 v15.2
Upvotes: 5
Views: 13650
Reputation: 99
I had same issue with my project in .net core 3.1.0 Following are the steps
dotnet nuget locals all --clear dotnet restore --force
Upvotes: 0
Reputation: 30287
You can add the v3 nuget source via the dotnet cli:
dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json
If that doesn't work, try running clearing out the local cache:
dotnet nuget locals all --clear
dotnet restore --force
Upvotes: 5
Reputation: 4275
Update your nuget.config
file located in:
C:\Users\{username}\AppData\Roaming\NuGet\nuget.config
You need to add the v3
endpoint like this:
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
Upvotes: 8
Reputation: 381
Problem was Visual Studio version.
Solution was to create MSBuildSdksPath environment variable that is pointing to dotnet\sdk{{version}}\Sdks, like on the following link https://github.com/aspnet/Announcements/issues/231
Upvotes: 1