Skip to content

Commit fe0870b

Browse files
committed
dotnet@9 9.0.10 (new formula)
Signed-off-by: botantony <[email protected]>
1 parent fe8f289 commit fe0870b

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed

Formula/d/[email protected]

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
class DotnetAT9 < Formula
2+
desc ".NET Core"
3+
homepage "https://dotnet.microsoft.com/"
4+
url "https://github.com/dotnet/dotnet/archive/refs/tags/v9.0.111.tar.gz"
5+
version "9.0.10"
6+
sha256 "a18cbf9a48e58a516c1da3c58f0e46f66dcf1c5e7ef028e87101b1dc246e536a"
7+
license "MIT"
8+
9+
livecheck do
10+
url :stable
11+
regex(/^v?(9(?:\.\d+)+)$/i)
12+
end
13+
14+
keg_only :versioned_formula
15+
16+
# https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle
17+
deprecate! date: "2026-11-10", because: :unsupported
18+
19+
depends_on "cmake" => :build
20+
depends_on "pkgconf" => :build
21+
depends_on "rapidjson" => :build
22+
depends_on "brotli"
23+
depends_on "icu4c@78"
24+
depends_on "openssl@3"
25+
26+
uses_from_macos "python" => :build
27+
uses_from_macos "krb5"
28+
uses_from_macos "zlib"
29+
30+
on_macos do
31+
depends_on "grep" => :build # grep: invalid option -- P
32+
end
33+
34+
on_linux do
35+
depends_on "libunwind"
36+
depends_on "lttng-ust"
37+
end
38+
39+
resource "release.json" do
40+
version "9.0.10"
41+
url "https://github.com/dotnet/dotnet/releases/download/v9.0.111/release.json"
42+
sha256 "429d63f3d9d6d10921b6e0784f3343fe7a0676b888e726b1e4a20ff2ae9bbbf5"
43+
44+
livecheck do
45+
formula :parent
46+
end
47+
end
48+
49+
def install
50+
if OS.mac?
51+
# Need GNU grep (Perl regexp support) to use release manifest rather than git repo
52+
ENV.prepend_path "PATH", Formula["grep"].libexec/"gnubin"
53+
54+
# Avoid mixing CLT and Xcode.app when building CoreCLR component which can
55+
# cause undefined symbols, e.g. __swift_FORCE_LOAD_$_swift_Builtin_float
56+
ENV["SDKROOT"] = MacOS.sdk_path
57+
else
58+
icu4c_dep = deps.find { |dep| dep.name.match?(/^icu4c(@\d+)?$/) }
59+
ENV.append_path "LD_LIBRARY_PATH", icu4c_dep.to_formula.opt_lib
60+
61+
# Work around build script getting stuck when running shutdown command on Linux
62+
# TODO: Try removing in the next release
63+
# Ref: https://github.com/dotnet/source-build/discussions/3105#discussioncomment-4373142
64+
inreplace "build.sh", '"$CLI_ROOT/dotnet" build-server shutdown', ""
65+
inreplace "repo-projects/Directory.Build.targets",
66+
'"$(DotnetTool) build-server shutdown --vbcscompiler"',
67+
'"true"'
68+
end
69+
70+
args = ["--clean-while-building", "--source-build", "--with-system-libs", "brotli+libunwind+rapidjson+zlib"]
71+
if build.stable?
72+
args += ["--release-manifest", "release.json"]
73+
odie "Update release.json resource!" if resource("release.json").version != version
74+
buildpath.install resource("release.json")
75+
end
76+
77+
system "./prep-source-build.sh"
78+
# We unset "CI" environment variable to work around aspire build failure
79+
# error MSB4057: The target "GitInfo" does not exist in the project.
80+
# Ref: https://github.com/Homebrew/homebrew-core/pull/154584#issuecomment-1815575483
81+
with_env(CI: nil) do
82+
system "./build.sh", *args
83+
end
84+
85+
libexec.mkpath
86+
tarball = buildpath.glob("artifacts/*/Release/dotnet-sdk-*.tar.gz").first
87+
system "tar", "--extract", "--file", tarball, "--directory", libexec
88+
doc.install libexec.glob("*.txt")
89+
(bin/"dotnet").write_env_script libexec/"dotnet", DOTNET_ROOT: libexec
90+
91+
bash_completion.install "src/sdk/scripts/register-completions.bash" => "dotnet"
92+
zsh_completion.install "src/sdk/scripts/register-completions.zsh" => "_dotnet"
93+
man1.install Utils::Gzip.compress(*buildpath.glob("src/sdk/documentation/manpages/sdk/*.1"))
94+
man7.install Utils::Gzip.compress(*buildpath.glob("src/sdk/documentation/manpages/sdk/*.7"))
95+
end
96+
97+
def caveats
98+
<<~CAVEATS
99+
For other software to find dotnet you may need to set:
100+
export DOTNET_ROOT="#{opt_libexec}"
101+
CAVEATS
102+
end
103+
104+
test do
105+
target_framework = "net#{version.major_minor}"
106+
107+
(testpath/"test.cs").write <<~CS
108+
using System;
109+
110+
namespace Homebrew
111+
{
112+
public class Dotnet
113+
{
114+
public static void Main(string[] args)
115+
{
116+
var joined = String.Join(",", args);
117+
Console.WriteLine(joined);
118+
}
119+
}
120+
}
121+
CS
122+
123+
(testpath/"test.csproj").write <<~XML
124+
<Project Sdk="Microsoft.NET.Sdk">
125+
<PropertyGroup>
126+
<OutputType>Exe</OutputType>
127+
<TargetFrameworks>#{target_framework}</TargetFrameworks>
128+
<PlatformTarget>AnyCPU</PlatformTarget>
129+
<RootNamespace>Homebrew</RootNamespace>
130+
<PackageId>Homebrew.Dotnet</PackageId>
131+
<Title>Homebrew.Dotnet</Title>
132+
<Product>$(AssemblyName)</Product>
133+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
134+
</PropertyGroup>
135+
<ItemGroup>
136+
<Compile Include="test.cs" />
137+
</ItemGroup>
138+
</Project>
139+
XML
140+
141+
system bin/"dotnet", "build", "--framework", target_framework, "--output", testpath, testpath/"test.csproj"
142+
output = shell_output("#{bin}/dotnet run --framework #{target_framework} #{testpath}/test.dll a b c")
143+
# We switched to `assert_match` due to progress status ANSI codes in output.
144+
# TODO: Switch back to `assert_equal` once fixed in release.
145+
# Issue ref: https://github.com/dotnet/sdk/issues/44610
146+
assert_match "#{testpath}/test.dll,a,b,c\n", output
147+
148+
# Test to avoid uploading broken Intel Sonoma bottle which has stack overflow on restore.
149+
# See https://github.com/Homebrew/homebrew-core/issues/197546
150+
resource "docfx" do
151+
url "https://github.com/dotnet/docfx/archive/refs/tags/v2.78.3.tar.gz"
152+
sha256 "d97142ff71bd84e200e6d121f09f57d28379a0c9d12cb58f23badad22cc5c1b7"
153+
end
154+
resource("docfx").stage do
155+
system bin/"dotnet", "restore", "src/docfx", "--disable-build-servers", "--no-cache"
156+
end
157+
end
158+
end

0 commit comments

Comments
 (0)