GoogleCloudPlatform / buildpacks

Builders and buildpacks designed to run on Google Cloud's container platforms
Apache License 2.0
958 stars 144 forks source link

Could not build Dotnet Project #207

Open Je0pardy opened 2 years ago

Je0pardy commented 2 years ago

I am trying to build our custom developed project with buildpack. (First of all I am not .Net expert or developer) Project has a tree structure as follows:

├── BulkGateway.sln ├── src │ ├── Bulk.Gateway | | ├── Bulk.Gateway.csproj │ ├── Bulk.Gateway.Aggregator | | ├── Bulk.Gateway.Aggregator.csproj │ └── Bulk.Gateway.Model | | ├── Bulk.Gateway.Model.csproj ├── nuget.config ├── test │ ├── Bulk.Gateway.IntegrationTests | | ├── Bulk.Gateway.IntegrationTests.csproj │ ├── Bulk.Gateway.UnitTests | | ├── Bulk.Gateway.UnitTests.csproj

If I run pack build --builder=<OurDockerRegistryAdress>/buildpacks/builder sample Failure: (ID: 52331111) expected to find exactly one project file in directory ., found [./test/Bulk.Gateway.UnitTests/Bulk.Gateway.UnitTests.csproj ./test/Inte rtech.Bulk.Gateway.IntegrationTests/Bulk.Gateway.IntegrationTests.csproj ./src/Bulk.Gateway.Aggregator/Bulk.Gateway.Aggregator.csproj ./src/ Bulk.Gateway.Model/Bulk.Gateway.Model.csproj ./src/Bulk.Gateway/Bulk.Gateway.csproj]

I also tried pack build app -e GOOGLE_BUILDABLE=src/Intertech.PusulaPlusBulk.Gateway --builder=/buildpacks/builder It gives an error like;

[builder] === .NET - Runtime (google.dotnet.runtime@0.9.1) === [builder] Looking for global.json in /workspace [builder] Failure: (ID: a18188e3) Failed to run /bin/build: cannot use project's TargetFramework value of "" to get .NET sdk version [builder] -------------------------------------------------------------------------------- [builder] Sorry your project couldn't be built. [builder] Our documentation explains ways to configure Buildpacks to better recognise your project: [builder] -> https://github.com/GoogleCloudPlatform/buildpacks/blob/main/README.md [builder] If you think you've found an issue, please report it: [builder] -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new [builder] -------------------------------------------------------------------------------- [builder] ERROR: failed to build: exit status 1 ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51

But I have TargetFramework value in csproj file Is it possible to build and project with this infrastructure has one sln file and more than one csproj file?

spew commented 2 years ago

Hi @Je0pardy we do not yet support sln files (with multiple csprojs). Thanks for letting us know that this is a functionality that you would want to use. We have added it to our backlog.

alwydl commented 8 months ago

This would be useful. Having the same issue.

fpt-ian commented 5 months ago

Literally any C# project will have have more than one csproj file and multiple need to be built for deployment. What is the method google recommends for building C# files then? Selecting a single csproj works, but it doesn't build the reference projects so fails. Selecting the root folder with the sln file fails as above.

alwydl commented 5 months ago

What worked for me was something I saw in another issue here and use a Google Build Trigger from Cloud Source Repository.

pack build gcr.io/your_project/your_rep:Push$COMMIT_SHA \ --builder gcr.io/buildpacks/builder:google-22 \ --env "GOOGLE_BUILDABLE=Project_Name"

it will build the hole project  you want and any other lib/project linked.
I hope this help in any way.