Reputation: 219
We're in the process of migrating some old projects and as initial step I have put our first project into a git repo. As an interim measure, we've also added the bin, packages and references folder to separate repo.
However the code won't build with the files in the bin folder etc, I need to be one folder up.
Locally we'd run a restore.ps1 script which will copy the bin folder etc into the main project.
So if we clone our binaries project in c:\binaries the project1 folder is created. Inside that repo we have the follow structure.
c:\git\binaries\project1\bin\
c:\git\binaries\project1\packages\
c:\git\binaries\project1\references\
c:\git\binaries\project1\restore.ps1
In our code repo we clone the repo into the c:\git folder we get the project1 folder.
c:\git\project1\project1\project1.sln
c:\git\project1\project1\project1\bin\
c:\git\project1\project1\references\
c:\git\project1\project1\packages\
I've ran the simple generate pipeline in Azure Devops and it's created the following...
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
However, this is one folder too deep.
I've been looking at commands to pull in the binaries repo and run the restore.ps1. But this won't work as I need to up one level.
- checkout: git://Binaries/project1@master
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: $(System.DefaultWorkingDirectory)\test2.ps1
I know you can set working directories, but I think the whole build process is hindged around the location of the yml file etc.
Upvotes: 0
Views: 2332
Reputation: 28146
Yaml pipeline supports checking out multiple repos. So you can check out both two repos in same pipeline:
resources:
repositories:
- repository: MyGitHubRepo # The name used to reference this repository in the checkout step
type: github #For github git repo
endpoint: xxx
name: MyGitHubOrgOrUser/MyGitHubRepo
- repository: MyAzureReposGitRepo
endpoint: xxx
type: git #For azure devops git repo
name: MyAzureReposGitRepo
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- checkout: self #check out the main repo
- checkout: MyGitHubRepo #check out the code repo
Then you can use a CMD task with xcopy command or Copy Files task to copy the binary repo into main project folder. You even don't need to use the restore1.ps file.
And the path of the two repos, see check out path.
Upvotes: 1