On Azure Pipelines hosted windows-2019 agent, building a newly created solution in docker will result in Access to the path 'C:\app\obj\testmodule.csproj.nuget.dgspec.json' is denied.
error. This may be a regression of issue https://github.com/NuGet/Home/issues/7836
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): dotnet.exe
NuGet version (x.x.x.xxx): 5.3.0.4
dotnet.exe --version (if appropriate): 3.0.100 (on build agent). The docker image uses image microsoft/dotnet:2.1-sdk
to build solution.
VS version (if appropriate): Not using VS.
OS version (i.e. win10 v1607 (14393.321)): windows 1809
Worked before? If so, with which NuGet version: Worked before, but I couldn't get previous runtime information.
Create a new build definition in Azure Pipelines. Select hosted agent windows-2019
to run the build.
Add following powershell task
steps:
- powershell: |
dotnet new -i Microsoft.Azure.IoT.Edge.Module
dotnet new aziotedgemodule -n testmodule -r localhost:5000/testmodule
cd testmodule
docker build --rm -f "./Dockerfile.windows-amd64" -t localhost:5000/testmodule:0.0.1-windows-amd64 .
displayName: 'PowerShell Script'
Actual behavior:
The docker build command failed with error Access to the path 'C:\app\obj\testmodule.csproj.nuget.dgspec.json' is denied.
Expected behavior:
The build finished successfully
...
Run the dotnet new commands in repro steps and you can get the sample solution.
Any updates on this? Seeing this with mcr.microsoft.com/dotnet/core/sdk:3.1
, with a simple Dockerfile (create an app folder locally with a sample dotnet project):
#escape=`
FROM mcr.microsoft.com/dotnet/core/sdk:3.1
ADD app ./app
RUN dotnet build ./app
Output:
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files\dotnet\sdk\3.1.101\NuGet.targets(123,5): error : Access to the path 'C:\app\obj\testharness.csproj.nuget.dgspec.json' is denied. [C:\app\testharness.csproj]
Build FAILED.
C:\Program Files\dotnet\sdk\3.1.101\NuGet.targets(123,5): error : Access to the path 'C:\app\obj\testharness.csproj.nuget.dgspec.json' is denied. [C:\app\testharness.csproj]
0 Warning(s)
1 Error(s)
Ping @onovotny @dominoFire
This was a result of me copying over existing obj/bin folders, from a local build. Added a .dockerignore
to ignore those folders. Experience could be improved here.
Hey @blackchoey
Thank you filing this issue.
As @riverar suggested, this is a consequence of the permissions model in docker.
We'd recommend ensuring that the obj/bin folders are not copied over in the image.
Most helpful comment
This was a result of me copying over existing obj/bin folders, from a local build. Added a
.dockerignore
to ignore those folders. Experience could be improved here.