efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Bundle-Migration errors with "cannot access file...being used by another process"

Open bricelam opened this issue 4 years ago • 81 comments

Originally reported by @ryanrichard19 in https://github.com/dotnet/efcore/issues/19693#issuecomment-900396649

For some reason, dotnet publish is behaving differently between Bundle-Migration and dotnet ef migrations bundle.

PM> Bundle-Migration -Verbose
Using project 'MarketingIncentive.Data'.
Using startup project 'MarketingIncentive.API'.
Build started...
Build succeeded.
C:\Program Files\dotnet\dotnet.exe exec --depsfile C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.API.deps.json --additionalprobingpath C:\Users\mrrar\.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" --additionalprobingpath "C:\Program Files (x86)\Microsoft\Xamarin\NuGet" --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.API.runtimeconfig.json C:\Users\mrrar\.nuget\packages\microsoft.entityframeworkcore.tools\6.0.0-preview.7.21378.4\tools\netcoreapp2.0\any\ef.dll migrations bundle --verbose --no-color --prefix-output --assembly C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll --project C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\MarketingIncentive.Data.csproj --startup-assembly C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.API.dll --startup-project C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj --project-dir C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\ --language C# --working-dir C:\Users\mrrar\Development\MarketingIncentive --root-namespace MarketingIncentive.Data
Using assembly 'MarketingIncentive.Data'.
Using startup assembly 'MarketingIncentive.API'.
Using application base 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0'.
Using working directory 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API'.
Using root namespace 'MarketingIncentive.Data'.
Using project directory 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'MarketingIncentive.API'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'MarketingIncentiveDBContext'.
Finding DbContext classes in the project...
Using context 'MarketingIncentiveDBContext'.
Building bundle...
dotnet publish --output C:\Users\mrrar\AppData\Local\Temp\etc5av4u.vrh\publish
Microsoft (R) Build Engine version 17.0.0-preview-21378-03+d592862ed for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\mrrar\AppData\Local\Temp\etc5av4u.vrh\bundle.csproj (in 319 ms).
  2 of 3 projects are up-to-date for restore.
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  MarketingIncentive.Data -> C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 2 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 7 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 8 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 9 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Beginning retry 10 in 1000ms. The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): error MSB3027: Could not copy "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". Exceeded retry count of 10. Failed.  [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4685,5): error MSB3021: Unable to copy file "C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.Data\bin\Debug\net6.0\MarketingIncentive.Data.dll" to "bin\Debug\net6.0\MarketingIncentive.Data.dll". The process cannot access the file 'C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\bin\Debug\net6.0\MarketingIncentive.Data.dll' because it is being used by another process. [C:\Users\mrrar\Development\MarketingIncentive\MarketingIncentive.API\MarketingIncentive.API.csproj]
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args) in ef.dll:token 0x60001a9+0x23b
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args) in ef.dll:token 0x6000205+0x3b
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) in ef.dll:token 0x6000053+0x100
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) in ef.dll:token 0x60000cf+0x2e
Build failed. Use --verbose to see errors.

bricelam avatar Aug 17 '21 17:08 bricelam

Note from triage: consider removing.

ajcvickers avatar Sep 04 '21 08:09 ajcvickers

I'm seeing the same problem when running dotnet ef migrations bundle --verbose while the project is open in VSCode. If I close VSCode it works. I'm running on preview7 on Windows 10 and I've tried by removing my runtime targets and such but the error persists even with a minimal project file (see below).

