Building from source uses highly flawed method of detecting versions

Đang mở
#520 10 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp, go
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu bằng cách xác định mã buildpack phân tích các tệp .csproj để tìm TargetFramework, sau đó xem xét hành vi của MSBuild được mô tả trong issue #520. Chạy dotnet msbuild /t:__GetFrameworkVersion với các project tiêu biểu và xác minh rằng phần triển khai sử dụng output của MSBuild thay vì phân tích XML, bao gồm cả các project sử dụng imports hoặc TargetFrameworks.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Current buildpack tries to parse .csproj file as XML to extract TargetFramework and a few other properties to determine the correct version to introduce. This is a highly flawed way of doing it because .csproj is essentially an MSBuild script. There can be a very large number of ways to set these properties in a way that is non standard for all sorts of legit reasons. The value of <TargetFramework> may actually be a variable that comes from a common import file at parent level. It may be set by Directory.Build.props which is a common way to set it for multiple projects simultaneously as it's automatically imported from a parent folder. It may be absent altogether and declared as signifying that the project can run on multiple runtimes. The only thing that can accurately answer which TargetFramework is actually being used is MSBuild itself.

The simplest way to query MSBuild for this info is to inject a target that echos the property to console and parse it. For example if you append this to the bottom of csproj

  <Target Name="__GetFrameworkVersion">
    <Message Text="TargetFramework is '$(TargetFramework)'" Importance="High" />
  </Target>

one can print out the value of TargetFramework to console by running

> dotnet msbuild /t:__GetFrameworkVersion

Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  TargetFramework is 'net6.0'
Ngôn ngữ chính
Go
Star
98
Fork
91
Merge trung bình
7 giờ 39 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cloudfoundry/dotnet-core-buildpack

Tất cả issue của cloudfoundry/dotnet-core-buildpack

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.