Closed boukisge closed 3 years ago
Hello! Thanks for filing this issue.
Can you help me understand a couple of things?
The project layout implies that there are multiple runnable projects (Web.API
and Web
) and some class libraries (Web.Model
and Web.DataAccess
). Is that right? It sounds like you want to build this source repo twice, each time producing a container image specific to either Web.API
or Web
, which you can later deploy. And you want to do this using OpenShift's BuildConfigs.
Am I understanding the problem correctly?
As for build dependencies, you can leave it to dotnet build
itself to find project-to-project dependencies and build those correctly.
I have a sample project here following the project setup above that works on OpenShift for me.
Here's the BuildConfig:
https://github.com/omajid/s2i-example-dotnet-multi-project/blob/issue-350/bc.yaml
It defines 2 builds, one for Web
, another for Web.Api
. I only needed to specify DOTNET_STARTUP_PROJECT
(for each project). The build logs show that the dependencies are picked up automatically:
Web.Api:
---> Publishing application...
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Web.DataAccess -> /opt/app-root/src/Web.DataAccess/bin/Release/netstandard2.0/Web.DataAccess.dll
Web.Model -> /opt/app-root/src/Web.Model/bin/Release/netstandard2.0/Web.Model.dll
Web.Api -> /opt/app-root/src/Web.Api/bin/Release/netcoreapp3.1/Web.Api.dll
Web.Api -> /opt/app-root/app/
Web:
---> Publishing application...
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Web.Model -> /opt/app-root/src/Web.Model/bin/Release/netstandard2.0/Web.Model.dll
Web -> /opt/app-root/src/Web/bin/Release/netcoreapp3.1/Web.dll
Web -> /opt/app-root/src/Web/bin/Release/netcoreapp3.1/Web.Views.dll
Web -> /opt/app-root/app/
Hi Omair,
Thank you for responding to my email.
This project follows a microservices based approach The Browser client will talk to the component , which will talk to a number of microservices , each Microservice/API will talk to a database external to the container The model module/project will be shared among the web component and the Microservices
The thinking is to create one container for the web component and separate containers for each Microservice and most likely deploy in separate pods to take advantage of Microservice features suh independent build, deployment and scalability
I believe your understanding is correct
On Mon, Feb 8, 2021 at 5:48 PM Omair Majid notifications@github.com wrote:
Hello! Thanks for filing this issue.
Can you help me understand a couple of things?
The project layout implies that there are multiple runnable projects ( Web.API and Web) and some class libraries (Web.Model and Web.DataAccess). Is that right? It sounds like you want to build this source repo twice, each time producing a container image specific to either Web.API or Web, which you can later deploy. And you want to do this using OpenShift's BuildConfigs.
Am I understanding the problem correctly?
As for build dependencies, you can leave it to dotnet build itself to find project-to-project dependencies and build those correctly.
I have a sample project here https://github.com/omajid/s2i-example-dotnet-multi-project/tree/issue-350 following the project setup above that works on OpenShift for me.
Here's the BuildConfig:
https://github.com/omajid/s2i-example-dotnet-multi-project/blob/issue-350/bc.yaml
It defines 2 builds, one for Web, another for Web.Api. I only needed to specify DOTNET_STARTUP_PROJECT (for each project). The build logs show that the dependencies are picked up automatically:
Web.Api:
---> Publishing application... Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.
Web.DataAccess -> /opt/app-root/src/Web.DataAccess/bin/Release/netstandard2.0/Web.DataAccess.dll Web.Model -> /opt/app-root/src/Web.Model/bin/Release/netstandard2.0/Web.Model.dll Web.Api -> /opt/app-root/src/Web.Api/bin/Release/netcoreapp3.1/Web.Api.dll Web.Api -> /opt/app-root/app/
Web:
---> Publishing application... Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.
Web.Model -> /opt/app-root/src/Web.Model/bin/Release/netstandard2.0/Web.Model.dll Web -> /opt/app-root/src/Web/bin/Release/netcoreapp3.1/Web.dll Web -> /opt/app-root/src/Web/bin/Release/netcoreapp3.1/Web.Views.dll Web -> /opt/app-root/app/
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/s2i-dotnetcore/issues/350#issuecomment-775515232, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2I6X5E4332KNCDZ77IY5LS6BS3VANCNFSM4XHZDUTA .
I believe your understanding is correct
In that case, please try out using two separate build configs. Each one just needs to define DOTNET_STARTUP_PROJECT
to point to a single project at a time. See https://github.com/omajid/s2i-example-dotnet-multi-project/blob/issue-350/bc.yaml for a complete example.
Do I need to define DOTNET_ASSEMBLY_NAME ?
On Mon, Feb 8, 2021 at 6:02 PM Omair Majid notifications@github.com wrote:
I believe your understanding is correct
In that case, please try out using two separate build configs. Each one just needs to define DOTNET_STARTUP_PROJECT to point to a single project at a time. See https://github.com/omajid/s2i-example-dotnet-multi-project/blob/issue-350/bc.yaml for a complete example.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/s2i-dotnetcore/issues/350#issuecomment-775521223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2I6X4ZK3JLNDOQLDTEMETS6BUQFANCNFSM4XHZDUTA .
Do I need to define DOTNET_ASSEMBLY_NAME ?
No, that's really only needed if your assembly name and project names are different. In this case, for example, Web.Api.csproj
generates Web.Api.dll
, so it's not needed.
Please specify oc start-build parameters for each build config
On Mon, Feb 8, 2021 at 6:05 PM George Boukis boukisge@gmail.com wrote:
Do I need to define DOTNET_ASSEMBLY_NAME ?
On Mon, Feb 8, 2021 at 6:02 PM Omair Majid notifications@github.com wrote:
I believe your understanding is correct
In that case, please try out using two separate build configs. Each one just needs to define DOTNET_STARTUP_PROJECT to point to a single project at a time. See https://github.com/omajid/s2i-example-dotnet-multi-project/blob/issue-350/bc.yaml for a complete example.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/s2i-dotnetcore/issues/350#issuecomment-775521223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2I6X4ZK3JLNDOQLDTEMETS6BUQFANCNFSM4XHZDUTA .
The buildconfig for the project I posted doesn't need any parameters, so it's just:
oc start-build s2i-example-dotnet-multi-project-web
oc start-build s2i-example-dotnet-multi-project-web-api
That's the name
parameters from the build configs.
Your buildconfig might be different; I can't say without more information about your buildconfig.
Thank you for the clarification.
On Mon, Feb 8, 2021 at 6:14 PM Omair Majid notifications@github.com wrote:
The buildconfig for the project I posted doesn't need any parameters, so it's just:
oc start-build s2i-example-dotnet-multi-project-web oc start-build s2i-example-dotnet-multi-project-web-api
That's the name parameters from the build configs.
Your buildconfig might be different; I can't say without more information about your buildconfig.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/s2i-dotnetcore/issues/350#issuecomment-775526809, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2I6X26TUAIHFMOKHQENVDS6BV6PANCNFSM4XHZDUTA .
I am closing this issue since the original question was answered and there are no further actions needed here.
Please feel free to re-open this issue or file a new one if there's additional questions around this.
Thank you.
On Wed, Feb 10, 2021 at 2:30 PM Omair Majid notifications@github.com wrote:
Closed #350 https://github.com/redhat-developer/s2i-dotnetcore/issues/350.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/s2i-dotnetcore/issues/350#event-4316583936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2I6X2MOL22NU6H7U7M3PLS6LNFJANCNFSM4XHZDUTA .
No problem! Glad to be able to help.
Hi Omair,
I have another question
I have a requirement to run a dotnet core 3.1 executable batch job - inside a linux container in openshift 4.4 I am able to run a web application with mircoservices , not an issue.
How do I accomplish this? I was able to leverage cronjob within openshift , I get error message "cannot execute binary file"
Any suggestions ? Can I reference a DLL instead of exe When I build exe in MS Visual Studio 2019 are there any build options I can use to enable exe to run on the linux container
Regards, George
On Wed, Feb 10, 2021 at 3:42 PM Omair Majid @.***> wrote:
No problem! Glad to be able to help.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/redhat-developer/s2i-dotnetcore/issues/350#issuecomment-777021283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2I6X7VGJHNOWJ2C3HM6UDS6LVRZANCNFSM4XHZDUTA .
Hey @boukisge ! Can you please file a new issue for this? We are more likely to miss messages on closed issues.
I was able to leverage cronjob within openshift , I get error message "cannot execute binary file".
Can you share more details? A tiny hello-world application + OpenShift configuration that demonstrates this error would be fantastic.
I am trying to build an image for a single solution multi-project .NET Core 3.1 web application with local dependencies using S2I strategy for OpenShift V4.4
Build config fails due to error "Skipping Project"/opt/app-root/src/Web.Model/Web.Model.csproj" because it was not found
bc.yml snippet
Directory Structure - 4 projects , single repo
is there an example for a S2I script that builds dependencies automatically Does this use case require a custom assembly ?