Error MSB4184 Microsoft.LightSwitch.Publish.targets when Building project using Team Foundation Build

481 views Asked by At

Company I work to need to implement continous integration. Projects are developed by using Lightswitch with visual studio 2012. We use Team Foundation Server to manage source version. I created a build definition and agent pool to try to run build processes programatically using MsBuild task into TFS.

Everything goes fine except Build Solution step throws an error. Following is the trace:

2016-08-08T17:30:17.1606552Z Checking if artifacts directory exists: C:\TFSAgent\_work\1\a
2016-08-08T17:30:17.1606552Z Deleting artifacts directory.
2016-08-08T17:30:17.1606552Z Creating artifacts directory.
2016-08-08T17:30:17.1762560Z Checking if test results directory exists: C:\TFSAgent\_work\1\TestResults
2016-08-08T17:30:17.1762560Z Deleting test results directory.
2016-08-08T17:30:17.1762560Z Creating test results directory.
2016-08-08T17:30:17.2230568Z Starting: Get sources
2016-08-08T17:30:17.2386617Z Entering TfvcSourceProvider.PrepareRepositoryAsync
2016-08-08T17:30:17.2386617Z localPath=C:\TFSAgent\_work\1\s
2016-08-08T17:30:17.2386617Z clean=False
2016-08-08T17:30:17.2386617Z sourceVersion=199
2016-08-08T17:30:17.2386617Z mappingJson={"mappings":[{"serverPath":"$/OmniPay","mappingType":"map","localPath":"\\"},{"serverPath":"$/OmniPay/Drops","mappingType":"cloak","localPath":"\\"}]}
2016-08-08T17:30:17.2386617Z Syncing repository: OmniPay (TFVC)
2016-08-08T17:30:17.2386617Z workspaceName=ws_1_3
2016-08-08T17:30:21.4039019Z Workspace Name: ws_1_3;45d6157a-c0a3-480c-9615-310b82a07e0e
2016-08-08T17:30:21.5130997Z tf get /version:199
2016-08-08T17:30:22.6987201Z Done syncing repository OmniPay to version 199 (workspace version C199)
2016-08-08T17:30:22.6987201Z Leaving TfvcSourceProvider.PrepareRepositoryAsync
2016-08-08T17:30:22.9015180Z Running tasks
2016-08-08T17:30:22.9327171Z Starting task: Build solution $/OmniPay/0-Development/OmniMerchant/OmniMerchant.sln
2016-08-08T17:30:22.9951206Z C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; $env:TF_BUILD = 'True' ; Import-Module -Name 'C:\TFSAgent\tasks\VSBuild\1.0.37\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList @{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'SilentlyContinue' ; $DebugPreference = 'SilentlyContinue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''C:\TFSAgent\tasks\VSBuild\1.0.37\VSBuild.ps1'''))"
2016-08-08T17:30:24.8203363Z ##[warning]Visual Studio version '11.0' not found. Looking for the latest version.
2016-08-08T17:30:25.1947427Z ##[command]"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.sln" /nologo /nr:false /fl /flp:"logfile=C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.sln.log" /dl:CentralLogger,"C:\TFSAgent\tasks\VSBuild\1.0.37\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"C:\TFSAgent\tasks\VSBuild\1.0.37\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"  /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="10.0"
2016-08-08T17:30:25.3195436Z Los proyectos de esta solución se van a compilar de uno en uno. Para habilitar la compilación en paralelo, agregue el modificador "/m".
2016-08-08T17:30:25.3351434Z Compilación iniciada a las 08/08/2016 12:30:25 p. m..
2016-08-08T17:30:25.5223466Z Proyecto "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.sln" en nodo 1 (destinos predeterminados).
2016-08-08T17:30:25.5223466Z ValidateSolutionConfiguration:
2016-08-08T17:30:25.5223466Z   Compilando la configuración de soluciones "release|any cpu".
2016-08-08T17:30:25.7719622Z ##[error]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Publish\v1.8\Microsoft.LightSwitch.Publish.targets(31,9): Error MSB4184: La expresión "[System.IO.Path]::Combine(null, bin\x86)" no se puede evaluar. El valor no puede ser nulo. Nombre del parámetro: path1
2016-08-08T17:30:25.7719622Z El proyecto "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.sln" (1) está compilando "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.ls3proj" (2) en el nodo 1 (destinos predeterminados).
2016-08-08T17:30:25.7719622Z C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Publish\v1.8\Microsoft.LightSwitch.Publish.targets(31,9): error MSB4184: La expresión "[System.IO.Path]::Combine(null, bin\x86)" no se puede evaluar. El valor no puede ser nulo. Nombre del parámetro: path1 [C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.ls3proj]
2016-08-08T17:30:25.8031476Z Compilación del proyecto terminada "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.ls3proj" (destinos predeterminados) -- ERROR.
2016-08-08T17:30:25.8499500Z Compilación del proyecto terminada "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.sln" (destinos predeterminados) -- ERROR.
2016-08-08T17:30:25.8499500Z ERROR al compilar.
2016-08-08T17:30:25.8499500Z "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.sln" (destino predeterminado) (1) ->
2016-08-08T17:30:25.8499500Z "C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.ls3proj" (destino predeterminado) (2) ->
2016-08-08T17:30:25.8499500Z   C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Publish\v1.8\Microsoft.LightSwitch.Publish.targets(31,9): error MSB4184: La expresión "[System.IO.Path]::Combine(null, bin\x86)" no se puede evaluar. El valor no puede ser nulo. Nombre del parámetro: path1 [C:\TFSAgent\_work\1\s\0-Development\OmniMerchant\OmniMerchant.ls3proj]
2016-08-08T17:30:25.8499500Z     0 Advertencia(s)
2016-08-08T17:30:25.8499500Z     1 Errores
2016-08-08T17:30:25.8499500Z Tiempo transcurrido 00:00:00.29
2016-08-08T17:30:26.0371525Z ##[error]Process 'msbuild.exe' exited with code '1'.
2016-08-08T17:30:26.1307517Z Finishing task: VSBuild
2016-08-08T17:30:26.1307517Z Starting task: Copy Files to: $(build.artifactstagingdirectory)
2016-08-08T17:30:26.1463517Z Set workingFolder to default: C:\TFSAgent\tasks\CopyFiles\1.0.20
2016-08-08T17:30:26.4583580Z ##[debug]agent.workFolder=C:\TFSAgent\_work
2016-08-08T17:30:26.4583580Z ##[debug]loading inputs and endpoints
2016-08-08T17:30:26.4583580Z ##[debug]loading ENDPOINT_AUTH_$/
2016-08-08T17:30:26.4583580Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
2016-08-08T17:30:26.4583580Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2016-08-08T17:30:26.4583580Z ##[debug]loading ENDPOINT_AUTH_SCHEME_$/
2016-08-08T17:30:26.4583580Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2016-08-08T17:30:26.4583580Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2016-08-08T17:30:26.4583580Z ##[debug]loading INPUT_CLEANTARGETFOLDER
2016-08-08T17:30:26.4583580Z ##[debug]loading INPUT_CONTENTS
2016-08-08T17:30:26.4583580Z ##[debug]loading INPUT_OVERWRITE
2016-08-08T17:30:26.4583580Z ##[debug]loading INPUT_SOURCEFOLDER
2016-08-08T17:30:26.4583580Z ##[debug]loading INPUT_TARGETFOLDER
2016-08-08T17:30:26.4583580Z ##[debug]loaded 11
2016-08-08T17:30:26.4583580Z ##[debug]check path : C:\TFSAgent\tasks\CopyFiles\1.0.20\task.json
2016-08-08T17:30:26.4583580Z ##[debug]set resource file to: C:\TFSAgent\tasks\CopyFiles\1.0.20\task.json
2016-08-08T17:30:26.4739560Z ##[debug]system.culture=en-US
2016-08-08T17:30:26.4739560Z ##[debug]Contents=**\bin\release\**
2016-08-08T17:30:26.4739560Z ##[debug]SourceFolder=C:\TFSAgent\_work\1\s
2016-08-08T17:30:26.4739560Z ##[debug]check path : C:\TFSAgent\_work\1\s
2016-08-08T17:30:26.4739560Z ##[debug]TargetFolder=C:\TFSAgent\_work\1\a
2016-08-08T17:30:26.4739560Z ##[debug]CleanTargetFolder=false
2016-08-08T17:30:26.4739560Z ##[debug]OverWrite=false
2016-08-08T17:30:26.4739560Z ##[debug]include content pattern: **\bin\release\**
2016-08-08T17:30:26.7547577Z ##[debug]find C:\TFSAgent\_work\1\s
2016-08-08T17:30:26.7547577Z ##[debug]2219 matches.
2016-08-08T17:30:26.8795588Z ##[debug]allFiles contains 2012 files
2016-08-08T17:30:26.8795588Z ##[debug]Include matching C:\TFSAgent\_work\1\s\**\bin\release\**
2016-08-08T17:30:26.9107601Z ##[debug]Include matched 0 files
2016-08-08T17:30:26.9107601Z found 0 files
2016-08-08T17:30:26.9263593Z Finishing task: CopyFiles
2016-08-08T17:30:26.9419655Z Starting task: Publish Artifact: drop
2016-08-08T17:30:26.9419655Z Set workingFolder to default: C:\TFSAgent\tasks\PublishBuildArtifacts\1.0.34
2016-08-08T17:30:27.2383627Z ##[debug]agent.workFolder=C:\TFSAgent\_work
2016-08-08T17:30:27.2383627Z ##[debug]loading inputs and endpoints
2016-08-08T17:30:27.2383627Z ##[debug]loading ENDPOINT_AUTH_$/
2016-08-08T17:30:27.2383627Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
2016-08-08T17:30:27.2539635Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2016-08-08T17:30:27.2539635Z ##[debug]loading ENDPOINT_AUTH_SCHEME_$/
2016-08-08T17:30:27.2539635Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2016-08-08T17:30:27.2539635Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2016-08-08T17:30:27.2539635Z ##[debug]loading INPUT_ARTIFACTNAME
2016-08-08T17:30:27.2539635Z ##[debug]loading INPUT_ARTIFACTTYPE
2016-08-08T17:30:27.2539635Z ##[debug]loading INPUT_PATHTOPUBLISH
2016-08-08T17:30:27.2539635Z ##[debug]loading INPUT_TARGETPATH
2016-08-08T17:30:27.2539635Z ##[debug]loaded 10
2016-08-08T17:30:27.2539635Z ##[debug]check path : C:\TFSAgent\tasks\PublishBuildArtifacts\1.0.34\task.json
2016-08-08T17:30:27.2539635Z ##[debug]set resource file to: C:\TFSAgent\tasks\PublishBuildArtifacts\1.0.34\task.json
2016-08-08T17:30:27.2539635Z ##[debug]system.culture=en-US
2016-08-08T17:30:27.2539635Z ##[debug]PathtoPublish=C:\TFSAgent\_work\1\a
2016-08-08T17:30:27.2539635Z ##[debug]check path : C:\TFSAgent\_work\1\a
2016-08-08T17:30:27.2539635Z ##[debug]ArtifactName=drop
2016-08-08T17:30:27.2539635Z ##[debug]ArtifactType=Container
2016-08-08T17:30:27.2695627Z ##[debug]TargetPath=\\my\share\Merchant\20160808.4
2016-08-08T17:30:28.6267793Z Max Concurrent Uploads 2, Max Creators 1
2016-08-08T17:30:28.7048085Z Found 0 files to upload.
2016-08-08T17:30:28.7203860Z Created 0 files without uploading content. Total files processed 0
2016-08-08T17:30:28.7203860Z Uploaded artifact 'C:\TFSAgent\_work\1\a' to container folder 'drop' of build 24.
2016-08-08T17:30:29.6719971Z Associated artifact 12 with build 24
2016-08-08T17:30:29.6875965Z Finishing task: PublishBuildArtifacts
2016-08-08T17:30:29.7032002Z ##[error]System.Exception: Task VSBuild failed. This caused the job to fail. Look at the logs for the task for more details.
2016-08-08T17:30:29.7032002Z ##[error]   en Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource)

Error in line 29 is as follows:

2016-08-08T17:30:25.7719622Z ##[error]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Publish\v1.8\Microsoft.LightSwitch.Publish.targets(31,9): Error MSB4184: La expresión "[System.IO.Path]::Combine(null, bin\x86)" no se puede evaluar. El valor no puede ser nulo. Nombre del parámetro: path1

In English means: Error MSB4184: "[System.IO.Path]::Combine(null, bin\x86)" Expression cannot be evaluated. Value cannot be null. Parameter name: path1

Going deep into Microsoft.LightSwitch.Publish.Targets line 39:

<!--If the path to the sign tool is not set, try the Windows SDK path or the Framework SDK path -->
<_WindowsSDKSignToolPath  Condition="'$(SignToolPath)' == ''">$([System.IO.Path]::Combine('$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot', null, RegistryView.Registry32, RegistryView.Default))', 'bin\x86'))</_WindowsSDKSignToolPath>

Compiling project by using Visual Studio 2012 works perfect, however error throws TFS Build refers to OmniMerchant.ls3proj in line:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.targets" />

I created HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots and KitsRoot key in server, also I copied all folders and files Microsoft\VisualStudio\LightSwitch into server based on developer machine, but errors still is showing. Please, need helps! thanks

1

There are 1 answers

0
Aldemar Cuartas Carvajal On

I've found answer, thanks to Patrick-MSFT which helped me a lot.

Many of the errors were caused by missing correctly framework version and also by missing solution dependencies.

TFS's Building Agent searchs for MSBuild according Visual Studio's projects configured in Build Definitions or else for latest version. The absence of the correct version installed on build server made MSBuild searched for latest installed versión and therefore executed following line from Microsoft.LightSwitch.Publish.Targets:

<_WindowsSDKSignToolPath  Condition="'$(SignToolPath)' == ''">$([System.IO.Path]::Combine('$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot', null, RegistryView.Registry32, RegistryView.Default))', 'bin\x86'))</_WindowsSDKSignToolPath>

That triggered errors and the correct way to overcome that was doing following:

According to Patrick-MSFT I've installed Visual Studio 2012 plus updates, and all tools necessary same as my developing PC into TFS Build server.

Besides of it, it were necessary to put all projects dependency assemblies (DLL) not checked-in to TFS.

Now my builds are green!!