6

Ao executar o comando Update-Database tenho o seguinte erro

Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Todo o output do comando

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Running Seed method.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
File name: 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Syns.Common.SynsLegadoContext.Auditar()
   at Syns.Common.SynsLegadoContext.SaveChangesAsync(CancellationToken cancellationToken) in D:\Projetos\Syns\Syns\Syns\SynsLegadoContext.cs:line 38
   at System.Data.Entity.DbContext.SaveChangesAsync()
   at Microsoft.AspNet.Identity.EntityFramework.UserStore`6.<SaveChanges>d__5a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.EntityFramework.UserStore`6.<UpdateAsync>d__1c.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.UserManager`2.<UpdateAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNet.Identity.UserManager`2.<RemovePasswordAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.AsyncHelper.RunSync[TResult](Func`1 func)
   at Microsoft.AspNet.Identity.UserManagerExtensions.RemovePassword[TUser,TKey](UserManager`2 manager, TKey userId)
   at Syns.Common.Migrations.Configuration.AlterarSenhaUsuarios() in D:\Projetos\Syns\Syns\Syns\Migrations\Configuration.cs:line 265
   at Syns.Common.Migrations.Configuration.Seed(SynsLegadoContext context) in D:\Projetos\Syns\Syns\Syns\Migrations\Configuration.cs:line 41
   at System.Data.Entity.Migrations.DbMigrationsConfiguration`1.OnSeed(DbContext context)
   at System.Data.Entity.Migrations.DbMigrator.SeedDatabase()
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.SeedDatabase()
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClasse.<Update>b__d()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

AVI: o log de associações de assembly está desativado.
Para ativar o log de  falhas de assembly, defina o valor do Registro [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) como 1.
Observação: há alguma penalidade para o desempenho associada ao log de falha de associação de assembly.
Para desativar esse recurso, remova o valor do Registro [HKLM\Software\Microsoft\Fusion!EnableLog].

Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
7
  • veja no seu config o Microsoft.Build.Framework se você não tive usando ele ou seja não tive instalado, delete a linha que o contem do web.config. se não instale ele no seu projeto. Commented 14/12/2017 às 11:11
  • Não tenho referência ao Microsoft.Build.Framework no meu web.config Commented 14/12/2017 às 11:13
  • Estranho, em algum lugar ele esta tentando acessa essa dll. tem uma resposta ... stackoverflow.com/a/43498190/2740371 Commented 14/12/2017 às 11:17
  • 1
    O que eu fiz está nessa resposta stackoverflow.com/a/44723132/2221388 até então tem me resolvido o problema. Commented 14/12/2017 às 11:20
  • 1
    Pois é, a cada novo update do VS ele volta a colocar o caminho das dll com ..\..\ ai eu troco pro caminho relativo e resolve. Commented 14/12/2017 às 11:30

1 Resposta 1

5

Após algumas semanas lutando com este problema, fiz algumas descobertas.

A primeira é que o caminho para a DLL Microsoft.Build.Framework no arquivo devenv.exe.config que está na pasta C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ está definido da seguinte forma ..\..\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll o que remeteria para a pasta C:\Program Files (x86)\Microsoft Visual Studio\2017\Community, logo pensei que alterando todos as ocorrências onde tem ..\..\ para o caminho completo sanaria. Porém essa solução é afetada quando atualizo o VS e por algum outro motivo, que não descobri ainda, o VS altera esse arquivo.

A última solução que apliquei foi registrar as dlls usando o gacutil

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll"

Antes de rodar esses comandos, tem que fechar o Visual Studio e abrir o Developer Command Prompt for VS 2017 como Administrador.

Isso tem sido minha solução por enquanto.

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .