MicrosoftDocs / mslearn-dotnet-cloudnative

Sample apps for the Microsoft Learn modules for creating cloud native apps with ASP.NET Core
MIT License
44 stars 624 forks source link

Access to the path is denied. [C:\Projects\.....dotnet-kubernetes\Products\Products.csproj] #14

Open eliassal opened 3 months ago

eliassal commented 3 months ago

After following instructions up to step 2 dotnet publish /p:PublishProfile=DefaultContainer

Building the product image errored as follows

Building image 'products' with tags 'latest' on top of base image 'mcr.microsoft.com/dotnet/aspnet:8.0'. C:\Program Files\dotnet\sdk\8.0.106\Containers\build\Microsoft.NET.Build.Containers.targets(202,5): error MSB4018: The "CreateNewImage" task failed unexpectedly. [C:\Projects\AzureDevOpsProjects\MSLearn\mslear n-dotnet-cloudnative\dotnet-kubernetes\Products\Products.csproj] C:\Program Files\dotnet\sdk\8.0.106\Containers\build\Microsoft.NET.Build.Containers.targets(202,5): error MSB4018: System.UnauthorizedAccessException: Access to the path is denied. [C:\Projects\AzureDevOpsProj ects\MSLearn\mslearn-dotnet-cloudnative\dotnet-kubernetes\Products\Products.csproj]

whereas store image was build correctly. Why is this and what is needed to be done? Thanks image

jamesmontemagno commented 3 months ago

are you running this locally on your machine or in a github codespace?

jamesmontemagno commented 3 months ago

It built up locally here fine for me locally. Are you able to update to the latest .NET SDK: https://dotnet.microsoft.com/en-us/download looks like you are on an older one.

eliassal commented 3 months ago

Hi, I a running eberything locally. Dear @jamesmontemagno I have latest .Net SDK

image

I tried both dotnet docker and kubernetes, both have issues with the product image

jamesmontemagno commented 3 months ago

8.0.300 is the latest sdk if you can try that.. https://dotnet.microsoft.com/en-us/download

Let me also ping @baronfel if he has any idea

baronfel commented 3 months ago

My guess is a timing issue here - when you run dotnet publish at the solution level you end up containerizing both projects at the same time. This means that each project is doing the following in parallel:

this second step involves downloading files from your container registry and storing them locally in your system, but if both projects use the same base image (probably dotnet/aspnet?) this can lead to a race condition where only the first one finished downloading can successfully copy. My guess is that if you ran the publish again both would succeed because you would have already downloaded all the images. Does this match the behavior you see? We have an issue tracking fixing this at https://github.com/dotnet/sdk-container-builds/issues/344.