New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve assembly paths for reference compilation libraries #2981

Closed
tuespetre opened this Issue Aug 4, 2017 · 49 comments

Comments

Projects
None yet
@tuespetre

tuespetre commented Aug 4, 2017

There is no implementation of ICompilationAssemblyResolver that will resolve paths for a CompilationLibrary with a Type of "reference", so when trying to use libraries like Microsoft.AspNetCore.Mvc that call ResolveReferencePaths, an exception is thrown:

System.InvalidOperationException: Can not find compilation library location for package 'MyLibrary'

This is a regression with 2.x, as the following used to work:

<Reference Include="MyLibrary">
    <HintPath>../../path/to/MyLibrary.dll</HintPath>
</Reference>

I have been reading everything I can find surrounding this issue and came across the following comment:

dotnet/sdk#1213 (comment)

However, this is not an applicable solution for projects that do in fact require PreserveCompilationContext to be true.

Here is what I came up with as a workaround, that lets us develop locally with MVC and also use the precompilation tool for deploys:

    public class MvcConfiguration : IDesignTimeMvcBuilderConfiguration
    {
        private class DirectReferenceAssemblyResolver : ICompilationAssemblyResolver
        {
            public bool TryResolveAssemblyPaths(CompilationLibrary library, List<string> assemblies)
            {
                if (!string.Equals(library.Type, "reference", StringComparison.OrdinalIgnoreCase))
                {
                    return false;
                }

                var paths = new List<string>();

                foreach (var assembly in library.Assemblies)
                {
                    var path = Path.Combine(ApplicationEnvironment.ApplicationBasePath, assembly);

                    if (!File.Exists(path))
                    {
                        return false;
                    }

                    paths.Add(path);
                }

                assemblies.AddRange(paths);

                return true;
            }
        }

        public void ConfigureMvc(IMvcBuilder builder)
        {
            // .NET Core SDK v1 does not pick up reference assemblies so
            // they have to be added for Razor manually. Resolved for
            // SDK v2 by https://github.com/dotnet/sdk/pull/876 OR SO WE THOUGHT
            /*builder.AddRazorOptions(razor =>
            {
                razor.AdditionalCompilationReferences.Add(
                    MetadataReference.CreateFromFile(
                        typeof(PdfHttpHandler).Assembly.Location));
            });*/

            // .NET Core SDK v2 does not resolve reference assemblies' paths
            // at all, so we have to hack around with reflection
            typeof(CompilationLibrary)
                .GetTypeInfo()
                .GetDeclaredField("<DefaultResolver>k__BackingField")
                .SetValue(null, new CompositeCompilationAssemblyResolver(new ICompilationAssemblyResolver[] 
                {
                    new DirectReferenceAssemblyResolver(),
                    new AppBaseCompilationAssemblyResolver(),
                    new ReferenceAssemblyPathResolver(),
                    new PackageCompilationAssemblyResolver(),
                }));
        }
    }
@tuespetre

This comment has been minimized.

Show comment
Hide comment
@tuespetre

tuespetre Aug 5, 2017

Pinging @eerhardt just in case, I feel it's important to address this for 2.0

tuespetre commented Aug 5, 2017

Pinging @eerhardt just in case, I feel it's important to address this for 2.0

@hamidmayeli

This comment has been minimized.

Show comment
Hide comment
@hamidmayeli

hamidmayeli Aug 10, 2017

I have a similar problem, however, the stack trace is slightly different with this article.

InvalidOperationException: Cannot find compilation library location for package 'XXX' Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List<string> assemblies) Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart+<>c.<GetReferencePaths>b__8_0(CompilationLibrary library) System.Linq.Enumerable+SelectManySingleSelectorIterator.MoveNext() Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature) Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature<TFeature>(TFeature feature) Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences() System.Threading.LazyInitializer.EnsureInitializedCore<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory) Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences() Microsoft.AspNetCore.Mvc.Razor.Internal.LazyMetadataReferenceFeature.get_References()

I have used the given solution in this issue in two different projects in the test project which was a new MVC Core project it works but in the real project, just the exception has changed.

untitled

hamidmayeli commented Aug 10, 2017

I have a similar problem, however, the stack trace is slightly different with this article.

InvalidOperationException: Cannot find compilation library location for package 'XXX' Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List<string> assemblies) Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart+<>c.<GetReferencePaths>b__8_0(CompilationLibrary library) System.Linq.Enumerable+SelectManySingleSelectorIterator.MoveNext() Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature) Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature<TFeature>(TFeature feature) Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences() System.Threading.LazyInitializer.EnsureInitializedCore<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory) Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences() Microsoft.AspNetCore.Mvc.Razor.Internal.LazyMetadataReferenceFeature.get_References()

I have used the given solution in this issue in two different projects in the test project which was a new MVC Core project it works but in the real project, just the exception has changed.

untitled

@tuespetre

This comment has been minimized.

Show comment
Hide comment
@tuespetre

tuespetre Aug 10, 2017

@hamidmayeli sorry about that, be sure to put new MvcConfiguration().ConfigureMvc(mvcBuilder); in your ConfigureServices. Just having the class exist is good for the precompilation of views, but for runtime, you have to add that. Sorry, I should have specified that for any passersby.

tuespetre commented Aug 10, 2017

@hamidmayeli sorry about that, be sure to put new MvcConfiguration().ConfigureMvc(mvcBuilder); in your ConfigureServices. Just having the class exist is good for the precompilation of views, but for runtime, you have to add that. Sorry, I should have specified that for any passersby.

@pranavkm

This comment has been minimized.

Show comment
Hide comment
@pranavkm

pranavkm Aug 15, 2017

Contributor

Here's a couple other workarounds for 2.0.0 until we have a resolution:

  • If your application does not have any views, add <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> to disable Razor view compilation.
  • If your application does have views, you can replace the default MetadataReferenceFeatureProvider to not throw when it encounters dll references:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.PortableExecutable;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyModel;

namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
{
    public class ReferencesMetadataReferenceFeatureProvider : IApplicationFeatureProvider<MetadataReferenceFeature>
    {
        public void PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature)
        {
            var libraryPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
            foreach (var assemblyPart in parts.OfType<AssemblyPart>())
            {
                var dependencyContext = DependencyContext.Load(assemblyPart.Assembly);
                if (dependencyContext != null)
                {
                    foreach (var library in dependencyContext.CompileLibraries)
                    {
                        if (string.Equals("reference", library.Type, StringComparison.OrdinalIgnoreCase))
                        {
                            foreach (var libraryAssembly in library.Assemblies)
                            {
                              libraryPaths.Add(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, libraryAssembly));
                            }
                        }
                        else
                        {
                            foreach (var path in library.ResolveReferencePaths())
                            {
                                libraryPaths.Add(path);
                            }
                        }
                    }
                }
                else
                {
                    libraryPaths.Add(assemblyPart.Assembly.Location);
                }
            }

            foreach (var path in libraryPaths)
            {
                feature.MetadataReferences.Add(CreateMetadataReference(path));
            }
        }

        private static MetadataReference CreateMetadataReference(string path)
        {
            using (var stream = File.OpenRead(path))
            {
                var moduleMetadata = ModuleMetadata.CreateFromStream(stream, PEStreamOptions.PrefetchMetadata);
                var assemblyMetadata = AssemblyMetadata.Create(moduleMetadata);

                return assemblyMetadata.GetReference(filePath: path);
            }
        }
    }
}

And in your Startup:

services.AddMvc()
    .ConfigureApplicationPartManager(manager =>
    {
        var oldMetadataReferenceFeatureProvider = manager.FeatureProviders.First(f => f is MetadataReferenceFeatureProvider);
        manager.FeatureProviders.Remove(oldMetadataReferenceFeatureProvider);
        manager.FeatureProviders.Add(new ReferencesMetadataReferenceFeatureProvider());
    });
Contributor

pranavkm commented Aug 15, 2017

Here's a couple other workarounds for 2.0.0 until we have a resolution:

  • If your application does not have any views, add <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> to disable Razor view compilation.
  • If your application does have views, you can replace the default MetadataReferenceFeatureProvider to not throw when it encounters dll references:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.PortableExecutable;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyModel;

namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
{
    public class ReferencesMetadataReferenceFeatureProvider : IApplicationFeatureProvider<MetadataReferenceFeature>
    {
        public void PopulateFeature(IEnumerable<ApplicationPart> parts, MetadataReferenceFeature feature)
        {
            var libraryPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
            foreach (var assemblyPart in parts.OfType<AssemblyPart>())
            {
                var dependencyContext = DependencyContext.Load(assemblyPart.Assembly);
                if (dependencyContext != null)
                {
                    foreach (var library in dependencyContext.CompileLibraries)
                    {
                        if (string.Equals("reference", library.Type, StringComparison.OrdinalIgnoreCase))
                        {
                            foreach (var libraryAssembly in library.Assemblies)
                            {
                              libraryPaths.Add(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, libraryAssembly));
                            }
                        }
                        else
                        {
                            foreach (var path in library.ResolveReferencePaths())
                            {
                                libraryPaths.Add(path);
                            }
                        }
                    }
                }
                else
                {
                    libraryPaths.Add(assemblyPart.Assembly.Location);
                }
            }

            foreach (var path in libraryPaths)
            {
                feature.MetadataReferences.Add(CreateMetadataReference(path));
            }
        }

        private static MetadataReference CreateMetadataReference(string path)
        {
            using (var stream = File.OpenRead(path))
            {
                var moduleMetadata = ModuleMetadata.CreateFromStream(stream, PEStreamOptions.PrefetchMetadata);
                var assemblyMetadata = AssemblyMetadata.Create(moduleMetadata);

                return assemblyMetadata.GetReference(filePath: path);
            }
        }
    }
}

And in your Startup:

services.AddMvc()
    .ConfigureApplicationPartManager(manager =>
    {
        var oldMetadataReferenceFeatureProvider = manager.FeatureProviders.First(f => f is MetadataReferenceFeatureProvider);
        manager.FeatureProviders.Remove(oldMetadataReferenceFeatureProvider);
        manager.FeatureProviders.Add(new ReferencesMetadataReferenceFeatureProvider());
    });

@steveharter steveharter added this to the 2.01 milestone Aug 16, 2017

@steveharter

This comment has been minimized.

Show comment
Hide comment
@steveharter

steveharter Aug 16, 2017

Member

Possible fix for 2.01 is to add new resolver to Microsoft.Extensions.DependencyModel\Resolution that understands CompilationLibrary

Assigning to @eerhardt ; he will be able to evaluate this next week

Member

steveharter commented Aug 16, 2017

