Skip to content
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

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

Open
bricelam opened this issue Aug 17, 2021 · 82 comments
Labels
area-migrations consider-for-next-release customer-reported punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Milestone

Comments

@bricelam
Copy link
Contributor

bricelam commented Aug 17, 2021

Originally reported by @ryanrichard19 in #19693 (comment)

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.
@ajcvickers
Copy link
Member

Note from triage: consider removing.

@karl-sjogren
Copy link

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>

@bricelam
Copy link
Contributor Author

bricelam commented Sep 14, 2021

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

@bricelam bricelam removed this from the 6.0.0 milestone Sep 14, 2021
@AndriySvyryd AndriySvyryd added this to the 6.0.0 milestone Sep 15, 2021
@bricelam bricelam modified the milestones: 6.0.0, Backlog Sep 24, 2021
@ptffr
Copy link

ptffr commented Oct 13, 2021

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

@julielerman
Copy link

julielerman commented Oct 18, 2021

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??

@sturlath
Copy link

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.

@julielerman
Copy link

julielerman commented Oct 19, 2021

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! 😆

@bricelam bricelam removed this from the Backlog milestone Oct 19, 2021
@julielerman
Copy link

julielerman commented Oct 21, 2021

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

@ajcvickers ajcvickers added this to the Backlog milestone Oct 23, 2021
@anuraj
Copy link

anuraj commented Oct 26, 2021

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.

@DanoThom
Copy link

DanoThom commented Nov 1, 2021

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

image

@MoishyS
Copy link

MoishyS commented Jul 20, 2023

--configuration Bundle workaround does not work for me, i am using 7.0.9

@Chadwuo
Copy link

Chadwuo commented Aug 15, 2023

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

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 and when the dotnet process was showing this warning I unlocked the process and it finished creating the bundle.EFCoreMigrationWeb.dll

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.

阿甘,你TM真是个天才

@alraseensaad
Copy link

alraseensaad commented Aug 25, 2023

for me the errors appear when I add and configure Nerdbank.GitVersioning to the solution
I remove the PackageReference of Nerdbank.GitVersioning in Directory.Build.props file and it's work fine

@dmi-harlow
Copy link

--configuration Bundle

I was having this issue for an Azure Pipelines build using a self-hosted agent. Adding '--configuration Bundle' made the problem go away.

@rafalkwol
Copy link

rafalkwol commented Oct 29, 2023

I have encountered this issue and described it in #1261. I was investigating it a bit and I think it can be pretty quickly fixed (if there is no time for a "real" fix) by allowing us to pass the new dotnet build & publish property "--disable-build-servers". It is not the perfect fix, but it would cause the build step to close all the dotnet.exe processes it's starting when building the projects before the publish step happens. It would be a way to make it work for those who don't mind invalidating the build cache.

@ajcvickers ajcvickers removed this from the Backlog milestone Nov 2, 2023
@ajcvickers
Copy link
Member

Note for triage: we should consider the --disable-build-servers approach.

@plillevold
Copy link

not given the proper attention

This is going to require some architectural changes to the way our tools work to fix properly. We hope to address this in 7.0 as part of #26798

Given severity of the issue (i.e. the feature does NOT work for most of the people) can it be addressed sooner (in v6.0.x)?

This was saddening news. I came here experiencing this issue in our CI build in Azure DevOps Pipelines, using v6.0.25. No time soon are we able to upgrade to 7 in order to work around this issue.

Adding my vote for getting a fix backported to v6.0.x.

@ctolkien
Copy link

ctolkien commented Dec 5, 2023

This was saddening news. I came here experiencing this issue in our CI build in Azure DevOps Pipelines, using v6.0.25. No time soon are we able to upgrade to 7 in order to work around this issue.

It's not fixed in 7 (or 8) anyway.

@plillevold
Copy link

plillevold commented Dec 5, 2023

This was saddening news. I came here experiencing this issue in our CI build in Azure DevOps Pipelines, using v6.0.25. No time soon are we able to upgrade to 7 in order to work around this issue.

It's not fixed in 7 (or 8) anyway.

Yeah, I tested with the 7.0 version of dotnet-ef tools and the issue persist. I presume the 7 and 8 versions are mere version bumps of the existing 6.0 tools.

That said, I did actually manage to get the 6.0.25 version to work in Azure DevOps Pipelines, which is great! I'm not 100% sure how, which is not so great :|

This is my build command, and the main difference is that I use an absolute path to the project file, while previously it was relative to the current working folder.

migrations bundle --output $(Build.ArtifactStagingDirectory)\Migrations\migrate-seed.exe --project $(Build.SourcesDirectory)\src\Data.Migrations --verbose --force

Note also that I did not use the "--configuration Bundle" trick, as this did not help for me at all.

ajcvickers added a commit that referenced this issue Jan 6, 2024
Attempt to help with #25555.

Note that this code is in `dotnet-ef`, so a new tool version is needed to get this change.

Tested with locally built tool package and didn't see any issues.
ajcvickers added a commit that referenced this issue Jan 10, 2024
Attempt to help with #25555.

Note that this code is in `dotnet-ef`, so a new tool version is needed to get this change.

Tested with locally built tool package and didn't see any issues.
@jasekiw
Copy link

jasekiw commented Feb 13, 2024

@ajcvickers What is the status of this fix considering #32737 has been merged? Has that been released to the public yet?

@ajcvickers
Copy link
Member

@jasekiw I'd be extremely surprised, but very happy, if #32737 fully fixed this. It will be included in 9.0 preview 1, but you should be able to try it now with the daily builds.

@ChrisPeacock1
Copy link

#32737 Doesn't fix the issue for me. This is going to prevent us from upgrading our projects, which build fine in .Net 6, to .Net 8.

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 8, 2024

@ChrisPeacock1 Are you using the daily tool build?

@baronfel
Copy link
Member

baronfel commented Mar 8, 2024

Hey folks - we (SDK and Roslyn teams) very very very strongly recommend against using the --disable-build-servers argument. Any use of that flag will result in much longer (like 10x) build times due to Roslyn not being able to reuse its internal caches. Our teams have a kind of side-mission of finding and removing any usage of this flag because it's such an anti-pattern.

We'd love to work with the EF team to help diagnose why these errors are seen during the bundle generation, as well as work towards a solution that doesn't use --disable-build-servers. The first step in any resolution would be to gather binlogs for the publish that is happening under the covers. From there we can actually see what's going wrong in the build and fix the underlying issue that led to the addition of --disable-build-servers.

cc @jaredpar

@ChrisPeacock1
Copy link

@ChrisPeacock1 Are you using the daily tool build?

Yes, I am.

@pantonis
Copy link

what is the workaround for this until it is fixed in the very far feature?

@jasekiw
Copy link

jasekiw commented May 2, 2024

@pantonis

We followed the workaround here by adding
<NoDefaultLaunchSettingsFile Condition=" '$(Configuration)' == 'Bundle' ">true</NoDefaultLaunchSettingsFile> to the migrations .csproj file and used --configuration Bundle when running the bundle command.

dotnet ef migrations bundle --configuration Bundle

@ChrisPeacock1
Copy link

ChrisPeacock1 commented Nov 5, 2024

The workaround in the above didn't work for me, but what does work is removing the runtime (e.g. win-x64) option from the bundle command, and also from any project files, along with the self-contained option. I.e. remove these:

<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

The bundle does some extra file copying at the end where a Windows runtime is specified, and it's during this that the locked file cannot be moved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations consider-for-next-release customer-reported punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Projects
None yet
Development

No branches or pull requests