Currently I am working on a big legacy project where each c# project file has a copy job (with a custom tool written in C#) in the post build event.
The post build event looks like
"$(MyEnvVar)\_Build\_Binaries\CopyTool" "$(TargetDir)$(TargetName)" "$(MyEnvVar)\_Binaries"
As you can see, the path for the copy job is based on the value of an environment variable.
I now want to build another solution which references some of the projects mentioned above.
The build fails because the environment variable is not set for the build.
The build step order in the Build vNext definition:
SetEnv powershell script
[Environment]::GetEnvironmentVariable("MyEnvVar","Process")
Write-Host 'build sources dir'
Write-Host $Env:BUILD_SOURCESDIRECTORY
[Environment]::SetEnvironmentVariable("MyEnvVar", $Env:BUILD_SOURCESDIRECTORY, "Process")
- Visual Studio Build step
- Visual Studio Test
- ... (index, publish, copy, publish artifacts)
But the value of "MyEnvVar" is not accessible in the post build event which is executed by the VS Solution Build step.
How can I achieve that the VS Build step has the value previously set in the powershell script on TFS onPremise (not VSO)?