我刚从.Net Core 1.0升级到.NET Core 1.1 我已经有了使用.Net Core 1.0的项目 我如何成功迁移。 因为我尝试过使用
dotnet migrate
迁移它是成功的,但是当我尝试运行时
dotnet restore
我显示了很长的错误,如下所示
1.0.0/microsoft.visualstudio.web.codegenerators.mvc.1.0.0.nupkg'. [1320/1825]
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.relational/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.hosting/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.viewfeatures/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Failed to download package 'Microsoft.AspNetCore.Mvc.ApiExplorer.1.0.3' from 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.apiexplorer/1.0.3/microsoft.as
pnetcore.mvc.apiexplorer.1.0.3.nupkg'.
An error occurred while sending the request.
Couldn't resolve host name
Failed to download package 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.1.0.2' from 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.identity.entityframew
orkcore/1.0.2/microsoft.aspnetcore.identity.entityframeworkcore.1.0.2.nupkg'.
An error occurred while sending the request.
Couldn't resolve host name
Failed to download package 'Microsoft.AspNetCore.Hosting.Abstractions.1.0.2' from 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.hosting.abstractions/1.0.2/mi
crosoft.aspnetcore.hosting.abstractions.1.0.2.nupkg'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.formatters.json/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.localization/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Failed to download package 'Microsoft.VisualStudio.Web.CodeGeneration.Tools.1.0.0' from 'https://api.nuget.org/v3-flatcontainer/microsoft.visualstudio.web.codegeneration.to
ols/1.0.0/microsoft.visualstudio.web.codegeneration.tools.1.0.0.nupkg'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.taghelpers/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.design/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.http.extensions/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.httpoverrides/index.json'.
An error occurred while sending the request.
Couldn't resolve host name
[0] 0:[tmux]*Z
我该怎么办?
答案 0 :(得分:1)
days == 87.97
运行
else
哦,我差点忘了
而不是
dotnet migrate
更新文件以反映netcore最新版本 如下图所示
dotnet restore
这是改变这一行
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>webproj</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>webproj</PackageId>
<UserSecretsId>aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a</UserSecretsId>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<None Update="wwwroot\**\*;Views\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
到
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>webproj</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>webproj</PackageId>
<UserSecretsId>aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a</UserSecretsId>
<RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<None Update="wwwroot\**\*;Views\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
和
<TargetFramework>netcoreapp1.0</TargetFramework>
到
<TargetFramework>netcoreapp1.1</TargetFramework>
&#34; appsettings.json&#34;文件
同样在Startup.cs文件中
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
然后你现在可以重新运行以下
<RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
然后
if (env.IsDevelopment())
{
// comment this line
// builder.AddUserSecrets();
// Use this instead
builder.AddUserSecrets("myusersecretAddUserSecrets"); // where myusersecretAddUserSecrets is your secret key or ID
}
然后
dotnet restore
您的应用程序应该正常运行现在!希望。 :)