Skip to content

Commit 1f18195

Browse files
botantonybevanjkay
authored andcommitted
dotnet@9 9.0.111 (new formula)
Signed-off-by: botantony <[email protected]>
1 parent fc88b9d commit 1f18195

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

Formula/d/[email protected]

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

0 commit comments

Comments
 (0)