Skip to content

Assembly with same name is already loaded #2493

@kentcb

Description

@kentcb

What You Are Seeing?

I'm attempting to switch from manually loading a slew of NuGets, to loading only the "main" ones and using loaddependencies to get the rest.

First of all, attempting to run my script is incredibly slow (even a second time once the cache is primed). Secondly, it gives me an error:

Error: System.IO.FileLoadException: Assembly with same name is already loaded
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Cake.Core.Reflection.AssemblyLoader.Load(FilePath path, Boolean verify) in C:\projects\cake\src\Cake.Core\Reflection\AssemblyLoader.cs:line 31
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 171
   at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:\projects\cake\src\Cake\Commands\BuildCommand.cs:line 41
   at Cake.CakeApplication.Run(CakeOptions options) in C:\projects\cake\src\Cake\CakeApplication.cs:line 45
at Cake.Program.Main() in C:\projects\cake\src\Cake\Program.cs:line 73

What is Expected?

That it works or gives me a more useful error.

What version of Cake are you using?

I tried with both 0.28.1 and 0.32.1.

Are you running on a 32 or 64 bit system?

64-bit

What environment are you running on? Windows? Linux? Mac?

Windows, but running the build inside a Linux Docker container.

How Did You Get This To Happen? (Steps to Reproduce)

Just running this puppy:

#addin nuget:?package=Cake.Git&version=0.19.0
#addin nuget:?package=Newtonsoft.Json&version=11.0.2

#addin nuget:?package=Microsoft.Azure.KeyVault&version=3.0.2&loaddependencies=true
#addin nuget:?package=Microsoft.Azure.Management.Fluent&version=1.18.0&loaddependencies=true
#addin nuget:?package=Microsoft.Rest.ClientRuntime.Azure&version=3.3.18&loaddependencies=true
#addin nuget:?package=Microsoft.Rest.ClientRuntime.Azure.Authentication&version=2.3.6&loaddependencies=true
#addin nuget:?package=Microsoft.ServiceFabric.Client.Http&version=2.0.0-preview1&loaddependencies=true
#addin nuget:?package=WindowsAzure.Storage&version=9.3.3&loaddependencies=true

Task("Build")
    .Does(() => Console.WriteLine("Oh, hai"));

RunTarget(Argument("target", "Build"));

Output Log

I've upload the full diagnostic log here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions