Running MVC 6 ASP.NET 5 localization example for dnx rc2

I am trying to start an AspNet5Localization example project here https://github.com/damienbod/AspNet5Localization/tree/rc2

However, when I open the solution, a warning window appears:

DNX SDC version dnx-clr-win-x86.1.0.0-rc2-16444 is required by your solution, but not installed on this computer. 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 DNX SDK version for this session.

I choose Yes.

Then the following information window will appear:

The DNX SDK version dnx-clr-win-x86.1.0.0-rc2-16444 could not be installed. The solution will use the DNX SDK version dnx-clr-win-x86.1.0.0-rc1-update1 for this session.

Since I installed dnx-clr-win-x86.1.0.0-rc2-16357, I am changing the version of the Soltion DNX SDK to 1.0.0-rc2-16357 from the 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 of this change, it cannot restore packets.

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 sample project?

+5
source share
1 answer

How can I compile and run this sample project?

One Run the following three commands from the command line. This updates our dnvm and adds the latest development releases. Be sure to disable the antivirus; my antivirus has 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. He does this by providing the runtime information necessary to resolve the target implementations of the .NETCore platform, platform, and runtime.

  "Microsoft.NETCore.Platforms": "1.0.1-*" 

Three . Open AspNet5Localization/NuGet.config . Make sure the asp.nuget.org and nuget.org feeds are NOT commented out. These channels provide us with Newtonsoft.Json, Remotion.Linq, Ix-Async, and some Microsoft.CodeAnalysis packages. When you are done, NuGet.config will look 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, but dnu build will not.

Four . Open AspNet5Localization/src/AspNet5Localization/Controllers/BoxesController.cs . Responses to recent renaming by searching 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 .

 $ cd src\AspNet5Localization $ dnu restore $ dnu build $ dnx web 

You will see the following result.

enter image description here

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 create, you will get two warnings that Microsoft.Extensions.CodeGeneration and Microsoft.Extensions.CodeGenerators.Mvc do not support dnx451. To get rid of these errors, open project.json. Remove these two dependencies or remove the dnx451 structure.

+4
source

Source: https://habr.com/ru/post/1243518/


All Articles