dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.87k stars 466 forks source link

v9.0.0-rc.1.24431.7: fails to build aspire in CI=true environments #5956

Open xen0n opened 1 month ago

xen0n commented 1 month ago

Describe the Bug

aspire fails to build from source if CI=true is present in the environment, which is the case on many CI platforms e.g. Travis CI and GitHub Actions, preventing source builds in such CI environments without kludge.

Code responsible for the behavior

Steps to Reproduce

git clone -b v9.0.0-rc.1.24431.7 --recurse-submodules https://github.com/dotnet/dotnet.git
cd dotnet
docker run --rm --platform linux/amd64 -v $(pwd):/vmr -e CI=true -ti mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9

# inside docker
cd /vmr
./prep-source-build.sh
./build.sh -so --clean-while-building -c Release /p:PortableBuild=true

Other Information

Example run: https://github.com/loongson-community/dotnet-unofficial-build/actions/runs/10969826008/job/30463397000 Although the project is set up for linux-loongarch64 cross builds, the failure occurs at Stage 1 so still relevant to linux-x64.

Relevant log message:

/vmr/src/aspire/eng/Versions.targets(49,67): error MSB4057: The target "GitInfo" does not exist in the project. [/vmr/src/aspire/src/Microsoft.NET.Sdk.Aspire/Microsoft.NET.Sdk.Aspire.csproj]

I'm able to work around the problem by simply overriding CI for build.sh invocations like this.

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ellahathaway commented 1 month ago

This issue is not localized to source-build.

When I ran a local build of the aspire repo with export CI=true and ./build.sh -ci --configuration Release --restore --build --pack, it failed with the same error:

/root/repos/aspire/eng/Versions.targets(49,67): error MSB4057: The target "GitInfo" does not exist in the project.

Looking through the Aspire repo, it's true that GitInfo target does not exist. The issue is originating from these lines. This does not come up in other builds because using -ci does not trigger CI=true.

I'm going to transfer this issue to the aspire repo.

cc @dotnet/aspire-admin

radical commented 1 month ago

Is CI=true a vmr thing? should that be mapped to ContinuousIntegrationBuild=true somewhere?

radical commented 1 month ago

cc @joperezr

xen0n commented 1 month ago

Hi, thank you for following up on this! While I'm not a .NET dev nor very familiar with .NET or the Microsoft CI offerings, here's my current understanding:

Is CI=true a vmr thing?

AFAIK, no, the variable is not among the Azure DevOps presets nor inspected anywhere in arcade (with a cursory grep of \$\(?CI\)?). But I see a few more hits in the VMR (fsharp and razor) so I wonder if it's a relic of old internal CI machinery somewhere that never went public.

The problem is only exposed when one tries to build affected repos with popular open-source CI tools, where a preset CI=true is the ubiquitous convention, unlike Azure DevOps, that occasionally surprises people.

should that be mapped to ContinuousIntegrationBuild=true somewhere?

Probably yes, according to arcade docs it should be the dotnet-org-wide convention.