$ dotnet ef migrations bundle --verbose
Using project 'X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj'.
Using startup project 'X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj'.
Writing 'X:\Github\songbird\src\Songbird.Web\obj\Songbird.Web.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\Karl\AppData\Local\Temp\tmp5143.tmp /verbosity:quiet /nologo X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj
Writing 'X:\Github\songbird\src\Songbird.Web\obj\Songbird.Web.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\Karl\AppData\Local\Temp\tmp5309.tmp /verbosity:quiet /nologo X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj
Build started...
dotnet build X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj /verbosity:quiet /nologo

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.33
Build succeeded.
dotnet exec --depsfile X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.deps.json --additionalprobingpath C:\Users\Karl\.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.runtimeconfig.json C:\Users\Karl\.nuget\packages\dotnet-ef\6.0.0-preview.7.21378.4\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations bundle --assembly X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll --project X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj --startup-assembly X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll --startup-project X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj --project-dir X:\Github\songbird\src\Songbird.Web\ --root-namespace Songbird.Web --language C# --working-dir X:\Github\songbird\src\Songbird.Web --verbose
Using assembly 'Songbird.Web'.
Using startup assembly 'Songbird.Web'.
Using application base 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0'.
Using working directory 'X:\Github\songbird\src\Songbird.Web'.
Using root namespace 'Songbird.Web'.
Using project directory 'X:\Github\songbird\src\Songbird.Web\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'Songbird.Web'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'SongbirdContext'.
Finding DbContext classes in the project...
Using context 'SongbirdContext'.
Building bundle...
dotnet publish --output C:\Users\Karl\AppData\Local\Temp\pqtfcewu.r5o\publish
Microsoft (R) Build Engine version 17.0.0-preview-21378-03+d592862ed for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\Karl\AppData\Local\Temp\pqtfcewu.r5o\bundle.csproj (in 735 ms).
  1 of 2 projects are up-to-date for restore.
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 2 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 7 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 8 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 9 in 1000ms. The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): warning MSB3026: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Beginning retry 10 in 1000ms. The process cannot 
access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): error MSB3027: Could not copy "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". Exceeded retry count of 10. Failed.  [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4508,5): error MSB3021: Unable to copy file "obj\Debug\net6.0\Songbird.Web.dll" to "bin\Debug\net6.0\Songbird.Web.dll". The process cannot access the file 'X:\Github\songbird\src\Songbird.Web\bin\Debug\net6.0\Songbird.Web.dll' because it is being used by another process. [X:\Github\songbird\src\Songbird.Web\Songbird.Web.csproj]
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args) in ef.dll:token 0x60001a9+0x23b
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args) in ef.dll:token 0x6000205+0x3b
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) in ef.dll:token 0x6000053+0x100
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) in ef.dll:token 0x60000cf+0x2e
Build failed. Use --verbose to see errors.

This is the project I'm trying to build a bundle for. Both building and publishing works fine.

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AspNetCore.HealthChecks.UI" Version="5.0.1" />
    <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
    <PackageReference Include="AutoMapper.Collection" Version="7.0.1" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
    <PackageReference Include="LetterAvatars.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.0-preview.7.21378.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-preview.7.21378.4">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-preview.7.21378.4" />
    <PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="6.0.0-preview.7.21378.6" />
    <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.0-preview.7.21378.6" />
    <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.0-preview.7.21378.6" />
    <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="6.0.0-preview.7.21378.6" />
    <PackageReference Include="Microsoft.Identity.Web" Version="1.16.0" />
    <PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.16.0" />
    <PackageReference Include="NEST" Version="7.14.1" />
    <PackageReference Include="NEST.JsonNetSerializer" Version="7.14.1" />
    <PackageReference Include="RobotsTxtCore" Version="1.1.0" />
    <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
  </ItemGroup>
</Project>

karl-sjogren avatar Sep 07 '21 07:09 karl-sjogren

This appears to be fixed on RC1 with latest version of Visual Studio. I wonder if OmniSharp just needs to catch up too...

bricelam avatar Sep 14 '21 21:09 bricelam

Seems like it is broken again with dotnet-ef 6.0.0-rc.2.21480.5 ? This error does not appear with 6.0.0-rc.1.21452.10

keenjus avatar Oct 13 '21 19:10 keenjus

gah ... I'm getting it now too (preparing for conference demo this week eek) VS Code on Windows using EF Core Version="6.0.0-rtm.21518.2 I have the same version of the tools. Dotnet version 6.0.100-rc.2.21505.57. "Punted for 6" as in not getting fixed??

julielerman avatar Oct 18 '21 19:10 julielerman

I´m getting this error both with 6.0.0-rc.1.21452.10 and 6.0.0-rc.2.21480.5 it doesn´t matter if restart the machine and just run the bundle script.

C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]

Workaround: I downloaded LockHunter and pointed it to the EFCoreMigrationWeb.dll and when the dotnet process was showing this warning I unlocked the process and it finished creating the bundle.

Below is the complete output log. I also uploaded the project to here if you would like to try it out.

