I have a Visual Studio Build definition that compiles solution1.sln. It has 2 web projects: WebProject1, and WebApiProject2.
Is there any what to get those names (WebProject1, WebApiProject2) automatically into variables?
You need to add a Powershell step to retrieve project names from a .sln file and then set the project names into variables.
Get-Content 'xxx.sln' |
Select-String 'Project\(' |
ForEach-Object {
$projectParts = $_ -Split '[,=]' | ForEach-Object { $_.Trim('[ "{}]') };
New-Object PSObject -Property @{
Name = $projectParts[1];
}
}
Sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. Check ##vso[task.setvariable]value for more information.
Example:
##vso[task.setvariable variable=testvar;]testvalue
##vso[task.setvariable variable=testvar;issecret=true;]testvalue