0
votes

I have a git solution in azure repositories that has three project references to TFVC projects. I'm trying to create a build pipeline right now using YAML, but I can't find any step that downloads projects from TFVC. This is giving me this sort of error:
Error MSB3202: The project file "(path to project)\Standard.Logging.csproj" was not found

I know this is because the project folders aren't part of the repository, but i'm not sure how to bring them from the tfsvc repo into my build agent.

Here is my azure-pipelines.yml:

pool: 'MyPool'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'
    vstsFeed: '{company feed}'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" 
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

How do I download these projects?

1

1 Answers

1
votes

I am afraid YAML pipeline doesnot support TFVC currently.

As workaround you can migrate TFVC to Git.

You can also create a classic UI build pipeline instead of YAML pipeline. TFVC is supported on classic UI pipeline.

enter image description here

User voice to support TFVC in Yaml has been submitted to Microsoft development. You can vote it up or create a new one. see here.

Update:

  • To bring the code from tfsvc repo into build agent.

you can use TFVC Get items rest api to get the items. Add a script task in your pipeline to call the rest api and save the items in the build agent. Please check about below example powershell script: To get a Personal access token. Please refer to document here.

 $url = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/tfvc/items?scopePath=path&recursionLevel=full&api-version=5.1"

 $PAT= "Personal access token"
 $base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))
 $result = Invoke-RestMethod -Uri $url -Method Get -Header @{Authorization = "Basic $base64AuthInfo"} 

 $files= $result.value | where { !$_.isFolder} | select path, url

 foreach($file in $files){
    $path = "$(System.DefaultWorkingDirectory)\" + $file.path.Substring(2)
    New-Item -Path  $path -ItemType File -Force
    Invoke-RestMethod -Uri $file.url -Method get -Header @{Authorization = "BearerĀ $env:SYSTEM_ACCESSTOKEN"} -OutFile $path
  }

Above script call the Get Items Api and get the items url and path($files= $result.value | where { !$_.isFolder} | select path, url)

Then get each item and save to $(System.DefaultWorkingDirectory). For example if my scopePath is $/MyProject/, then the items will be save to $(System.DefaultWorkingDirectory)/MyProject/