6

I upgraded DNVM with dnvm upgrade -Unstable. Running dnvm list shows this to be active: 1.0.0-beta6-12120.

I created a new project using the ASP.NET 5 Preview Template for Web Site and verified that it would build.

I changed the project.json to reference 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"
}

But the build fails with runtime library conflicts:

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

How can this be resolved?

jltrem
  • 12,124
  • 4
  • 40
  • 50

2 Answers2

3

beta6-*

In your project.json file(s), try using beta6-* instead of just beta6. That means it will reference the most recent build of it.

~.dnx\runtimes

Check what runtime directories are in C:\Users\MyUser\.dnx\runtimes. Mine include the following:

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

In my global.json file, which is in the same directory as the *.sln, I make sure to reference one of the runtimes like this:

{
    "projects": [ "src", "test" ],
    "sdk": {
        "version": "1.0.0-beta6-12120"
    }
}
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • 1
    One thing I would add is that the BCL is no longer unified in versioning so packages can have different versions. Also many packages which previously would be considered part of the BCL are now technically not in the BCL (i.e. microsoft.asp.net.*). For some of the packages in the question even beta6-* is invalid as the latest version is beta5-something. – Gerald Davis Jun 27 '15 at 18:16
  • 1
    by just using `beta6` rather than `beta6-*` the package restore brought down the oldest version in beta6. Changing to `beta6-*` brought down the newest version and the library conflict disappeared. – jltrem Jun 29 '15 at 13:29
  • 1
    It's better to remove the sdk version if you want to float – davidfowl Jul 04 '15 at 10:04
  • @davidfowl Do you mean that `global.json` should contain `{ "projects": [ "src", "test" ] }` without listing a specific `sdk`? – Shaun Luttin Jul 04 '15 at 15:10
  • Correct, that means it'll use the default alias. The other way to float is to be explicit about the alias in the sdk.version field. We don't support floating versions in global.json. – davidfowl Jul 04 '15 at 17:15
  • @davidfowl What do you mean by "be explicit about the alias in the sdk.version field?" What would that look like? E.g. `{ "projects": [ "src", "test" ], "sdk": { "version": "myCustomAlias" } }`. I'm not sure how that would be a version float, because `myCustomAlias`, I assume, would refer to a specific version. – Shaun Luttin Jul 04 '15 at 19:07
  • 1
    Yes that example is correct. If you dnvm upgrade foo, it will set an alias foo to the upgraded version. If you set an alias, that you always update then you never have to touch global.json – davidfowl Jul 04 '15 at 19:17
2

If building from the command line:

From the command line do a dnu restore. This will force an update of dependency resolution. Pretty much anytime you change the runtime either upgrading to a new one or switching the active runtime I would do a restore.

If building from visual studio:

Visual studio uses the sdk property to determine which runtime to use when building and restoring. This can be different than the runtime set active by dnvm. Setting the active runtime in dnvm does not change the runtime used by the IDE. Setting the target in VS does not change the active runtime on the command line.

To change the runtime used by Visual Studio either:

Set the minimum dnx version for the entire solution.

Edit the global.json (solution level file) manually. Set or change the value for "sdk" to the desired version of the runtime. This sets the defaults for all projects and it can be overridden at the project level below.

OR

Set the desired runtime for the project

Right click on a project > Properties > Application

Check Use specific DNX version. Set to desired version, platform, and architecture

Community
  • 1
  • 1
Gerald Davis
  • 4,541
  • 2
  • 31
  • 47
  • just now ran that at the cmdln. It seems this is the same thing as 'Restore Packages' on the project's context menu. All the the references appear happy. It just fails when building. – jltrem Jun 26 '15 at 20:24
  • It also fails when building on the command line (dnu build)? I updated answer to indicate how visual studio uses does not set the target the same way as dnvm. – Gerald Davis Jun 26 '15 at 20:34
  • yes, it fails using `dnu build` at the command line too. cmdln and VS are both using sdk 1.0.0-beta6-12120. – jltrem Jun 26 '15 at 20:40
  • 1
    Taking a closer look at your code I am unsure how a restore works from either the command line or IDE. I don't believe beta6 (w/o build number) is a valid version for those packages. I tried to replicate the issue but I got unable to locate package errors so I am surprised you are able to do a restore. For example there is a beta6-10361 of "Microsoft.AspNet.Server.WebListener" but not beta6. – Gerald Davis Jun 27 '15 at 00:10
  • "I got unable to locate package errors" ... would have been wonderful if I had gotten those errors. But instead it pulled the oldest version of beta6 instead of the newest. But thanks for your answer. It provides good info on using these tools at a time where there isn't enough info available! – jltrem Jun 29 '15 at 13:38