Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Dnu wrapping a class library targeting an incompatible framework version gives unclear error #2329

Closed
@halter73

Description

@halter73

Trying to add a project reference to a classic 4.5.2 or 4.6 class library from a dnx451 project fails with an unclear error message.

Repro steps (All using VS 2015 RTM w/ WTE beta 6):

  1. Create a new ASP.NET 5 beta 6 application (I used the default web application template)

  2. Add a classic class library project to your solution (This defaults to framework 4.5.2)

  3. Add a reference to the class library using VS's "Add Reference..." dialog or dnu wrap .\ClassLibrary1\ClassLibrary1.csproj

    a. If using VS, the following will be added to your project.json automatically. If using dnu wrap you will have to add this yourself:

      "dnx451": {
        "dependencies": {
          "ClassLibrary1": "1.0.0-*"
        }
      },
  1. When you try to run the application from VS you will see the error: "The dependency ClassLibrary1 >= 1.0.0-* could not be resolved." There are no errors in the package manager output window.
  2. Here is some sample output from the console:
C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2 [master]> dnu wrap .\ClassLibrary1\ClassLibrary1.csproj
The servicing index file at: C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt does not exist or could not be opened.
Loaded module: dnx.clr.dll
Found export: CallApplicationMain
Information: [DomainManager] Using Desktop CLR v4.5.1
Information: [LoaderContainer]: Load name=Microsoft.Framework.PackageManager
Information: [PathBasedAssemblyLoader]: Loaded name=Microsoft.Framework.PackageManager in 12ms
Information: [Bootstrapper] Runtime Framework: DNX,Version=v4.5.1
Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256

Information: [LoaderContainer]: Load name=Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Information: [PathBasedAssemblyLoader]: Loaded name=Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed in 2ms
Wrapping project 'ClassLibrary1' for '.NETFramework,Version=v4.5.2'
  Source C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\ClassLibrary1\ClassLibrary1.csproj
  Target C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\wrap\ClassLibrary1\project.json
  Adding bin paths for '.NETFramework,Version=v4.5.2'
    Assembly: ../../ClassLibrary1/obj/{configuration}/ClassLibrary1.dll
    Pdb: ../../ClassLibrary1/obj/{configuration}/ClassLibrary1.pdb

C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2 [master +1 ~1 -0 !]> cd .\src\WebApplication2\
C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\src\WebApplication2 [master +1 ~2 -0 !]> dnu restore
The servicing index file at: C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt does not exist or could not be opened.
Loaded module: dnx.clr.dll
Found export: CallApplicationMain
Information: [DomainManager] Using Desktop CLR v4.5.1
Information: [LoaderContainer]: Load name=Microsoft.Framework.PackageManager
Information: [PathBasedAssemblyLoader]: Loaded name=Microsoft.Framework.PackageManager in 12ms
Information: [Bootstrapper] Runtime Framework: DNX,Version=v4.5.1
Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256

Restoring packages for C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\src\WebApplication2\project.json
Information: [LoaderContainer]: Load name=Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Information: [PathBasedAssemblyLoader]: Loaded name=Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed in 3ms
Writing lock file C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\src\WebApplication2\project.lock.json
Restore complete, 1654ms elapsed

NuGet Config files used:
    C:\Users\shalter\AppData\Roaming\NuGet\NuGet.Config
    C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\NuGet.Config
C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\src\WebApplication2 [master +1 ~2 -0 !]> dnx . web
The servicing index file at: C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt does not exist or could not be opened.
Loaded module: dnx.clr.dll
Found export: CallApplicationMain
Information: [DomainManager] Using Desktop CLR v4.5.1
Information: [Bootstrapper] Runtime Framework: DNX,Version=v4.5.1
Information: [DefaultHost]: Project path: C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\src\WebApplication2
Information: [DefaultHost]: Project root: C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2
Information: [DefaultHost]: Packages path: C:\Users\shalter\.dnx\packages
Information: [DependencyWalker]: Walking dependency graph for 'WebApplication2 DNX,Version=v4.5.1'.
Information: [WalkContext]: Graph walk stage 1 took in 71ms
Information: [DependencyWalker]: Graph walk took 74ms.
Information: [ServicingIndex]: Servicing index not found at C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt
Information: [WalkContext]: Populate took 28ms
Information: [DependencyWalker]: Resolved dependencies for WebApplication2 in 105ms
System.InvalidOperationException: Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1':
   ClassLibrary1 1.0.0

Searched Locations:
  C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\src\{name}\project.json
  C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\test\{name}\project.json
  C:\Users\shalter\Documents\Visual Studio 2015\Projects\WebApplication2\wrap\{name}\project.json
  C:\Users\shalter\.dnx\packages\{name}\{version}\{name}.nuspec
  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\{name}.dll
  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\{name}.dll
  C:\windows\Microsoft.NET\assembly\GAC_32\{name}\{version}\{name}.dll
  C:\windows\Microsoft.NET\assembly\GAC_64\{name}\{version}\{name}.dll
  C:\windows\Microsoft.NET\assembly\GAC_MSIL\{name}\{version}\{name}.dll

Try running 'dnu restore'.

   at Microsoft.Framework.Runtime.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
   at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
   at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)

This is all fixed by targeting the class library to 4.5.1, but I think the error could be clearer.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions