aspnet / MusicStore

[Archived] MusicStore test application that uses ASP.NET/EF Core. Project moved to https://github.com/aspnet/AspNetCore
1.3k stars 878 forks source link

How to install System.Reflection.Metadata ? #558

Closed mauricioralcala closed 8 years ago

mauricioralcala commented 8 years ago

I cloned the repository and opened it in Visual Studio 2015. I tried to run it and got this:

System.InvalidOperationException
Could not find a part of the path 'C:\Users\Mauricio\.dnx\packages\System.Reflection.Metadata\1.1.0-alpha-00014\lib\dotnet\System.Reflection.Metadata.dll'.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
at Microsoft.Dnx.Compilation.DesignTime.DesignTimeHostCompiler.<Compile>d__7.MoveNext()
System.AggregateException
One or more errors occurred.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 
at System.Threading.Tasks.Task<TResult>.GetResultCore(Boolean waitCompletionNotification) 
at System.Threading.Tasks.Task<TResult>.get_Result() 
at Microsoft.Dnx.Compilation.DesignTime.DesignTimeHostProjectCompiler.CompileProject(CompilationProjectContext projectContext, Func<LibraryExport> referenceResolver, Func<IList<ResourceDescriptor>> resourcesResolver)
at Microsoft.Dnx.Compilation.LibraryExporter.<>c__DisplayClass17_0.<ExportProject>b__0(CacheContext ctx) 
at Microsoft.Dnx.Compilation.Caching.CacheExtensions.<>c__DisplayClass0_0<T>.<Get>b__0(CacheContext ctx) 
at Microsoft.Dnx.Compilation.Caching.Cache.CreateEntry(Object k, Func<CacheContext, Object> acquire) 
at Microsoft.Dnx.Compilation.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0() 
at System.Lazy<T>.CreateValue() 
at System.Lazy<T>.LazyInitValue() 
at System.Lazy<T>.get_Value() 
at Microsoft.Dnx.Compilation.Caching.Cache.Get(Object key, Func<CacheContext, Object> factory) 
at Microsoft.Dnx.Compilation.Caching.CacheExtensions.Get<T>(ICache cache, Object key, Func<CacheContext, T> factory) 
at Microsoft.Dnx.Compilation.LibraryExporter.ExportProject(ProjectDescription project, String aspect) 
at Microsoft.Dnx.Compilation.LibraryExporter.GetExport(LibraryDescription library, String aspect) 
at Microsoft.Dnx.Compilation.LibraryExporter.GetExport(String name, String aspect) 
at Microsoft.Dnx.Compilation.CompilationEngine.LoadProject(Project project, FrameworkName targetFramework, String aspect, IAssemblyLoadContext loadContext, AssemblyName assemblyName)
at Microsoft.Dnx.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext) 
at Microsoft.Dnx.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName) 
at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName) 
at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName) 
at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func<AssemblyName, Assembly> factory) 
at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName) 
at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args) 
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
System.IO.FileLoadException
Could not load file or assembly 'MusicStore' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef) 
at Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String startupAssemblyName, IList<String> diagnosticMessages) 
at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup() 
at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices() 
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()

I installed System.Reflection.Metadata through NuGet and still got this. Apologies if this is trivial. This is my first time trying VS or ASP.NET.

Eilon commented 8 years ago

@mrag89 can you try this again after clearing your NuGet caches? There was a problem with that package missing some of its target frameworks and I just uploaded what I believe is the correct version.

You can run dnu clear-http-cache to clear out the cache, and you'll also want to run git clean -xdf to make sure there aren't stale packages in the cloned repo.

mauricioralcala commented 8 years ago

@Eilon That didn't work but I figured it out. NuGet was installing the latest stable release of the package (1.1.0). The project required (1.1.0-alpha-00014). I had to allow NuGet to get prerelease packages and specify this version and now it works. I'm guessing NuGet wasn't smart enough to get the correct package because the version required is a prerelease package?

Eilon commented 8 years ago

Hmm I'm not sure NuGet configuration should affect this at all. The NuGet.config files and project.json/project.lock.json files should have everything set up already.

mauricioralcala commented 8 years ago

Tried it again and right now I have to manually install the package on the console:

Install-Package System.Reflection.Metadata -Version 1.1.0-alpha-00014 -Pre

NuGet doesn't resolve the dependency automatically. Adding

"System.Reflection.Metadata": "1.1.0-alpha-00014"

to the project.json, makes the project run without issue. I created a pull request with this change here

Eilon commented 8 years ago

@mrag89 sorry that still doesn't look right. The dependency closure should be picking up that package.

@pranavkm any idea why the alpha version of that package wouldn't be picked up?

pranavkm commented 8 years ago

@mrag89, could you try getting us the restore log? Might tell where it's picking up the packages from. Here's what I would try to make sure you aren't getting cached results:

  1. Delete %LocalAppData%\dnu
  2. Delete %UserProfile%.dnx\packages
  3. Run dnu restore > dnurestore.log and attach it here if it's still failing for you.