[英]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.