Wil*_*sch 1 dotnet-cli angular
我一直在玩通过创建的项目
dotnet new Angular.
Run Code Online (Sandbox Code Playgroud)
我喜欢它!
但我需要从我的项目中引用一个.net 4.6.1项目.我的第一个想法是将Angular项目改为.net 4.6.1项目,因为一个461项目显然可以引用另一个项目.所以我尝试更改.csproj文件,替换
<TargetFramework>netcoreapp2.0</TargetFramework>
Run Code Online (Sandbox Code Playgroud)
同
<TargetFramework>net461</TargetFramework>.
Run Code Online (Sandbox Code Playgroud)
但后来我得到了一堆构建错误,从以下开始:
Package Microsoft.AspNetCore.All 2.0.0 is not compatible with net461 (.NETFramework,Version=v4.6.1) / win7-x86. Package Microsoft.AspNetCore.All 2.0.0 supports: netcoreapp2.0 (.NETCoreApp,Version=v2.0) Angular C:\Code\Learning\angular\foo\AngularTest\Angular\Angular.csproj 1
Run Code Online (Sandbox Code Playgroud)
如果我删除对Microsoft.AspNetCore.All的引用,我从代码中得到错误,说明缺少Microsoft.AspNetCore.All.
我没有问题之前使用过Angular和.net 4.6.1.所以应该有办法做到这一点.但它是什么?
您可以net461在Angular模板中进行定位,但必须在.csproj文件中单独列出引用的程序集,而不是使用Microsoft.AspNetCore.All.
它会在文件顶部看起来像这样.
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.NodeServices" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
我自己做了这个开关,但它确实有效.
| 归档时间: |
|
| 查看次数: |
476 次 |
| 最近记录: |