[英]Azure DevOps Build Pipeline with two repos, different folders
We're in the process of migrating some old projects and as initial step I have put our first project into a git repo.我们正在迁移一些旧项目,作为第一步,我将我们的第一个项目放入 git 存储库中。 As an interim measure, we've also added the bin, packages and references folder to separate repo.作为一项临时措施,我们还将 bin、packages 和 references 文件夹添加到单独的存储库中。
However the code won't build with the files in the bin folder etc, I need to be one folder up.但是代码不会与 bin 文件夹等中的文件一起构建,我需要一个文件夹。
Locally we'd run a restore.ps1 script which will copy the bin folder etc into the main project.在本地,我们将运行一个 restore.ps1 脚本,它将 bin 文件夹等复制到主项目中。
So if we clone our binaries project in c:\binaries the project1 folder is created.因此,如果我们在 c:\binaries 中克隆我们的二进制项目,就会创建 project1 文件夹。 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 文件夹。
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...我在 Azure Devops 中运行了简单的生成管道,它创建了以下内容......
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.我一直在查看用于拉入二进制存储库并运行 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.我知道你可以设置工作目录,但我认为整个构建过程都围绕着 yml 文件的位置等。
Yaml pipeline supports checking out multiple repos . Yaml 管道支持检出多个 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.然后,您可以使用带有 xcopy 命令或复制文件任务的CMD 任务将二进制 repo 复制到主项目文件夹中。 You even don't need to use the restore1.ps file.您甚至不需要使用 restore1.ps 文件。
And the path of the two repos, see check out path .以及两个 repos 的路径,请参见check out path 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.