question

hishobhit82 avatar image
0 Votes"
hishobhit82 asked TianyuSun-MSFT commented

jenkins pipeline docker is unable to delete msbuild obj binaries on build agent

I am trying to build my .net framework 4.7.2 project (a WCF and WPF application) using jenkins pipeline using docker image (mcr.microsoft.com/dotnet/framework/sdk:4.8-20220215-windowsservercore-ltsc2019) on my machine. This is a POC BTW.

The msbuild command is failing with the below error, I have tried to find solutions over the internet but the solutions I found aren't working for me. :-

"C:\ProgramData\Jenkins\.jenkins\workspace\MyLocalServicePipeline\MyLocalService.sln" (Rebuild target) (1) ->
"C:\ProgramData\Jenkins\.jenkins\workspace\MyLocalServicePipeline\MyWPFApp\MyWPFApp.csproj" (Rebuild target) (8) ->
(CleanupTemporaryTargetAssembly target) -> 
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(480,10): error MSB3061:
 Unable to delete file "obj\x64\Release\MyWPFApp.exe". 
Access to the path 'C:\ProgramData\Jenkins\.jenkins\workspace\MyLocalServicePipeline\MyWPFApp\obj\x64\Release\MyWPFApp.exe' is denied.
[C:\ProgramData\Jenkins\.jenkins\workspace\MyLocalServicePipeline\MyWPFApp\MyWPFApp.csproj]

    0 Warning(s)
    1 Error(s)


jenkins pipeline code is as below :-

pipeline {
    agent {
        docker 
        { 
            image 'mcr.microsoft.com/dotnet/framework/sdk:4.8-20220215-windowsservercore-ltsc2019'
        }
    } 
    stages {
        stage('Checkout') {
            steps {
                git url: 'https://lasnab82@bitbucket.org/lasnab82/mylocalservice.git'
            }
        }
        stage('NugetRestore') {
            steps {
                bat 'nuget restore "%WORKSPACE%\\MyLocalService.sln"'
            }
        }  
        stage('Build') {
            steps {
                bat '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe" "%WORKSPACE%\\MyLocalService.sln" /t:"Clean" /p:Configuration=Release /p:Platform="x64"'
                bat '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe" "%WORKSPACE%\\MyLocalService.sln" /t:"Rebuild" /p:Configuration=Release /p:Platform="x64"'
            }
        }
    }
}


Logically, I think whats going wrong here is that the jenkins docker container agent may not have delete access to delete files which are actually checked out on my machine in jenkins workspace but I dont know how to resolve this access issue on my setup of jenkins.

Appreciate your help.

Thanks!

dotnet-runtimevs-msbuild
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @hishobhit82 ,

Welcome to Microsoft Q&A forum.

I agree with you, the error prompted from MSBuild is clear, the access to the path … is denied. You need to check and give full permission to this path. I suggest you ask this question on Jenkins Community and Developer Community – Azure DevOps.

Regards,
Tianyu

0 Votes 0 ·

hi, thanks for your reply but it does not look like a persmission issue because when I removed the WPF project from the solution then the build seems to be going through. It is only giving error for .exe files present in the /obj/*.exe dir.

Could you please help understand why is that the case ?

0 Votes 0 ·

Hi @hishobhit82 , if you test with a newly created WPF project, will the path still cannot be accessed?

0 Votes 0 ·

0 Answers