C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore> dotnet ef migrations bundle --verbose
Using project 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj'.
Using startup project 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj'.
Writing 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\obj\EFCoreMigrationWeb.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\sturla.thorvaldsson\AppData\Local\Temp\tmp3D.tmp /verbosity:quiet /nologo C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj
Writing 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\obj\EFCoreMigrationWeb.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\sturla.thorvaldsson\AppData\Local\Temp\tmp222.tmp /verbosity:quiet /nologo C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj
Build started...
dotnet build C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj /verbosity:quiet /nologo
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Email.cs(5,23): warning CS8618: Non-nullable property 'Id' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Email.cs(6,23): warning CS8618: Non-nullable property 'EmailAddress' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(6,23): warning CS8618: Non-nullable property 'StreetAddress' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(7,23): warning CS8618: Non-nullable property 'City' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(8,23): warning CS8618: Non-nullable property 'State' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(9,23): warning CS8618: Non-nullable property 'PostalCode' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Person.cs(8,23): warning CS8618: Non-nullable property 'FirstName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Person.cs(9,23): warning CS8618: Non-nullable property 'LastName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Program.cs(155,12): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]

Build succeeded.

C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Email.cs(5,23): warning CS8618: Non-nullable property 'Id' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Email.cs(6,23): warning CS8618: Non-nullable property 'EmailAddress' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(6,23): warning CS8618: Non-nullable property 'StreetAddress' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(7,23): warning CS8618: Non-nullable property 'City' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(8,23): warning CS8618: Non-nullable property 'State' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(9,23): warning CS8618: Non-nullable property 'PostalCode' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Person.cs(8,23): warning CS8618: Non-nullable property 'FirstName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Person.cs(9,23): warning CS8618: Non-nullable property 'LastName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Program.cs(155,12): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
    9 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.05
Build succeeded.
dotnet exec --depsfile C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.deps.json --additionalprobingpath C:\Users\sturla.thorvaldsson\.nuget\packages --runtimeconfig C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.runtimeconfig.json C:\Users\sturla.thorvaldsson\.dotnet\tools\.store\dotnet-ef\6.0.0-rc.1.21452.10\dotnet-ef\6.0.0-rc.1.21452.10\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations bundle --assembly C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll --project C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj --startup-assembly C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll --startup-project C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj --project-dir C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\ --root-namespace EFCoreMigrationWeb --language C# --framework net6.0 --nullable --working-dir C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore --verbose
Using assembly 'EFCoreMigrationWeb'.
Using startup assembly 'EFCoreMigrationWeb'.
Using application base 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0'.
Using working directory 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore'.
Using root namespace 'EFCoreMigrationWeb'.
Using project directory 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'EFCoreMigrationWeb'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'TodoDbContext'.
Finding DbContext classes in the project...
Using context 'TodoDbContext'.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 6.0.0-rc.2.21480.5 initialized 'TodoDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.0-rc.2.21480.5' with options: None
Building bundle...
dotnet publish --runtime win10-x64 --output C:\Users\sturla.thorvaldsson\AppData\Local\Temp\i35uregs.wj3\publish --no-self-contained
Microsoft (R) Build Engine version 17.0.0-preview-21460-01+8f208e609 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\sturla.thorvaldsson\AppData\Local\Temp\i35uregs.wj3\efbundle.csproj (in 420 ms).
  Restored C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj (in 420 ms).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(6,23): warning CS8618: Non-nullable property 'StreetAddress' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(7,23): warning CS8618: Non-nullable property 'City' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(8,23): warning CS8618: Non-nullable property 'State' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Address.cs(9,23): warning CS8618: Non-nullable property 'PostalCode' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Email.cs(5,23): warning CS8618: Non-nullable property 'Id' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Email.cs(6,23): warning CS8618: Non-nullable property 'EmailAddress' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Person.cs(8,23): warning CS8618: Non-nullable property 'FirstName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Models\Person.cs(9,23): warning CS8618: Non-nullable property 'LastName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\Program.cs(155,12): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 2 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 7 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 8 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 9 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): warning MSB3026: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Beginning retry 10 in 1000ms. The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): error MSB3027: Could not copy "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". Exceeded retry count of 10. Failed.  [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\Microsoft.Common.CurrentVersion.targets(4646,5): error MSB3021: Unable to copy file "obj\Debug\net6.0\EFCoreMigrationWeb.dll" to "bin\Debug\net6.0\EFCoreMigrationWeb.dll". The process cannot access the file 'C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\bin\Debug\net6.0\EFCoreMigrationWeb.dll' because it is being used by another process. [C:\Dev\Delete\EFCoreMigrationPOC\Todo.EFCore\EFCoreMigrationWeb.csproj]
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args)
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Build failed. Use --verbose to see errors.

sturlath avatar Oct 19 '21 08:10 sturlath

Same ...I tried reverting to the earlier build with no luck. @bricelam mentioned that it's a problem with Omnisharp. (I can run the command from the visual studio command prompt ONLY IF VS CODE IS CLOSED...a little clunky for a conference demo but that's what I'll have to do). Is there an issue filed on the omnisharp end?

Further experiments: DIsabled Omnisharp (C# Extension) in VS COde and reloaded and was able to run the bundle command successfully. As for my demo, I can leave C# disabled and perform all of the tasks. (run efbundle, dotnet run, modify code, add a new migration, bundle again, dotnet run) to show idempotency . Just no intellisense. That will work. Just as long as I remember to enable it again for the next demos! 😆

julielerman avatar Oct 19 '21 13:10 julielerman

~~It is NOW working in VS Code. Not sure if the latest nightly build did the trick, @bricelam (now getting 21519.8) but guessing that's it. 🥇 I ran dotnet ef migrations bundle --force repeatedly and it worked each time. (With C# enabled 😁 )~~

15 minutes later. I closed and opened VS Code and tried again and ....SOB...it's back. sorry about that

julielerman avatar Oct 21 '21 00:10 julielerman

I am facing the same issue with 6.0.0-rtm.21519.8. Here is the log - error MSB3021: Unable to copy file "obj\Debug\net6.0\demo2.dll" to "bin\Debug\net6.0\demo2.dll". The process cannot access the file 'C:\demo2\bin\Debug\net6.0\demo2.dll' because it is being used by another process.

I don't have VS Code is running and C# extension is disabled in VS Code.

anuraj avatar Oct 26 '21 10:10 anuraj

Same here. LockHunter says the file(s) aren't being locked at all however.

image

DanoThom avatar Nov 01 '21 15:11 DanoThom

I ran into this without VS Code or Visual Studio open at all - simply running from CLI (tried windows terminal - powershell/cmd, and cmd standalone).

However, I found an odd workaround that works but it seems to me that it works because of a bug.

If I execute dotnet ef migrations bundle --verbose --configuration Debug (or leave --configuration off, or change to Release) It executes and fails as described:

dotnet build C:\dev\...\MyProject.Web\MyProject.Web.csproj --configuration Debug /verbosity:quiet /nologo
...
dotnet publish --runtime win10-x64 --output C:\Users\me\AppData\Local\Temp\exndyuow.3es\publish --no-self-contained --configuration Debug

However, I noticed that if I run the same command with --configuration Bundle it did this:

dotnet build C:\dev\...\MyProject.Web\MyProject.Web.csproj --configuration Bundle /verbosity:quiet /nologo
...
dotnet publish --runtime win10-x64 --output C:\Users\me\AppData\Local\Temp\m15pxos2.mpo\publish --no-self-contained

Note that the publish call doesn't include the --configuration flag, but the dotnet build does.

It seems that if I set --configuration to Debug or Release it propagates to both the build and publish calls but if I set it to anything else it gets used for the build but not the publish. I believe this to be a bug (I'd assume config would be passed to both commands always), but because of it that means that the 'build' step and 'publish' step are using different working directories.

I'm on

  • .Net SDK 6.0.100
  • Entity Framework .Net Command-line Tools 6.0.0

Edit: I downloaded and installed LockHunter. It DOES say that my dll in the bin folder is locked by dotnet exec ... which happens as a part of the bundle process.

dotnet.exe Process ID: 24084 Command Line: "dotnet" exec --depsfile C:\dev\MyProject\bin\Debug\net6.0\MyProject.deps.json --additionalprobingpath C:\Users\me.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\dev\MyProject\bin\Debug\net6.0\MyProject.runtimeconfig.json C:\Users\me.dotnet\tools.store\dotnet-ef\6.0.0\dotnet-ef\6.0.0\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations bundle --force --assembly C:\dev\MyProject\bin\Debug\net6.0\MyProject.dll --project C:\dev\MyProject\MyProject.csproj --startup-assembly C:\dev\MyProject\bin\Debug\net6.0\MyProject.dll --startup-project C:\dev\MyProject\MyProject.csproj --project-dir C:\dev\MyProject\ --root-namespace MyProject --language C# --framework net6.0 --working-dir C:\dev\MyProject --verbose

mcaden avatar Nov 12 '21 23:11 mcaden

Same with Azure build pipeline and net core 6.0.100 ef tools 6.0.0:

dotnet ef migrations bundle --configuration Release --project MyProject/MyProject.csproj --verbose "C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a_temp\d1b341b4-301f-4550-a431-bc4a38837ef9.cmd"" Using project 'D:\a\1\s\MyProject\MyProject.csproj'. Using startup project 'D:\a\1\s\MyProject\MyProject.csproj'. Writing 'D:\a\1\s\MyProject\obj\MyProject.csproj.EntityFrameworkCore.targets'... dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\VssAdministrator\AppData\Local\Temp\tmpA5E3.tmp /verbosity:quiet /nologo D:\a\1\s\MyProject\MyProject.csproj Writing 'D:\a\1\s\MyProject\obj\MyProject.csproj.EntityFrameworkCore.targets'... dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\VssAdministrator\AppData\Local\Temp\tmpA8A3.tmp;Configuration=Release /verbosity:quiet /nologo D:\a\1\s\MyProject\MyProject.csproj Build started... dotnet build D:\a\1\s\MyProject\MyProject.csproj --configuration Release /verbosity:quiet /nologo D:\a\1\s\MyProject\Startup.cs(36,17): warning SYSLIB0020: 'JsonSerializerOptions.IgnoreNullValues' is obsolete: 'JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.' [D:\a\1\s\MyProject\MyProject.csproj]

Build succeeded.

D:\a\1\s\MyProject\Startup.cs(36,17): warning SYSLIB0020: 'JsonSerializerOptions.IgnoreNullValues' is obsolete: 'JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.' [D:\a\1\s\MyProject\MyProject.csproj] 1 Warning(s) 0 Error(s)

Time Elapsed 00:00:01.92 Build succeeded. dotnet exec --depsfile D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.deps.json --additionalprobingpath C:\Users\VssAdministrator.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" --additionalprobingpath "C:\Program Files (x86)\Microsoft\Xamarin\NuGet" --runtimeconfig D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.runtimeconfig.json C:\Users\VssAdministrator.dotnet\tools.store\dotnet-ef\6.0.0\dotnet-ef\6.0.0\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations bundle --assembly D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll --project D:\a\1\s\MyProject\MyProject.csproj --startup-assembly D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll --startup-project D:\a\1\s\MyProject\MyProject.csproj --project-dir D:\a\1\s\MyProject\ --root-namespace MyProject --language C# --framework net6.0 --configuration Release --nullable --working-dir D:\a\1\s --verbose Using assembly 'MyProject'. Using startup assembly 'MyProject'. Using application base 'D:\a\1\s\MyProject\bin\Release\net6.0'. Using working directory 'D:\a\1\s\MyProject'. Using root namespace 'MyProject'. Using project directory 'D:\a\1\s\MyProject'. Remaining arguments: .

Finding DbContext classes... Finding IDesignTimeDbContextFactory implementations... Finding application service provider in assembly 'MyProject'... Finding Microsoft.Extensions.Hosting service provider... Using environment 'Development'. Using application service provider from Microsoft.Extensions.Hosting. Found DbContext 'MyProjectContext'. Finding DbContext classes in the project... Using context 'MyProjectContext'. Building bundle... dotnet publish --runtime win10-x64 --output C:\Users\VssAdministrator\AppData\Local\Temp\hadixnkm.d3f\publish --no-self-contained --configuration Release Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Copyright (C) Microsoft Corporation. All rights reserved.

Determining projects to restore... Restored D:\a\1\s\MyProject\MyProject.csproj (in 481 ms). Restored C:\Users\VssAdministrator\AppData\Local\Temp\hadixnkm.d3f\efbundle.csproj (in 484 ms). D:\a\1\s\MyProject\Startup.cs(36,17): warning SYSLIB0020: 'JsonSerializerOptions.IgnoreNullValues' is obsolete: 'JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.' [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 2 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 7 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 8 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 9 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): warning MSB3026: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Beginning retry 10 in 1000ms. The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): error MSB3027: Could not copy "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". Exceeded retry count of 10. Failed. [D:\a\1\s\MyProject\MyProject.csproj] C:\hostedtoolcache\windows\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(4635,5): error MSB3021: Unable to copy file "obj\Release\net6.0\MyProject.dll" to "bin\Release\net6.0\MyProject.dll". The process cannot access the file 'D:\a\1\s\MyProject\bin\Release\net6.0\MyProject.dll' because it is being used by another process. [D:\a\1\s\MyProject\MyProject.csproj] Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors. at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args) at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) Build failed. Use --verbose to see errors. ##[error]Cmd.exe exited with code '1'. Finishing: Create migrations bundle

