MVC运行ASP.NET 6本土化5示例DNX RC2 [英] Running MVC 6 ASP.NET 5 localization example for dnx rc2
问题描述
我想从这里 https://github.com/damienbod运行AspNet5Localization示例项目/ AspNet5Localization /树/ RC2
然而,当我打开解决方案出现一个警告框:
是由您的解决方案所需的DNX SDC版本DNX-CLR-双赢x86.1.0.0-rc2-16444但并不在本机上安装。你现在要安装吗?如果选择否,'DNX-CLR-双赢x86.1.0.0-RC1-UPDATE1'将被用作解决DNX SDK版本本次会议。
块引用>我选择是。
然后出现另一个信息框:
DNX SDK版本DNX-CLR-双赢x86.1.0.0-rc2-16444安装失败。该解决方案将使用DNX SDK版本DNX-CLR-双赢x86.1.0.0-RC1-UPDATE1本次会议。
块引用>由于我已经安装了DNX-CLR-双赢x86.1.0.0-rc2-16357我改变Soltion DNX SDK版本1.0.0-rc2-16357从项目属性。
活动版本运行架构OperatingSystem的别名
------ ------- ------- ------------ --------------- --- -
1.0.0-RC1-UPDATE1 CLR 64胜
1.0.0-RC1-UPDATE1 CLR 86胜默认
1.0.0-RC1-UPDATE1 coreclr 64胜
1.0.0-RC1-UPDATE1 coreclr 86胜
1.0.0-rc2-16357 CLR 86胜然而,不管这种变化,它无法恢复的包。
我看到了以下错误:
System.ArgumentException:多个runtime.json文件宣称进口的win7-86'
参数名:runtimeName
在Microsoft.Dnx.Tooling.RestoreCommand.FindRuntimeDependencies(字符串runtimeName,List`1 runtimeFiles,Dictionary`2 effectiveRuntimeSpecs,HashSet`1 allRuntimeNames,Func`2 circularImport)
在Microsoft.Dnx.Tooling.RestoreCommand.FindRuntimeDependencies(字符串runtimeName,List`1 runtimeFiles,Dictionary`2 effectiveRuntimeSpecs,HashSet`1 allRuntimeNames)
在Microsoft.Dnx.Tooling.RestoreCommand< RestoreForProject> d__69.MoveNext()
---从previous位置堆栈跟踪,其中引发异常的结尾---
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)
在Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass68_0.<<Execute>b__2>d.MoveNext()
---从previous位置堆栈跟踪,其中引发异常的结尾---
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)
在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)
在Microsoft.Dnx.Tooling.RestoreCommand&LT;执行&GT; d__68.MoveNext()
----------
恢复失败
多个runtime.json文件已申报的win7-86进口我
如何才能编译并运行这个例子项目?
解决方案
我如何才能编译并运行这个例子项目?
块引用>一。运行命令行下面的三个命令。此升级我们的
dnvm
,并增加了最新开发版本。确保关闭防病毒;我的抗病毒阻断几个.NET文件。设置DNX_UNSTABLE_FEED = HTTPS://www.myget.org/F/aspnetcidev/api/v2
dnvm升级-unstable
dnvm安装1.0.0-rc2-16549 -runtime coreclr -unstable两个即可。打开
AspNet5Localization / src目录/ AspNet5Localization / project.json
。添加下面的依赖。此修复runtime.json错误。它是通过提供解决目标框架,平台和.NETCore包运行特定的实现需要运行时信息。Microsoft.NETCore.Platforms:1.0.1- *
三。打开
AspNet5Localization / NuGet.config
。确保asp.nuget.org和nuget.org饲料没有被注释掉。这些提要提供给我们Newtonsoft.Json,Remotion.Linq,IX-异步和一些微软。codeAnalysis包。当你完成后,NuGet.config看起来是这样的:&LT;?XML版本=1.0编码=UTF-8&GT?;
&LT;结构&gt;
&LT; packageSources&GT;
&LT;! - 继承全局的NuGet包源
删除的&lt;清/&GT;下面行 - &GT;
&LT;清/&GT;
&LT;添加键=MyGet aspnetcidev
值=https://www.myget.org/F/aspnetcidev/api/v3/index.json/&GT;
&LT;添加键=api.nuget.org
值=https://api.nuget.org/v3/index.json/&GT;
&LT;添加键=nuget.org
值=https://www.nuget.org/api/v2//&GT;
&LT; / packageSources&GT;
&LT; /结构&gt;在这一点上,<code> DNU恢复将现在的工作,但
DNU建立
不会的。四。打开
AspNet5Localization / src目录/ AspNet5Localization /控制器/ BoxesController.cs
。 通过查找和替换以下回应近期更名。HttpNotFound - &GT;未找到
HttpBadRequest - &GT;错误的请求五恢复和建设
AspNet5Localization / src目录/ Localization.SqlLocalizer
项目。$ CD的src \\ Localization.SqlLocalizer
$ DNU恢复
$ DNU构建六恢复和建设
AspNet5Localization / src目录/ AspNet5Localization
项目。$ CD的src \\ AspNet5Localization
$ DNU恢复
$ DNU构建
$ DNX网您会看到下面的结果。
注意01 。这是
dnvm列表
看起来像我的机器上:活动版本运行架构OperatingSystem的别名
------ ------- ------- ------------ --------------- --- -
1.0.0-RC1-UPDATE1 coreclr 64胜
1.0.0-rc2-16549 CLR 86胜默认
* 1.0.0-rc2-16549 coreclr 64胜注意02 。当你建立,你会得到两个警告Microsoft.Extensions。codeGeneration和Microsoft.Extensions。codeGenerators.Mvc不支持dnx451。为了摆脱这些错误,开放project.json的。要么删除这两个依赖关系或删除dnx451框架。
I am trying to run the AspNet5Localization example project from here https://github.com/damienbod/AspNet5Localization/tree/rc2
However, when I open the solution a warning box appears:
DNX SDC version dnx-clr-win-x86.1.0.0-rc2-16444 is required by your solution but is not installed on this machine. Do you want to install it now? If you select No, 'dnx-clr-win-x86.1.0.0-rc1-update1' will be used as the solution DNX SDK version for this session.
I choose Yes.
Then another info box appears:
DNX SDK version dnx-clr-win-x86.1.0.0-rc2-16444 failed to install. The solution will use DNX SDK version dnx-clr-win-x86.1.0.0-rc1-update1 for this session.
Because I have installed dnx-clr-win-x86.1.0.0-rc2-16357 I change the "Soltion DNX SDK version" to 1.0.0-rc2-16357 from project properties.
Active Version Runtime Architecture OperatingSystem Alias ------ ------- ------- ------------ --------------- ----- 1.0.0-rc1-update1 clr x64 win 1.0.0-rc1-update1 clr x86 win default 1.0.0-rc1-update1 coreclr x64 win 1.0.0-rc1-update1 coreclr x86 win 1.0.0-rc2-16357 clr x86 win
However, regardless this change, it fails to restore the packages.
I see the following error:
System.ArgumentException: More than one runtime.json file has declared imports for 'win7-x86' Parameter name: runtimeName at Microsoft.Dnx.Tooling.RestoreCommand.FindRuntimeDependencies(String runtimeName, List`1 runtimeFiles, Dictionary`2 effectiveRuntimeSpecs, HashSet`1 allRuntimeNames, Func`2 circularImport) at Microsoft.Dnx.Tooling.RestoreCommand.FindRuntimeDependencies(String runtimeName, List`1 runtimeFiles, Dictionary`2 effectiveRuntimeSpecs, HashSet`1 allRuntimeNames) at Microsoft.Dnx.Tooling.RestoreCommand.<RestoreForProject>d__69.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass68_0.<<Execute>b__2>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Dnx.Tooling.RestoreCommand.<Execute>d__68.MoveNext() ---------- Restore failed More than one runtime.json file has declared imports for 'win7-x86'
How can I compile and run this example project?
解决方案How can I compile and run this example project?
One. Run the following three commands from the command line. This upgrades our
dnvm
and adds the recent development releases. Make sure to turn off anti-virus; my anti-virus blocked several .NET files.set DNX_UNSTABLE_FEED=https://www.myget.org/F/aspnetcidev/api/v2 dnvm upgrade -unstable dnvm install 1.0.0-rc2-16549 -runtime coreclr -unstable
Two. Open
AspNet5Localization/src/AspNet5Localization/project.json
. Add the following dependency. This fixes the runtime.json error. It does that by providing runtime information required to resolve target framework, platform, and runtime specific implementations of .NETCore packages."Microsoft.NETCore.Platforms": "1.0.1-*"
Three. Open
AspNet5Localization/NuGet.config
. Make sure that the asp.nuget.org and nuget.org feeds are NOT commented out. Those feeds provide us with Newtonsoft.Json, Remotion.Linq, Ix-Async, and some Microsoft.CodeAnalysis packages. When you are done, the NuGet.config looks like this:<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <!--To inherit the global NuGet package sources remove the <clear/> line below --> <clear /> <add key="MyGet aspnetcidev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" /> <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> </packageSources> </configuration>
At this point,
dnu restore
will now work butdnu build
will not.Four. Open
AspNet5Localization/src/AspNet5Localization/Controllers/BoxesController.cs
. Responds to recent renaming by finding and replacing the following.HttpNotFound --> NotFound HttpBadRequest --> BadRequest
Five Restore and build the
AspNet5Localization/src/Localization.SqlLocalizer
project.$ cd src\Localization.SqlLocalizer $ dnu restore $ dnu build
Six Restore and build the
AspNet5Localization/src/AspNet5Localization
project.$ cd src\AspNet5Localization $ dnu restore $ dnu build $ dnx web
You will see the following result.
Note 01. This is what
dnvm list
looks like on my machine:Active Version Runtime Architecture OperatingSystem Alias ------ ------- ------- ------------ --------------- ----- 1.0.0-rc1-update1 coreclr x64 win 1.0.0-rc2-16549 clr x86 win default * 1.0.0-rc2-16549 coreclr x64 win
Note 02. When you build, you will get two warnings that Microsoft.Extensions.CodeGeneration and Microsoft.Extensions.CodeGenerators.Mvc do not support dnx451. To get rid of those errors, open project.json. Either delete those two dependencies or delete the dnx451 framework.
这篇关于MVC运行ASP.NET 6本土化5示例DNX RC2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!