如何在ubuntu 16.04中从netcoreapp1.0迁移到netcoreapp1.1

时间:2017-07-12 23:18:39

标签: c# asp.net migration .net-core ubuntu-16.04

我刚从.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                                                                                                                               

我该怎么办?

1 个答案:

答案 0 :(得分:1)

是的,我已经解决了 运行后

days == 87.97

运行

else

哦,我差点忘了

编辑webprojectfile.csproj文件

而不是

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;文件

保留appsettings.json,因为它充当环境文件设置或PHP中的.env。 :)

同样在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

您的应用程序应该正常运行现在!希望。 :)