ASP.NET 5(vNext)Web项目:库冲突从beta4升级到beta6

我用dnvm upgrade -Unstable 。 运行dnvm list显示它处于活动状态:1.0.0-beta6-12120。

我使用ASP.NET 5预览模板为网站创建了一个新项目,并validation了它将构建。

我将project.json更改为引用beta6:

 "dependencies": { "EntityFramework.SqlServer": "7.0.0-beta6", "EntityFramework.Commands": "7.0.0-beta6", "Microsoft.AspNet.Mvc": "6.0.0-beta6", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta6", "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta6", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta6", "Microsoft.AspNet.Authentication.Google": "1.0.0-beta6", "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta6", "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta6", "Microsoft.AspNet.Diagnostics": "1.0.0-beta6", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta6", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta6", "Microsoft.AspNet.Server.IIS": "1.0.0-beta6", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6", "Microsoft.AspNet.StaticFiles": "1.0.0-beta6", "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta6", "Microsoft.Framework.Configuration.Json": "1.0.0-beta6", "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta6", "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta6", "Microsoft.Framework.Logging": "1.0.0-beta6", "Microsoft.Framework.Logging.Console": "1.0.0-beta6" } 

但是构建因运行时库冲突而失败:

1>MSBUILD : DNX 4.5.1 error CS0433: The type 'AssemblyFileVersionAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 1>MSBUILD : DNX 4.5.1 error CS0433: The type 'AssemblyVersionAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 1>MSBUILD : DNX 4.5.1 error CS0433: The type 'AssemblyInformationalVersionAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 1>MSBUILD : DNX 4.5.1 error CS0518: Predefined type 'System.String' is not defined or imported 1>MSBUILD : DNX 4.5.1 error CS0518: Predefined type 'System.String' is not defined or imported 1>MSBUILD : DNX 4.5.1 error CS0518: Predefined type 'System.String' is not defined or imported 1>MSBUILD : DNX 4.5.1 error CS0518: Predefined type 'System.Void' is not defined or imported 1>MSBUILD : DNX 4.5.1 error CS0518: Predefined type 'System.Void' is not defined or imported 1>MSBUILD : DNX 4.5.1 error CS0518: Predefined type 'System.Boolean' is not defined or imported

怎么解决这个问题?

beta6- *

在你的project.json文件中,尝试使用beta6-*而不仅仅是beta6-* 。 这意味着它将引用它的最新版本。

〜.dnx \运行时间

检查C:\Users\MyUser\.dnx\runtimes 。 我的包括以下内容:

 dnx-clr-win-x86.1.0.0-beta6 <-- I made this one via a rename. dnx-clr-win-x86.1.0.0-beta6-12085 dnx-clr-win-x86.1.0.0-beta6-12120 

在我的global.json文件中,它与*.sln位于同一目录中,我确保引用其中一个运行时,如下所示:

 { "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-beta6-12120" } } 

如果从命令行构建:

从命令行执行dnu restore 。 这将强制更新依赖项解析。 几乎任何时候你改变运行时升级到新的运行时或切换活动运行时我都会进行恢复。

如果从visual studio构建:

Visual Studio使用sdk属性来确定构建和还原时要使用的运行时。 这可能与dnvm激活的运行时设置不同。 在dnvm中设置活动运行时不会更改IDE使用的运行时。 在VS中设置目标不会更改命令行上的活动运行时。

要更改Visual Studio使用的运行时:

设置整个解决方案的最小dnx版本。

手动编辑global.json(解决方案级别文件)。 将“sdk”的值设置或更改为所需的运行时版本。 这将设置所有项目的默认值,并且可以在下面的项目级别覆盖它。

要么

为项目设置所需的运行时

右键单击项目>属性>应用程序

选中Use specific DNX version 。 设置为所需的版本,平台和体系结构