Possible fix for 2.01 is to add new resolver to Microsoft.Extensions.DependencyModel\Resolution that understands CompilationLibrary

Assigning to @eerhardt ; he will be able to evaluate this next week

@felyperennan

This comment has been minimized.

Show comment
Hide comment
@felyperennan

felyperennan Aug 23, 2017

Is there a way to tell Razor compilation where to look for assemblies, or to ignore certain assemblies?

After upgrading to 2.0 i suffered for a long day until this hack by @pranavkm "worked the issue around" for me.
My first shock was that PreserveCompilationContext came enabled by default, it caused severe problems with non-nuget assemblies that were added as path reference and Cefsharp.Core (most aren't even used by cshtml views). I read somewhere about razor reference paths, but was unable to correctly configure that.
When I disabled PreserveCompilationContext, then it started asking for manual input of the referenced assemblies, which for me would be okay, i was able to add assemblies with IRazorOptions.CompilationCallback, except for netstandard 2.0.0, which I couldn't find a way to fetch with reflection (my project uses net462, Razor insisted that class "Object" is in netstandard, not mscorlib. I could get mscorlib file location at runtime, but not netstandard)
By returning PreserveCompilationContext to true and using @pranavkm's hack, it worked.
Maybe razor compilation shouldn't be so alarmful by default, maybe expose more ways to configure razor compilation: A way to tell razor to ignore dependency errors, a way to tell razor to ignore assemblies, a way to tell razor where to look for assemblies.

felyperennan commented Aug 23, 2017

Is there a way to tell Razor compilation where to look for assemblies, or to ignore certain assemblies?

After upgrading to 2.0 i suffered for a long day until this hack by @pranavkm "worked the issue around" for me.
My first shock was that PreserveCompilationContext came enabled by default, it caused severe problems with non-nuget assemblies that were added as path reference and Cefsharp.Core (most aren't even used by cshtml views). I read somewhere about razor reference paths, but was unable to correctly configure that.
When I disabled PreserveCompilationContext, then it started asking for manual input of the referenced assemblies, which for me would be okay, i was able to add assemblies with IRazorOptions.CompilationCallback, except for netstandard 2.0.0, which I couldn't find a way to fetch with reflection (my project uses net462, Razor insisted that class "Object" is in netstandard, not mscorlib. I could get mscorlib file location at runtime, but not netstandard)
By returning PreserveCompilationContext to true and using @pranavkm's hack, it worked.
Maybe razor compilation shouldn't be so alarmful by default, maybe expose more ways to configure razor compilation: A way to tell razor to ignore dependency errors, a way to tell razor to ignore assemblies, a way to tell razor where to look for assemblies.

@rustamkulenov

This comment has been minimized.

Show comment
Hide comment
@rustamkulenov

rustamkulenov Aug 31, 2017

The fix of @pranavkm (custom ReferencesMetadataReferenceFeatureProvider) helped me, but it works only under Windows (I'm able to run my application from VS code, or run it after publishing). Under Ubuntu it works only after "dotnet publish", then "dotnet App.dll".
If I run my app by pressing F5 (VS Code, Ubuntu 16.04), I still receive "FileNotFoundException".
I add reference like:
<Reference Include="Geo.DotCore.dll"> <HintPath>./lib/Geo.DotCore.dll</HintPath> </Reference>
and all Dlls are copied to bin folder.

Update
oops, looks like it is different problem, because it reports not about compilation libraries. But it still may be related because it is about references resolution.

rustamkulenov commented Aug 31, 2017

The fix of @pranavkm (custom ReferencesMetadataReferenceFeatureProvider) helped me, but it works only under Windows (I'm able to run my application from VS code, or run it after publishing). Under Ubuntu it works only after "dotnet publish", then "dotnet App.dll".
If I run my app by pressing F5 (VS Code, Ubuntu 16.04), I still receive "FileNotFoundException".
I add reference like:
<Reference Include="Geo.DotCore.dll"> <HintPath>./lib/Geo.DotCore.dll</HintPath> </Reference>
and all Dlls are copied to bin folder.

Update
oops, looks like it is different problem, because it reports not about compilation libraries. But it still may be related because it is about references resolution.

@pranavkm

This comment has been minimized.

Show comment
Hide comment
@pranavkm

pranavkm Sep 1, 2017

Contributor

@rustamkulenov I tried a sample app on Ubuntu 16.04 and it seems to work fine (see https://github.com/pranavkm/fix-ref). Can you share your a repro app?

Contributor

pranavkm commented Sep 1, 2017

@rustamkulenov I tried a sample app on Ubuntu 16.04 and it seems to work fine (see https://github.com/pranavkm/fix-ref). Can you share your a repro app?

@leecow

This comment has been minimized.

Show comment
Hide comment
@leecow

leecow Nov 7, 2017

Member

Hey @ganeshmuthuvelu , we're in the final stages of the next update. Shooting to be live in the next week or so.

Member

leecow commented Nov 7, 2017

Hey @ganeshmuthuvelu , we're in the final stages of the next update. Shooting to be live in the next week or so.

@ganeshmuthuvelu

This comment has been minimized.

Show comment
Hide comment
@ganeshmuthuvelu

ganeshmuthuvelu Nov 7, 2017

Wonderful, can't wait to get it.

ganeshmuthuvelu commented Nov 7, 2017

Wonderful, can't wait to get it.

@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Nov 7, 2017

Member

and most importantly is there any article/thread that links the issue
"Cannot find compilation library location for package "XYZ" as the issue in the Microsoft.Extensions.DependencyModel library ?

This is the main thread for this issue.

Member

eerhardt commented Nov 7, 2017

and most importantly is there any article/thread that links the issue
"Cannot find compilation library location for package "XYZ" as the issue in the Microsoft.Extensions.DependencyModel library ?

This is the main thread for this issue.

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Nov 15, 2017

confirm it's fixed with 2.0.3 November release, thanks

evil-shrike commented Nov 15, 2017

confirm it's fixed with 2.0.3 November release, thanks

@ilya-chumakov

This comment has been minimized.

Show comment
Hide comment
@ilya-chumakov

ilya-chumakov Nov 19, 2017

In my case, Razor compilation was fixed by installing of "Microsoft.Extensions.DependencyModel" Version="2.0.3". Thanks.

ilya-chumakov commented Nov 19, 2017

In my case, Razor compilation was fixed by installing of "Microsoft.Extensions.DependencyModel" Version="2.0.3". Thanks.

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Nov 30, 2017

Well, it seemed to be fixed in 2.0.3 but in my other project I started to get the error again!
in csproj:

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />

dotnet --info:

C:\>dotnet --info
.NET Command Line Tools (2.0.3)

Product Information:
 Version:            2.0.3
 Commit SHA-1 hash:  12f0c7efcc

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.3\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

the error

C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server>dotnet publish -o out
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Server -> C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.dll
  Cannot find compilation library location for package 'Croc.XFW3.Web'
     at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List`1 assemblies)
     at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
     at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.<>c.<GetReferencePaths>b__8_0(CompilationLibrary library)
     at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
     at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable`1 parts, MetadataReferenceFeature feature)
     at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
     at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences()
     at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
     at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences()
     at Microsoft.AspNetCore.Mvc.Razor.Internal.CSharpCompiler.CreateCompilation(String assemblyName)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.CompileViews(ViewCompilationInfo[] results, String assemblyname)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.Execute()
     at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompilationApplication.Execute(String[] args)
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.1\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5): error MSB3073: The command ""C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig "C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.runtimeconfig.json" --depsfile "C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.deps.json" "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.1\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\Server.csproj]

😕

Adding "Microsoft.Extensions.DependencyModel" dependency doesn't help.
Disabling view compilation isn't an option.
Ideas?

evil-shrike commented Nov 30, 2017

Well, it seemed to be fixed in 2.0.3 but in my other project I started to get the error again!
in csproj:

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />

dotnet --info:

C:\>dotnet --info
.NET Command Line Tools (2.0.3)

Product Information:
 Version:            2.0.3
 Commit SHA-1 hash:  12f0c7efcc

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.3\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

the error

C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server>dotnet publish -o out
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Server -> C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.dll
  Cannot find compilation library location for package 'Croc.XFW3.Web'
     at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List`1 assemblies)
     at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
     at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.<>c.<GetReferencePaths>b__8_0(CompilationLibrary library)
     at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
     at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable`1 parts, MetadataReferenceFeature feature)
     at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
     at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences()
     at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
     at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences()
     at Microsoft.AspNetCore.Mvc.Razor.Internal.CSharpCompiler.CreateCompilation(String assemblyName)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.CompileViews(ViewCompilationInfo[] results, String assemblyname)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.Execute()
     at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompilationApplication.Execute(String[] args)
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.1\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5): error MSB3073: The command ""C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig "C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.runtimeconfig.json" --depsfile "C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.deps.json" "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.1\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\Server.csproj]

😕

Adding "Microsoft.Extensions.DependencyModel" dependency doesn't help.
Disabling view compilation isn't an option.
Ideas?

@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Nov 30, 2017

Member

Is Croc.XFW3.Web.dll in your C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0 or C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\refs folder when you get this error?

Member

eerhardt commented Nov 30, 2017

Is Croc.XFW3.Web.dll in your C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0 or C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\refs folder when you get this error?

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Nov 30, 2017

@eerhardt no, it's an assembly from a nuget package the the app references

evil-shrike commented Nov 30, 2017

@eerhardt no, it's an assembly from a nuget package the the app references

@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Nov 30, 2017

Member

Can you ensure the assembly is in your NuGet package cache? This is usually in C:\users\USER\.nuget\packages. Look in the file C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.deps.json for the sub-path to Croc.XFW3.Web.dll. The .deps.json information will tell you where the file is expected to be.

The path is made up of 3 parts.

  1. The above path to the NuGet package cache.
  2. The library's path in the last section of the deps.json file
"Croc.XFW3.Web/1.2.3": {
      "type": "package",
      "serviceable": true,
      "path": "Croc.XFW3.Web/1.2.3",  <------ THIS LINE
    },
  1. The path to the dll from the middle section of the .deps.json file:
"Croc.XFW3.Web/1.2.3": {
        "dependencies": {
        },
        "runtime": {
          "lib/netstandard1.0/Croc.XFW3.Web.dll": {}
        }
      },
Member

eerhardt commented Nov 30, 2017

Can you ensure the assembly is in your NuGet package cache? This is usually in C:\users\USER\.nuget\packages. Look in the file C:\Work\R-n-D\xfw3_webclient_tools\Demo2\Server\bin\Debug\netcoreapp2.0\Croc.Demo2.WebServer.deps.json for the sub-path to Croc.XFW3.Web.dll. The .deps.json information will tell you where the file is expected to be.

The path is made up of 3 parts.

  1. The above path to the NuGet package cache.
  2. The library's path in the last section of the deps.json file
"Croc.XFW3.Web/1.2.3": {
      "type": "package",
      "serviceable": true,
      "path": "Croc.XFW3.Web/1.2.3",  <------ THIS LINE
    },
  1. The path to the dll from the middle section of the .deps.json file:
"Croc.XFW3.Web/1.2.3": {
        "dependencies": {
        },
        "runtime": {
          "lib/netstandard1.0/Croc.XFW3.Web.dll": {}
        }
      },
@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Dec 1, 2017

@eerhardt
In this project I have nuget cache in a local folder (<add key="globalPackagesFolder" value="packages" />). So the assembly is in the folder: .\packages\croc.webclient\2.35.0\lib\netcoreapp2.0\Croc.XFW3.Web.dll.
But if I remove globalPackagesFolder and use global cache, the error persists.

.\packages\croc.webclient\2.35.0\lib\netcoreapp2.0\Croc.XFW3.Web.dll (with globalPackagesFolder in nuget.config)
or
C:\Users\Shrike\.nuget\packages\croc.webclient\2.35.0\lib\netcoreapp2.0\Croc.XFW3.Web.dll
2.

    "Croc.WebClient/2.35.0": {
      "type": "package",
      "serviceable": true,
      "path": "croc.webclient/2.35.0",
    },
      "Croc.WebClient/2.35.0": {
        "dependencies": {
          "Autofac": "4.6.2",
          "Autofac.Extensions.DependencyInjection": "4.2.0",
          "Croc.XFW3.All": "3.0.0",
          "Microsoft.AspNetCore.All": "2.0.3",
          "MimeTypesMap": "1.0.2"
        },
        "runtime": {
          "lib/netcoreapp2.0/Croc.XFW3.Web.Interop.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.PrecompiledViews.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.dll": {}
        },
        "resources": {
          "lib/netcoreapp2.0/ru/Croc.XFW3.Web.resources.dll": {
            "locale": "ru"
          }
        },
        "compile": {
          "lib/netcoreapp2.0/Croc.XFW3.Web.Interop.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.PrecompiledViews.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.dll": {}
        }
      },

as I can understand path is correct and the assembly is located in this path.

evil-shrike commented Dec 1, 2017

@eerhardt
In this project I have nuget cache in a local folder (<add key="globalPackagesFolder" value="packages" />). So the assembly is in the folder: .\packages\croc.webclient\2.35.0\lib\netcoreapp2.0\Croc.XFW3.Web.dll.
But if I remove globalPackagesFolder and use global cache, the error persists.

.\packages\croc.webclient\2.35.0\lib\netcoreapp2.0\Croc.XFW3.Web.dll (with globalPackagesFolder in nuget.config)
or
C:\Users\Shrike\.nuget\packages\croc.webclient\2.35.0\lib\netcoreapp2.0\Croc.XFW3.Web.dll
2.

    "Croc.WebClient/2.35.0": {
      "type": "package",
      "serviceable": true,
      "path": "croc.webclient/2.35.0",
    },
      "Croc.WebClient/2.35.0": {
        "dependencies": {
          "Autofac": "4.6.2",
          "Autofac.Extensions.DependencyInjection": "4.2.0",
          "Croc.XFW3.All": "3.0.0",
          "Microsoft.AspNetCore.All": "2.0.3",
          "MimeTypesMap": "1.0.2"
        },
        "runtime": {
          "lib/netcoreapp2.0/Croc.XFW3.Web.Interop.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.PrecompiledViews.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.dll": {}
        },
        "resources": {
          "lib/netcoreapp2.0/ru/Croc.XFW3.Web.resources.dll": {
            "locale": "ru"
          }
        },
        "compile": {
          "lib/netcoreapp2.0/Croc.XFW3.Web.Interop.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.PrecompiledViews.dll": {},
          "lib/netcoreapp2.0/Croc.XFW3.Web.dll": {}
        }
      },

as I can understand path is correct and the assembly is located in this path.

@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Dec 4, 2017

Member

Would it be possible to debug the DependencyModel code? You should be able to

  1. git clone https://github.com/dotnet/core-setup.git
  2. git checkout v2.0.3
  3. Break on InvalidOperationException
  4. Load the symbols from the Microsoft Symbols Server

Then set a breakpoint and run again, and debug where it is looking, and why it isn't finding the assembly it is looking for.

I can do this, if it would be possible to send me a repro. You can find my email on my GitHub page https://github.com/eerhardt.

Member

eerhardt commented Dec 4, 2017

Would it be possible to debug the DependencyModel code? You should be able to

  1. git clone https://github.com/dotnet/core-setup.git
  2. git checkout v2.0.3
  3. Break on InvalidOperationException
  4. Load the symbols from the Microsoft Symbols Server

Then set a breakpoint and run again, and debug where it is looking, and why it isn't finding the assembly it is looking for.

I can do this, if it would be possible to send me a repro. You can find my email on my GitHub page https://github.com/eerhardt.

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Dec 4, 2017

@eerhardt I'm sorry but I have difficulties with breaking at exception in dotnet.exe.
I tries the old approach for registering vsjitdebugger.exe in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\dotnet.exe
But while jitdebugger starts I have no VS2017 in the debuggers list. Of cause in VS's options it's checked in Debugger/Just-in-time Debugger/Managed.
In VS2015 I only got into native debugging where I can't do anything useful.
I tied some extension for auto-attaching VS to a process - https://marketplace.visualstudio.com/items?itemName=EntrianSolutions-RichieHindle.EntrianAttachAuto-Attachthedebuggeratprocessstart
VS tried to attach and then debugger terminated with the error:
"A fatal error has occurred and debugging needs to be terminated. For more details, please see the Microsoft Help and Support web site. HRESULT=0x8000ffff. ErrorCode=0x0."
That VS2017 is one big disaster :(

So if you have any idea how can I got into debugging of not-started-yet process, I'm ready to try something more...

evil-shrike commented Dec 4, 2017

@eerhardt I'm sorry but I have difficulties with breaking at exception in dotnet.exe.
I tries the old approach for registering vsjitdebugger.exe in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\dotnet.exe
But while jitdebugger starts I have no VS2017 in the debuggers list. Of cause in VS's options it's checked in Debugger/Just-in-time Debugger/Managed.
In VS2015 I only got into native debugging where I can't do anything useful.
I tied some extension for auto-attaching VS to a process - https://marketplace.visualstudio.com/items?itemName=EntrianSolutions-RichieHindle.EntrianAttachAuto-Attachthedebuggeratprocessstart
VS tried to attach and then debugger terminated with the error:
"A fatal error has occurred and debugging needs to be terminated. For more details, please see the Microsoft Help and Support web site. HRESULT=0x8000ffff. ErrorCode=0x0."
That VS2017 is one big disaster :(

So if you have any idea how can I got into debugging of not-started-yet process, I'm ready to try something more...

@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Dec 4, 2017

Member

Here's what I do (it probably isn't the easiest or most efficient, but it works for me):

  1. Launch VS 2017
  2. Create New Project -> Visual C# -> .NET Core -> Console App
  3. Right click the project in Solution Explorer -> Properties
  4. "Debug" tab -> Change "Launch" from "Project" to "Executable"
  5. Executable - C:\Program Files\dotnet\dotnet.exe
  6. Application Arguments - F:\DotNetTest\TestWeb\bin\Debug\netcoreapp2.0\TestWeb.dll
  7. Working directory - F:\DotNetTest\TestWeb

Replace any of the paths above with your paths and app name.

Make sure you uncheck "Enable Just My Code" in Tools -> Options -> Debugging.

It looks like we are having some problems with the Microsoft.Extensions.DependencyModel symbols on the Microsoft Symbols Server. If you can't load the symbols from there, you can find them https://dotnetcli.blob.core.windows.net/dotnet/Runtime/2.0.3/Microsoft.Extensions.DependencyModel.2.0.3.symbols.nupkg. Download and rename that file to .zip and you can find the .pdb under lib\netstandard1.6 in the .zip file.

Member

eerhardt commented Dec 4, 2017

Here's what I do (it probably isn't the easiest or most efficient, but it works for me):

  1. Launch VS 2017
  2. Create New Project -> Visual C# -> .NET Core -> Console App
  3. Right click the project in Solution Explorer -> Properties
  4. "Debug" tab -> Change "Launch" from "Project" to "Executable"
  5. Executable - C:\Program Files\dotnet\dotnet.exe
  6. Application Arguments - F:\DotNetTest\TestWeb\bin\Debug\netcoreapp2.0\TestWeb.dll
  7. Working directory - F:\DotNetTest\TestWeb

Replace any of the paths above with your paths and app name.

Make sure you uncheck "Enable Just My Code" in Tools -> Options -> Debugging.

It looks like we are having some problems with the Microsoft.Extensions.DependencyModel symbols on the Microsoft Symbols Server. If you can't load the symbols from there, you can find them https://dotnetcli.blob.core.windows.net/dotnet/Runtime/2.0.3/Microsoft.Extensions.DependencyModel.2.0.3.symbols.nupkg. Download and rename that file to .zip and you can find the .pdb under lib\netstandard1.6 in the .zip file.

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Dec 5, 2017

@eerhardt nailed it down

It happening in CompilationLibrary.ResolveReferencePaths for
image

the problem is that it's a "Type=project" while the csproj has no project references. This lib ("Croc.XFW3.Web") is added as a package dependency and already was processed:
image

I can't figure out where this CompilationLibrary came from as below in the stack - Microsoft.AspNetCore.Mvc.Core.dll and its symbol won't load:

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD05ffffffff/Microsoft.AspNetCore.Mvc.Core.pdb

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD05ffffffff/Microsoft.AspNetCore.Mvc.Core.pd_

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD05ffffffff/file.ptr

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  RESULT: 0x80190194

SYMSRV:  BYINDEX: 0x5A0
         C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache*https://msdl.microsoft.com/download/symbols
         Microsoft.AspNetCore.Mvc.Core.pdb
         A7BCD631130840DD9C5C7ABEF81EAD051

SYMSRV:  UNC: C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache\Microsoft.AspNetCore.Mvc.Core.pdb\A7BCD631130840DD9C5C7ABEF81EAD051\Microsoft.AspNetCore.Mvc.Core.pdb - path not found

SYMSRV:  UNC: C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache\Microsoft.AspNetCore.Mvc.Core.pdb\A7BCD631130840DD9C5C7ABEF81EAD051\Microsoft.AspNetCore.Mvc.Core.pd_ - path not found

SYMSRV:  UNC: C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache\Microsoft.AspNetCore.Mvc.Core.pdb\A7BCD631130840DD9C5C7ABEF81EAD051\file.ptr - path not found

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD051/Microsoft.AspNetCore.Mvc.Core.pdb

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD051/Microsoft.AspNetCore.Mvc.Core.pd_

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD051/file.ptr

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  RESULT: 0x80190194

https://msdl.microsoft.com/download/symbols: Symbols not found on symbol server.

Could you suggest where can I get symbols for Microsoft.AspNetCore.Mvc.Core?

stack:

>	Microsoft.Extensions.DependencyModel.dll!Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(Microsoft.Extensions.DependencyModel.Resolution.ICompilationAssemblyResolver resolver, System.Collections.Generic.List<string> assemblies) Line 79	C#	Symbols loaded.
 	Microsoft.Extensions.DependencyModel.dll!Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() Line 54	C#	Symbols loaded.
 	Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.GetReferencePaths.AnonymousMethod__8_0(Microsoft.Extensions.DependencyModel.CompilationLibrary library)	Unknown	No symbols loaded.
 	System.Linq.dll!System.Linq.Enumerable.SelectManySingleSelectorIterator<Microsoft.Extensions.DependencyModel.CompilationLibrary, string>.MoveNext() Line 204	C#	Symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPart> parts, Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeature feature)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature<Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeature>(Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeature feature)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences()	Unknown	No symbols loaded.
 	System.Private.CoreLib.dll!System.Threading.LazyInitializer.EnsureInitializedCore<System.__Canon>(ref System.__Canon target, ref bool initialized, ref object syncLock, System.Func<System.__Canon> valueFactory) Line 199	C#	Symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.CompilationReferences.get()	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Internal.CSharpCompiler.CreateCompilation(string assemblyName)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.CompileViews(Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.ViewCompilationInfo[] results, string assemblyname)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.Execute()	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(string[] args)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompilationApplication.Execute(string[] args)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Program.Main(string[] args)	Unknown	No symbols loaded.

evil-shrike commented Dec 5, 2017

@eerhardt nailed it down

It happening in CompilationLibrary.ResolveReferencePaths for
image

the problem is that it's a "Type=project" while the csproj has no project references. This lib ("Croc.XFW3.Web") is added as a package dependency and already was processed:
image

I can't figure out where this CompilationLibrary came from as below in the stack - Microsoft.AspNetCore.Mvc.Core.dll and its symbol won't load:

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD05ffffffff/Microsoft.AspNetCore.Mvc.Core.pdb

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD05ffffffff/Microsoft.AspNetCore.Mvc.Core.pd_

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD05ffffffff/file.ptr

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  RESULT: 0x80190194

SYMSRV:  BYINDEX: 0x5A0
         C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache*https://msdl.microsoft.com/download/symbols
         Microsoft.AspNetCore.Mvc.Core.pdb
         A7BCD631130840DD9C5C7ABEF81EAD051

SYMSRV:  UNC: C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache\Microsoft.AspNetCore.Mvc.Core.pdb\A7BCD631130840DD9C5C7ABEF81EAD051\Microsoft.AspNetCore.Mvc.Core.pdb - path not found

SYMSRV:  UNC: C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache\Microsoft.AspNetCore.Mvc.Core.pdb\A7BCD631130840DD9C5C7ABEF81EAD051\Microsoft.AspNetCore.Mvc.Core.pd_ - path not found

SYMSRV:  UNC: C:\Users\Sergei Dorogin\AppData\Local\Temp\SymbolCache\Microsoft.AspNetCore.Mvc.Core.pdb\A7BCD631130840DD9C5C7ABEF81EAD051\file.ptr - path not found

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD051/Microsoft.AspNetCore.Mvc.Core.pdb

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD051/Microsoft.AspNetCore.Mvc.Core.pd_

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  HTTPGET: /download/symbols/Microsoft.AspNetCore.Mvc.Core.pdb/A7BCD631130840DD9C5C7ABEF81EAD051/file.ptr

SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND

SYMSRV:  RESULT: 0x80190194

https://msdl.microsoft.com/download/symbols: Symbols not found on symbol server.

Could you suggest where can I get symbols for Microsoft.AspNetCore.Mvc.Core?

stack:

>	Microsoft.Extensions.DependencyModel.dll!Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(Microsoft.Extensions.DependencyModel.Resolution.ICompilationAssemblyResolver resolver, System.Collections.Generic.List<string> assemblies) Line 79	C#	Symbols loaded.
 	Microsoft.Extensions.DependencyModel.dll!Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() Line 54	C#	Symbols loaded.
 	Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.GetReferencePaths.AnonymousMethod__8_0(Microsoft.Extensions.DependencyModel.CompilationLibrary library)	Unknown	No symbols loaded.
 	System.Linq.dll!System.Linq.Enumerable.SelectManySingleSelectorIterator<Microsoft.Extensions.DependencyModel.CompilationLibrary, string>.MoveNext() Line 204	C#	Symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPart> parts, Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeature feature)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Core.dll!Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature<Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeature>(Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeature feature)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences()	Unknown	No symbols loaded.
 	System.Private.CoreLib.dll!System.Threading.LazyInitializer.EnsureInitializedCore<System.__Canon>(ref System.__Canon target, ref bool initialized, ref object syncLock, System.Func<System.__Canon> valueFactory) Line 199	C#	Symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.CompilationReferences.get()	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.Internal.CSharpCompiler.CreateCompilation(string assemblyName)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.CompileViews(Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.ViewCompilationInfo[] results, string assemblyname)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.Execute()	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(string[] args)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompilationApplication.Execute(string[] args)	Unknown	No symbols loaded.
 	Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll!Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Program.Main(string[] args)	Unknown	No symbols loaded.
@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Dec 5, 2017

Member

Looks like we are having troubles with the Mvc symbols for 2.0.3 as well. I'll follow up with the Mvc team to see what the issue is with loading those symbols.

However, the problem appears to be what you said - that assembly shouldn't be getting a type=project entry. Can you send the following files:

  • obj\project.assets.json
  • bin\Debug\netcoreapp2.0\AppName.deps.json

Even better would be if you could send the NuGet package. I suspect there is something unconventional about it that is confusing the build task that creates the .deps.json file.

Member

eerhardt commented Dec 5, 2017

Looks like we are having troubles with the Mvc symbols for 2.0.3 as well. I'll follow up with the Mvc team to see what the issue is with loading those symbols.

However, the problem appears to be what you said - that assembly shouldn't be getting a type=project entry. Can you send the following files:

  • obj\project.assets.json
  • bin\Debug\netcoreapp2.0\AppName.deps.json

Even better would be if you could send the NuGet package. I suspect there is something unconventional about it that is confusing the build task that creates the .deps.json file.

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike Dec 5, 2017

@eerhardt I sent you email with a download link with my project (from sdorogin@... address). thank you in advance if you find time to look into.

evil-shrike commented Dec 5, 2017

@eerhardt I sent you email with a download link with my project (from sdorogin@... address). thank you in advance if you find time to look into.

@nefcanto

This comment has been minimized.

Show comment
Hide comment
@nefcanto

nefcanto Jan 1, 2018

@evil-shrike you said you solved it by referencing Microsoft.Extensions.DependencyModel version 2.0.3. How did you do that? I'm referencing the well-known Nuget metapackage Microsoft.AspNetCore.All and I can't find DependencyModel beneath it. Can you elaborate a little please?

nefcanto commented Jan 1, 2018

@evil-shrike you said you solved it by referencing Microsoft.Extensions.DependencyModel version 2.0.3. How did you do that? I'm referencing the well-known Nuget metapackage Microsoft.AspNetCore.All and I can't find DependencyModel beneath it. Can you elaborate a little please?

@eerhardt

This comment has been minimized.

Show comment
Hide comment
@eerhardt

eerhardt Jan 2, 2018

Member

@nefcanto - You can reference version 2.0.3 of Microsoft.AspNetCore.All, which will bring in the updated Microsoft.Extensions.DependencyModel package.

Microsoft.Extensions.DependencyModel is referenced by Microsoft.AspNetCore.Mvc.Core, in case you want to know the full dependency chain.

Member

eerhardt commented Jan 2, 2018

@nefcanto - You can reference version 2.0.3 of Microsoft.AspNetCore.All, which will bring in the updated Microsoft.Extensions.DependencyModel package.

Microsoft.Extensions.DependencyModel is referenced by Microsoft.AspNetCore.Mvc.Core, in case you want to know the full dependency chain.

@JonathanBurgos

This comment has been minimized.

Show comment
Hide comment
@JonathanBurgos

JonathanBurgos Jan 5, 2018

@ahdung @tuespetre Hello, it wanted to give me an example of since I use the MvcConfiguration (). ConfigureMvc (mvcBuilder), I am new in .net core and have the same mistake

JonathanBurgos commented Jan 5, 2018

@ahdung @tuespetre Hello, it wanted to give me an example of since I use the MvcConfiguration (). ConfigureMvc (mvcBuilder), I am new in .net core and have the same mistake

@ngohungphuc

This comment has been minimized.

Show comment
Hide comment
@ngohungphuc

ngohungphuc Jan 22, 2018

Tried @pakrym solution in my project
ReferenceFeatureProvider.cs

and in this

I will get this error
image

ngohungphuc commented Jan 22, 2018

Tried @pakrym solution in my project
ReferenceFeatureProvider.cs

and in this

I will get this error
image

@dacanetdev

This comment has been minimized.

Show comment
Hide comment
@dacanetdev

dacanetdev Jun 14, 2018

I was having the issue and got resolved updating to AspNetCore.All 2.0.3

dacanetdev commented Jun 14, 2018

I was having the issue and got resolved updating to AspNetCore.All 2.0.3

@JasonPierce

This comment has been minimized.

Show comment
Hide comment
@JasonPierce

JasonPierce Jul 10, 2018

I ran into this issue with .NET Core 2.1.1. I was using the RazorLight lib coupled with some cshtml files for FluentEmail. Having the cshtml email templates in my project triggered error "Cannot find compilation library location for package" after deployment. I truly did not need the Razor compilation, since it was being handled by RazorLight at runtime, so adding <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> to the csproj resolved the issue

JasonPierce commented Jul 10, 2018

I ran into this issue with .NET Core 2.1.1. I was using the RazorLight lib coupled with some cshtml files for FluentEmail. Having the cshtml email templates in my project triggered error "Cannot find compilation library location for package" after deployment. I truly did not need the Razor compilation, since it was being handled by RazorLight at runtime, so adding <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> to the csproj resolved the issue

henningjensen added a commit to kartverket/Geonorge.MinSide that referenced this issue Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment