[英]Upgrading to ASP.Net Core 2.0
从ASP.Net Core 1.X升级到2.0( https://docs.microsoft.com/zh-cn/aspnet/core/migration/1x-to-2x/ )
我遇到以下疑问/问题:
第一:metapackage
现在用
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
我们获得了项目中所需的所有参考。 但是我不知道是否应该排除Microsoft.VisualStudio.Web
的程序包
我对这些参考资料有疑问 :
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGenerators.Mvc" Version="2.0.0" />
我看到该元软件包已包括以下内容: Microsoft.VisualStudio.Web.BrowserLink" Version
我是否应该仅排除其中一个而将其他两个( CodeGeneration.Design
和Microsoft.VisualStudio.Web.CodeGenerators.Mvc
保留在那里?
第二:错误
我gettint各种错误
首先有人说与metapackage一起安装的软件包与aspnetcore2.0不兼容。有人经历过吗? 有关如何处理此问题的任何建议?
第二个给出此错误消息:
“ EntityFrameworkCore”命名空间的类型或名称在“ Microsoft”命名空间中不存在(是否缺少任何程序集引用?)
提前致谢!
最后
这就是我的csproj看起来像atm的样子:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\lib\kendo-ui-core\**" />
<Content Remove="wwwroot\lib\kendo-ui-core\**" />
<EmbeddedResource Remove="wwwroot\lib\kendo-ui-core\**" />
<None Remove="wwwroot\lib\kendo-ui-core\**" />
</ItemGroup>
<ItemGroup>
<Content Include="wwwroot\css\bootstrap-lumen.css" />
<Content Include="wwwroot\css\bootstrap-sand.css" />
<Content Include="wwwroot\css\bootstrap-sand.min.css" />
<Content Include="wwwroot\js\application-role-index.js" />
<Content Include="wwwroot\js\family-index.js" />
<Content Include="wwwroot\js\jquery-3.2.1.min.js" />
<Content Include="wwwroot\js\modal-action-store.js" />
<Content Include="wwwroot\js\populate-district.js" />
<Content Include="wwwroot\js\store-index.js" />
<Content Include="wwwroot\js\type-index.js" />
<Content Include="wwwroot\js\user-index.js" />
<Content Include="wwwroot\js\jquery.filtertable.min.js" />
<Content Include="wwwroot\js\machine-index.js" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Bootstrap.v3.Datetimepicker" Version="4.17.45" />
<PackageReference Include="Bootstrap.v3.Datetimepicker.CSS" Version="4.17.45" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGenerators.Mvc" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="NuGet.CommandLine" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>
如果使用的是.NET Core,请尝试安装NuGet软件包:
Microsoft.AspNetCore.All
如果使用的是.NET Framework,则过程不同 。
对于.NET Framework,我建议使用常规的Visual Studio 2017模板创建一个新的ASP.NET Core项目。 这使您可以选择使用.NET Framework创建ASP.NET Core 2.0项目,并且可以选择目标版本。 然后,您将需要将内容迁移到项目中。 这是手动过程,因为项目文件格式是如此不同。 一旦完成,您将遇到一些编译错误,因为类已经转移到新的名称空间中,依此类推。 但是,使其工作并不是很难。 此方法确保您也不会随身携带任何垃圾的NuGet包。 您将一尘不染。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.