我安装了扩展程序并运行了命令from the link,这会产生以下错误:
dotnet :
At line:1 char:1
+ dotnet new -i "MadsKristensen.AspNetCore.Web.Templates::*"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
编辑:看起来错误可能是误报,我尝试按照说明创建静态网页。
但是在尝试编译时,我收到以下错误:
错误NU1605:检测到包降级:System.Diagnostics.Tools 从4.3.0到4.0.1。直接从项目中引用包 选择不同的版本。错误NU1605:HadakaAngular(> = 1.0.0) - > AspNetCore.StaticSiteHelper(> = 1.0.9) - > Microsoft.VisualStudio.Web.BrowserLink(> = 1.1.0) - > Microsoft.AspNetCore.Hosting.Abstractions(> = 1.1.0) - > NETStandard.Library(> = 1.6.1) - > System.Diagnostics.Tools(> = 4.3.0) 错误NU1605:HadakaAngular(> = 1.0.0) - > AspNetCore.StaticSiteHelper (> = 1.0.9) - > Microsoft.VisualStudio.Web.BrowserLink(> = 1.1.0) - > System.Diagnostics.Tools(> = 4.0.1)错误NU1605:检测到的包 降级:System.Net.Primitives从4.3.0升级到4.0.11。参考 直接从项目包中选择一个不同的版本。 错误NU1605:HadakaAngular(> = 1.0.0) - > AspNetCore.StaticSiteHelper (> = 1.0.9) - > Microsoft.VisualStudio.Web.BrowserLink(> = 1.1.0) - > Microsoft.AspNetCore.Hosting.Abstractions(> = 1.1.0) - > NETStandard.Library(> = 1.6.1) - > System.Net.Primitives(> = 4.3.0) 错误NU1605:HadakaAngular(> = 1.0.0) - > AspNetCore.StaticSiteHelper (> = 1.0.9) - > Microsoft.VisualStudio.Web.BrowserLink(> = 1.1.0) - > System.Net.Primitives(> = 4.0.11)
答案 0 :(得分:1)
Eellor的答案有效,但是如果您想使用.NET Core 2.0,则需要更改某些程序包引用的版本。然后编辑.csproj文件,以便ItemGroup如下所示:
<ItemGroup>
<PackageReference Include="AspNetCore.StaticSiteHelper" Version="1.0.9" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
</ItemGroup>
重建/重新编译,您的项目应下载正确版本的软件包。
答案 1 :(得分:0)
这是因为VS 2017的最新更新创建了目标框架为.NET Core 2.0的Web应用程序,而Kristensen的ASP.NET核心模板包2017.3(最新版本目前为1.0.9)仍然存在。 NET Core 1.1。
最简单的解决方案是将项目的目标框架更改为.NET Core 1.1,以与模板包的版本保持一致。转到项目属性&gt;申请&gt;目标框架。将其更改为.NET Core 1.1。
从长远来看,我们需要更新模板包,或者如果我们仍然想要坚持使用.NET Core 2.0,我们需要删除它。