Skip to content

Docker Container Build : (Cleanup Temporary Target Assembly target) -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(480,10): error MSB3061: Unable to delete file obj\x86\Release\. Access to the path is denied #7851

@MVAnand

Description

@MVAnand

I have a solution targetting .netframework 3.5 and getting build in VS2019.

I am able to build the solution using msbuild. Now days I am trying to create a image to build project successfully inside the container.

My DockerFile looks like as given below:

Copy

escape=`

Use a specific tagged image. Tags can be changed, though that is unlikely for most images.

You could also use the immutable tag @sha256:324e9ab7262331ebb16a4100d0fb1cfb804395a766e3bb1806c62989d1fc1326

ARG FROM_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2019
FROM ${FROM_IMAGE}

Restore the default Windows shell for correct batch processing.

SHELL ["cmd", "/S", "/C"]

COPY ["Component Factory", "C:\Program Files (x86)\Component Factory\"]

Install .NET Fx 3.5

RUN curl -fSLo microsoft-windows-netfx3.zip https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft-windows-netfx3-1809.zip && tar -zxf microsoft-windows-netfx3.zip
&& del /F /Q microsoft-windows-netfx3.zip && DISM /Online /Quiet /Add-Package /PackagePath:.\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab
&& del microsoft-windows-netfx3-ondemand-package31bf3856ad364e35amd64~~.cab `
&& powershell Remove-Item -Force -Recurse ${Env:TEMP}*

Copy our Install script.

COPY Install.cmd C:\TEMP\

Download collect.exe in case of an install failure.

ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe

Use the latest release channel. For more control, specify the location of an internal layout.

ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman

RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe
&& (call C:\TEMP\Install.cmd vs_buildtools.exe --quiet --wait --norestart --nocache install
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" --channelUri C:\TEMP\VisualStudio.chman
--installChannelUri C:\TEMP\VisualStudio.chman --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools;includeRecommended;includeOptional
--add Microsoft.VisualStudio.Workload.VCTools;includeRecommended --add Microsoft.Component.MSBuild
--add Microsoft.VisualStudio.Component.VC.CoreBuildTools --add Microsoft.VisualStudio.Component.VC.ATLMFC
--add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
--add Microsoft.VisualStudio.Component.VC.ATL)
# Cleanup
&& del /q vs_buildtools.exe

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR /src

ENTRYPOINT ["C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

But build is getting failed saying

(CleanupTemporaryTargetAssembly target) ->
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(480,10): error MSB3061: Unable to delete file "obj\x86\Release\TestA.dll". Access to the path 'C:\src\Repo\TestProject\obj\x86\Release
\TestA.dll' is denied. [C:\src\Repo\TestProject\TestA.csproj]

I tried to delete within container also, its not allowed. There have been discussion around the similar problem but couldn't get concrete root cause and solution. Specially when I am able to build it using outside the container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions