I stumbled upon this challenge:
My team was using a Windows VM to act as a Jenkins Agent to build and deploy .NET apps
It works like a charm.
However, I would like to be 100% on Containers, so we decided to embark on the journey of dockerizing this VM.
Using as baseline jenkins/ssh-agent:windowsservercore-ltsc2022-jdk21 we extended that OOTB image by adding the required software installed on the VM:
- Nuget 6.10
- Visual Studio 2019 Build Tools
- Visual Studio 2019 Test Agent
- .NET Framework Developer Pack version 4.5.1 - 4.6.2
- MSDeploy (webdeploy)
The main challenge we faced was to copy/paste some files into
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VisualStudio\v16.0
We kept on getting nasty errors like these each time we referenced that folder:
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:40 + Get-ChildItem -Path C:\`Program Files (x86)\`Microsoft Visual Studio\ ... + ~~~ + CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFound Exception + FullyQualifiedErrorId : CommandNotFoundException
Our solution was switching the Work Directory and we never looked back (or had to reference such folder)
WORKDIR C:\\'Program Files (x86)'\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Microsoft\\VisualStudio\\v16.0
And that's how you work around that nasty error.