I'm currently dealing with a problem within my Azure DevOps pipeline where I'm trying to run and build a pipeline for repo 'RepoX', whereafter the Dockerfile tries to use the '.csproj' of repo 'RepoY'. However, 'RepoY' is added as 'existing project reference' to 'RepoX' within Visual Studio. When the dockerfile tries to use the .csproj of repo 'Y' I get a message that this file cannot be found. This is true, since both are located in different repositories, thus are separate projects. How can I make sure RepoX clones repo Y somehow or is able to use RepoY, so that the Dockerfile finds the .csproj of repo Y and builds it in order to push it to, for example Docker hub?
Projects overview
Azure Repo: RepoX
------ [RepoX directory]
------------ Controllers
------------ Properties
------------ appsettings.Development.json
------------ appsettings.json
------------ Program.cs
------------ RepoX.csproj
------ .dockerignore
------ .gitignore
------ azure-pipelines.yml
------ Dockerfile
------ RepoX.sln
Azure Repo: RepoY (Class Library)
------ [CoreClasses directory]
------------ ClassA
------------ ClassB
I tried to use checkout to retrieve the repoY in repoX, but somehow this is not persistent when the Dockerfile is trying to search the .csproj of repoY?
azure-pipelines.yml:
trigger:
- main
# resources:
# - repo: self <---------------- tried to turn this off as well, makes no difference...
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: ubuntu-latest
- task: Docker@2
- checkout: self
path: s/CheckOutFolder
- checkout: git://ProjectA/RepoY
path: s/CheckOutFolder/RepoX/RepoY
- script: |
ls
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/CheckOutFolder/Dockerfile'
tags: |
$(tag)
Dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["RepoX/RepoX.csproj", "RepoX/"]
RUN dotnet restore "RepoX/RepoX.csproj"
#RUN ls ../home/vsts/work/1/s/ <----- says no such directory exists...
#RUN ls ../home/vsts/work/1/s/CheckOutFolder/RepoX/RepoY <----- says no such directory exists...
#RUN ls RepoX <----- does not contain files of RepoY, although I used checkout? I don't get it..
COPY ["RepoX/RepoY/RepoY.csproj", "RepoX/"] <----- says cannot find file...
RUN dotnet restore "RepoX/RepoY.csproj"
COPY . .
WORKDIR "/src/RepoX"
RUN dotnet build "RepoX.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "RepoX.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RepoX.dll"]
Can someone please help me with this?