Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

tye run --watch has locking issues with project used multiple times, and replicas #580

Closed
JamesNK opened this issue Jul 14, 2020 · 1 comment · Fixed by #1189
Closed
Labels
bug Something isn't working

Comments

@JamesNK
Copy link
Member

JamesNK commented Jul 14, 2020

Example tye.yaml:

name: microservice
services:
- name: frontend
  project: frontend/frontend.csproj
- name: backend-1
  project: backend/backend.csproj
- name: backend-2
  project: backend/backend.csproj

Starting projects with tye run --watch succeeds, but when a file changes in the backend project the build fails with locking issues:

[11:09:50 INF] Building projects failed with exit code 1:
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018: The "CreateAppHost" task failed unexpectedly. [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018: System.AggregateException: One or more errors occurred. (800703EE) (The process cannot access the file 'C:\Development\Temp\microservice\backend\obj\Debug\netcoreapp3.1\backend.exe' because it is being used by another process.) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:  ---> Microsoft.NET.HostModel.HResultException: 800703EE [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.HostModel.ResourceUpdater.ThrowExceptionForLastWin32Error() [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.<>c__DisplayClass2_0.<CreateAppHost>g__UpdateResources|1() [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.HostModel.RetryUtil.RetryOnWin32Error(Action func) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    --- End of inner exception stack trace --- [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore() [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:  ---> (Inner Exception #1) System.IO.IOException: The process cannot access the file 'C:\Development\Temp\microservice\backend\obj\Debug\netcoreapp3.1\backend.exe' because it is being used by another process. [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at System.IO.FileSystem.DeleteFile(String fullPath) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at System.IO.File.Delete(String path) [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom)<--- [C:\Development\Temp\microservice\backend\backend.csproj]
C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(424,5): error MSB4018:  [C:\Development\Temp\microservice\backend\backend.csproj]

Build FAILED.

This is also a problem when there is a single project configured with multiple replicas.

@JamesNK JamesNK added the bug Something isn't working label Jul 14, 2020
@jkotalik jkotalik added this to the 0.4 milestone Jul 15, 2020
@JunTaoLuo JunTaoLuo self-assigned this Jul 16, 2020
@jkotalik
Copy link
Contributor

I looked into this briefly as well. I think an approach could be to create a mapping from replica or service name to the csproj file and have a corresponding lock with it. Once watch triggers, whoever acquires the lock first runs dotnet build, while the other project waits on the lock. You'd need some sort of dirty/built flag as well to make sure you don't trigger multiple builds for each change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
4 participants