ZeusAFK avatar Nov 16 '21 20:11 ZeusAFK

Also getting this error.

I found that using Lockhunter, i can kill a specific instance of dotnet.exe, and it appears to create the bundle. When the bundle is created, I do end up with an error, but the .exe is still there... I have not tried it yet, so i cannot say if the bundle actually works.

I tried adding the --no-build flag to the ef migrations command, but it still seems to build when creating a bundle.

The process that i can kill to lead to the bundle creation finishing is as follows:

dotnet.exe
  Process ID: 11176
  Command Line: "dotnet" exec --depsfile C:\Users\Jerry\Documents\Github\<project_name_goeshere>.deps.json --additionalprobingpath C:\Users\Jerry\.nuget\packages --runtimeconfig C:\Users\Jerry\Documents\Github\<project_name_goeshere>.runtimeconfig.json C:\Users\Jerry\.dotnet\tools\.store\dotnet-ef\6.0.0\dotnet-ef\6.0.0\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations bundle --assembly C:\Users\Jerry\Documents\Github\<project_name_goeshere>.dll --project C:\Users\Jerry\Documents\Github\<project_name_goeshere>.csproj --startup-assembly C:\Users\Jerry\Documents\Github\<project_name_goeshere>.dll --startup-project C:\Users\Jerry\Documents\Github\<project_name_goeshere>.csproj --project-dir C:\Users\Jerry\Documents\Github\<project_name_goeshere>\ --root-namespace <project_name_goeshere> --language C# --framework net6.0 --configuration Release --working-dir C:\Users\Jerry\Documents\Github\<project_name_goeshere> --verbose

jerryk414 avatar Nov 16 '21 22:11 jerryk414

This appears to be fixed on RC1 with latest version of Visual Studio. I wonder if OmniSharp just needs to catch up too...

@bricelam I recently updated to the latest release of .Net 6 SDK (6.0.100) on Windows 10 Pro. I was NOT getting this error with the 6.0.100-rc.1.21458.32 release.

Note: I have no IDE open, no VS Code or Visual Studio. I'm use only the console and it still gives the error above. Even after a fresh reboot and only the terminal open. So I think it it might be a problem on the dotnet-ef migrations bundle.

ivanmonteiro avatar Nov 17 '21 17:11 ivanmonteiro

Same issue on 6.0.100 with nothing running except the dotnet cli command (using the LockHunter trick I did manage to workaround it but it's not ideal).

guillaume86 avatar Nov 17 '21 21:11 guillaume86

odd, I have been running bundle from CLI in the VS Code powershell terminal, the command terminal and the gitbash terminal (all in VS Code) without issues.

.NET 6.0.100 EF Core 6.0.0-* Pulling from standard nuget (e.g. no nuget.config) project.assests.Json confirms it's EF Core 6.0.0

My VSCode is 1.62.2 C# extension is v1.23.16

julielerman avatar Nov 17 '21 22:11 julielerman

I've been trying to narrow down if it's related to post-build/publish events or things like what is running in Program.cs or Startup.cs (web api project). So far nothing makes a difference. So far the only working around I've found is setting --configuration to something that is not debug or release. Heck, even asdf works.

mcaden avatar Nov 17 '21 22:11 mcaden

+1 that the bug exists and +1 that only the workaround seems to help. Closed IDEs, fresh restart - doesn't help.

MaxCrank avatar Nov 18 '21 17:11 MaxCrank

Any thoughts, @bricelam ??

julielerman avatar Nov 18 '21 17:11 julielerman

It is working property if we close VSCode and again running the command. And working properly in GitHub actions.

anuraj avatar Nov 19 '21 04:11 anuraj

+1 that the bug exists and +1 that only the workaround seems to help. Closed IDEs, fresh restart - doesn't help.

Yes fresh restart and not starting an IDE didn't help either here, trying to think about what's special in my setup...

  • I use Windows 10
  • I use the npgsql provider
  • It's an aspnet core 6.0 project

guillaume86 avatar Nov 19 '21 10:11 guillaume86

I'm still having these issues too.

This is a big deal at this point as it's preventing me from taking any of this forward. No point if I can't get the migration bundles to reliably build on my own machine, let alone a build agent on Azure Devops.

DanoThom avatar Nov 19 '21 11:11 DanoThom

While I hasn't been able to reproduce the problem via vs package manager (due to other issues with vs), I was able to reproduce it via dotnet ef migrations bundle.

The main problem is Microsoft.EntityFrameworkCore.Design.OperationExecutor, which is called from Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand. It loads the main assembly via Assembly.Load into dotnet process, so the main file gets locked on windows (most likely this doesn't happen on linux). Due to that, the child dotnet publish process fails, as the lock is taken by the parent process.

One way this could have been fixed is by using AssemblyLoadContext to load and unload the assemblies (after the executor is disposed) at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor, but since AssemblyLoadContext has been added with net core 3 (and ef tools is compiled against netcoreapp 2.0)...

vonzshik avatar Nov 19 '21 22:11 vonzshik

@bricelam maybe the modernization of the EF tools we mentioned at some point would allow us to use the "new" AssemblyLoadcontext to unload...

roji avatar Nov 19 '21 22:11 roji

... It loads the main assembly via Assembly.Load into dotnet process, so the main file gets locked on windows (most likely this doesn't happen on linux).

Well, to me at least using Github Actions (Windows) I have this problem, but using ubuntu-20-04 as the runner of the Github Action I see no errors and the migration bundle is correctly generated

ivanmonteiro avatar Nov 20 '21 19:11 ivanmonteiro

Same issue with 6.0.100 on Windows, not running VS or VS Code, no other terminal windows open. On macOS I don't get this problem, it works as expected.

matt-goldman avatar Nov 22 '21 00:11 matt-goldman

However, I noticed that if I run the same command with --configuration Bundle it did this:

This is the only workaround that worked for me on Windows (both on Windows 10 and Github Actions with Windows Server 2019 runner):

jobs:
  publish-bundle-windows:
    runs-on: windows-2019
   ...
    steps:
   ...
    - name: Create migrations bundle - windows
      run: dotnet ef migrations bundle --configuration Bundle --project ./src/Myproject/Myproject.csproj --verbose

On linux (ubuntu-20-04) and Docker (linux - alpine) I see no problems and the bundle is correctly generated:

jobs:
  publish-bundle-linux:
    runs-on: ubuntu-latest
   ...
    steps:
   ...
    - name: Create migrations bundle - linux
      run: dotnet ef migrations bundle --project ./src/Myproject/Myproject.csproj --verbose

ivanmonteiro avatar Nov 22 '21 19:11 ivanmonteiro

I'm receiving the same issue on my Azure DevOps pipeline as well as locally.

Updating the command to: dotnet ef migrations bundle -p MyCoolProject.Infrastructure -s MyCoolProject.Api --verbose --configuration github.com.dotnet.efcore.issues.25555 --force

has done the trick nicely! : )

with "--configuration github.com.dotnet.efcore.issues.25555" being the workaround and "--force" being in case any local bundles have been created and need to be overwritten.

jammyzt avatar Dec 17 '21 15:12 jammyzt

Same here. Adding dummy --configuration worked like a charm. So glad I found this thread...

Since this issue seems to be affecting everyone (?), should it be mentioned as a known issue in the doc?

dennis-yemelyanov avatar Jan 08 '22 05:01 dennis-yemelyanov

Upgrading to 6.0.1 didn't solve the problem,

This is the only workaround (tested on win 10 & 11): dotnet ef migrations bundle --configuration Bundle --project ./src/Myproject/Myproject.csproj --verbose

Important: The above workaround doesn’t work when option —no-build is set

moalamri avatar Jan 26 '22 04:01 moalamri