Skip to content

Sazwan96 patch 2#690

Open
Sazwan96 wants to merge 5 commits intodotnet:mainfrom
Sazwan96:Sazwan96-patch-2
Open

Sazwan96 patch 2#690
Sazwan96 wants to merge 5 commits intodotnet:mainfrom
Sazwan96:Sazwan96-patch-2

Conversation

@Sazwan96
Copy link

Saya akan bantu sediakan skrip pemasangan .NET (Dotnet install script) untuk "Sazwan96 patch 2" berdasarkan keperluan anda. Berikut adalah skrip lengkap yang boleh anda gunakan dalam projek Fairbase.


📜 Skrip Pemasangan .NET SDK (Sazwan96 patch 2)

Pilihan 1: Skrip PowerShell untuk Windows

# dotnet-install-sazwan96.ps1
# Skrip pemasangan .NET SDK untuk Sazwan96 patch 2

param(
    [string]$Channel = "STS",
    [string]$Version = "9.0.100",
    [string]$InstallDir = "$env:LocalAppData\Microsoft\dotnet",
    [string]$Architecture = "x64",
    [switch]$Runtime,
    [switch]$DryRun
)

# Warna untuk output
$Host.UI.RawUI.ForegroundColor = "Green"
Write-Host "🚀 Memulakan pemasangan .NET SDK Sazwan96 patch 2..." -ForegroundColor Cyan

# URL skrip pemasangan rasmi Microsoft
$InstallScriptUrl = "https://dot.net/v1/dotnet-install.ps1"
$InstallScriptPath = Join-Path $env:TEMP "dotnet-install.ps1"

# Muat turun skrip pemasangan
Write-Host "📥 Memuat turun skrip pemasangan..." -ForegroundColor Yellow
Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath

# Parameter pemasangan
$installParams = @{
    Channel = $Channel
    Version = $Version
    InstallDir = $InstallDir
    Architecture = $Architecture
    NoPath = $false
}

if ($Runtime) {
    $installParams.Runtime = "dotnet"
    Write-Host "⚙️  Memasang runtime sahaja..." -ForegroundColor Yellow
}

if ($DryRun) {
    $installParams.DryRun = $true
    Write-Host "🔍 Mod Dry-Run: Menunjukkan apa yang akan dipasang" -ForegroundColor Magenta
}

# Jalankan pemasangan
Write-Host "⚙️  Menjalankan pemasangan .NET SDK versi $Version..." -ForegroundColor Yellow
& $InstallScriptPath @installParams

if ($LASTEXITCODE -eq 0) {
    Write-Host "✅ Pemasangan .NET SDK Sazwan96 patch 2 BERJAYA!" -ForegroundColor Green
    
    # Tambah ke PATH untuk sesi semasa
    $env:Path = "$InstallDir;$env:Path"
    
    # Papar versi yang dipasang
    Write-Host "🔍 Memeriksa versi .NET yang dipasang:" -ForegroundColor Cyan
    & "$InstallDir\dotnet.exe" --info
} else {
    Write-Host "❌ Pemasangan GAGAL! Sila semak log di atas." -ForegroundColor Red
    exit 1
}

Write-Host "📌 Nota: Untuk menggunakan .NET secara global, tambahkan berikut ke PATH sistem:" -ForegroundColor Yellow
Write-Host "   $InstallDir" -ForegroundColor White

Pilihan 2: Skrip Bash untuk Linux/macOS

#!/bin/bash
# dotnet-install-sazwan96.sh
# Skrip pemasangan .NET SDK untuk Sazwan96 patch 2 (Linux/macOS)

set -e

GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color

echo -e "${CYAN}🚀 Memulakan pemasangan .NET SDK Sazwan96 patch 2...${NC}"

# Konfigurasi
CHANNEL="STS"
VERSION="9.0.100"
INSTALL_DIR="$HOME/.dotnet"
ARCHITECTURE="x64"

# Muat turun skrip pemasangan
echo -e "${YELLOW}📥 Memuat turun skrip pemasangan...${NC}"
curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
chmod +x dotnet-install.sh

# Jalankan pemasangan
echo -e "${YELLOW}⚙️  Menjalankan pemasangan .NET SDK versi $VERSION...${NC}"
./dotnet-install.sh --channel $CHANNEL \
                    --version $VERSION \
                    --install-dir $INSTALL_DIR \
                    --architecture $ARCHITECTURE

if [ $? -eq 0 ]; then
    echo -e "${GREEN}✅ Pemasangan .NET SDK Sazwan96 patch 2 BERJAYA!${NC}"
    
    # Tambah ke PATH untuk sesi semasa
    export PATH="$INSTALL_DIR:$PATH"
    
    # Papar versi yang dipasang
    echo -e "${CYAN}🔍 Memeriksa versi .NET yang dipasang:${NC}"
    $INSTALL_DIR/dotnet --info
else
    echo -e "${RED}❌ Pemasangan GAGAL! Sila semak log di atas.${NC}"
    exit 1
fi

echo -e "${YELLOW}📌 Nota: Untuk menggunakan .NET secara global, tambahkan berikut ke ~/.bashrc atau ~/.zshrc:${NC}"
echo -e "   export PATH=\"\$PATH:$INSTALL_DIR\""

Pilihan 3: GitHub Actions Workflow (Integrasi dengan Fairbase)

Buat fail .github/workflows/dotnet-install-sazwan96.yml dalam repositori Fairbase:

name: Install .NET SDK (Sazwan96 patch 2)

on:
  workflow_dispatch:  # Boleh dijalankan secara manual
  push:
    paths:
      - '**/*.cs'
      - '**/*.csproj'
      - '**/global.json'

jobs:
  install-dotnet:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      
      - name: Setup .NET SDK Sazwan96 patch 2
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '9.0.x'  # Menggunakan .NET 9.0 (STS)
          
      - name: Verify .NET installation
        run: |
          dotnet --info
          dotnet --list-sdks
          dotnet --list-runtimes
      
      - name: Restore dependencies
        run: dotnet restore
        continue-on-error: true  # Jika tiada projek .NET, tidak gagal
      
      - name: Build .NET projects (if any)
        run: |
          if [ -f "*.sln" ] || [ -f "**/*.csproj" ]; then
            dotnet build --configuration Release
          else
            echo "Tiada projek .NET dijumpai, langkah dilangkau."
          fi
        shell: bash

🔧 Cara Penggunaan

Untuk Windows (PowerShell):

# Jalankan sebagai Administrator
Set-ExecutionPolicy Bypass -Scope Process -Force
.\dotnet-install-sazwan96.ps1 -Version "9.0.100"

Untuk Linux/macOS:

chmod +x dotnet-install-sazwan96.sh
./dotnet-install-sazwan96.sh

Parameter yang Boleh Disesuaikan :

Parameter Penerangan Contoh
-Channel Saluran keluaran (LTS, STS, 9.0) -Channel "STS"
-Version Versi spesifik -Version "9.0.100"
-InstallDir Direktori pemasangan -InstallDir "D:\dotnet"
-Architecture Seni bina (x64, x86, arm64) -Architecture "x64"
-Runtime Pasang runtime sahaja -Runtime

📋 Menggunakan Versi "patch 2"

Berdasarkan carian, "patch 2" merujuk kepada kemas kini tampalan (patch) kedua untuk sesuatu keluaran .NET. Untuk .NET 9.0, patch terkini boleh didapati dengan menggunakan :

# Untuk patch terkini dalam saluran STS
.\dotnet-install-sazwan96.ps1 -Channel "STS" -Version "latest"

# Untuk patch spesifik 9.0.102 (contoh)
.\dotnet-install-sazwan96.ps1 -Channel "9.0" -Version "9.0.102"

Atau gunakan fail global.json untuk menetapkan versi secara konsisten :

{
  "sdk": {
    "version": "9.0.102",
    "rollForward": "latestPatch"
  }
}

Kemudian jalankan skrip dengan parameter -JSonFile:

.\dotnet-install-sazwan96.ps1 -JSonFile "./global.json"

Pengesahan Pemasangan

Selepas pemasangan, anda boleh mengesahkan dengan:

# Papar versi .NET
dotnet --version

# Papar SDK yang dipasang
dotnet --list-sdks

# Papar runtime yang dipasang
dotnet --list-runtimes

# Maklumat terperinci
dotnet --info

🔗 Integrasi dengan Projek Fairbase Sedia Ada

Jika anda ingin menambah komponen .NET ke dalam projek Fairbase (yang sedia ada React, Node.js, Python, MongoDB, BigQuery), anda boleh:

  1. Letakkan skrip dalam folder scripts/ atau tools/.
  2. Tambahkan job dalam GitHub Actions untuk memasang .NET apabila diperlukan.
  3. Gunakan .NET untuk microservices baru yang mungkin ditulis dalam C#.

📚 Rujukan

  • Dokumentasi rasmi dotnet-install scripts
  • Skrip pemasangan dari repositori rasmi Microsoft
  • Contoh penggunaan dalam CI/CD

Skrip sudah siap! Jika anda memerlukan sebarang pengubahsuaian atau menghadapi masalah, beritahu saya.

# 🚀 GitHub Actions Workflow for .NET: `dotnet.yml`

Berikut adalah file workflow GitHub Actions untuk proyek .NET yang siap digunakan. Simpan file ini sebagai `.github/workflows/dotnet.yml` di repository Anda.

## 📁 Lokasi File
```
.github/workflows/dotnet.yml
```

## 📄 Isi File `dotnet.yml`

```yaml
name: .NET CI

# Kapan workflow ini dijalankan
on:
  push:
    branches: [ main, develop ]          # Jalankan pada push ke branch main/develop
  pull_request:
    branches: [ main ]                    # Jalankan pada PR ke branch main

jobs:
  build:
    runs-on: ubuntu-latest                 # Bisa juga windows-latest / macos-latest

    steps:
    # 1. Checkout kode dari repository
    - name: Checkout repository
      uses: actions/checkout@v4

    # 2. Setup .NET SDK
    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x               # Sesuaikan dengan versi .NET project Anda

    # 3. Restore dependencies (NuGet packages)
    - name: Restore dependencies
      run: dotnet restore

    # 4. Build project
    - name: Build
      run: dotnet build --configuration Release --no-restore

    # 5. Jalankan unit tests
    - name: Test
      run: dotnet test --configuration Release --no-build --verbosity normal
```

## 🔧 Fitur Tambahan (Opsional)

### **Caching NuGet Packages** (percepat build)
Tambahkan langkah ini setelah `actions/checkout`:

```yaml
    - name: Cache NuGet packages
      uses: actions/cache@v3
      with:
        path: ~/.nuget/packages
        key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }}
        restore-keys: |
          ${{ runner.os }}-nuget-
```

### **Matrix Build** (uji dengan beberapa versi .NET)
Ubah bagian `jobs` menjadi:

```yaml
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        dotnet-version: [ '6.0.x', '7.0.x', '8.0.x' ]   # Versi yang akan diuji

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Setup .NET ${{ matrix.dotnet-version }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: ${{ matrix.dotnet-version }}

    # ... langkah lainnya (restore, build, test) ...
```

### **Publish dan Upload Artifact** (hanya pada push ke main)
Tambahkan langkah ini setelah `Test`:

```yaml
    - name: Publish (hanya jika push ke main)
      if: github.ref == 'refs/heads/main' && github.event_name == 'push'
      run: dotnet publish --configuration Release --output ./publish

    - name: Upload artifact
      if: github.ref == 'refs/heads/main' && github.event_name == 'push'
      uses: actions/upload-artifact@v4
      with:
        name: my-app-${{ matrix.dotnet-version || '8.0.x' }}   # Nama file artifact
        path: ./publish
```

## ✅ Workflow Lengkap dengan Semua Fitur

```yaml
name: .NET CI/CD

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        dotnet-version: [ '6.0.x', '7.0.x', '8.0.x' ]

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Cache NuGet packages
      uses: actions/cache@v3
      with:
        path: ~/.nuget/packages
        key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }}
        restore-keys: |
          ${{ runner.os }}-nuget-

    - name: Setup .NET ${{ matrix.dotnet-version }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: ${{ matrix.dotnet-version }}

    - name: Restore dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release --no-restore

    - name: Test
      run: dotnet test --configuration Release --no-build --verbosity normal

    - name: Publish (hanya jika push ke main)
      if: github.ref == 'refs/heads/main' && github.event_name == 'push'
      run: dotnet publish --configuration Release --output ./publish

    - name: Upload artifact
      if: github.ref == 'refs/heads/main' && github.event_name == 'push'
      uses: actions/upload-artifact@v4
      with:
        name: my-app-${{ matrix.dotnet-version }}
        path: ./publish
```

## 📝 Catatan Penting

- Pastikan file workflow disimpan dengan ekstensi `.yml` (bukan `.yaml` – keduanya valid, tapi konsisten).
- Ganti `dotnet-version` sesuai dengan target framework project Anda (misal: `8.0.x`, `7.0.x`, `6.0.x`).
- Jika menggunakan Windows runner (`windows-latest`), perhatikan path cache dan command line.
- Untuk project yang menggunakan file `.sln` yang tidak berada di root, sesuaikan perintah `dotnet restore` dan `dotnet build` dengan path yang tepat (misal: `dotnet restore src/MySolution.sln`).

Setelah menambahkan file ini, commit dan push ke GitHub. Workflow akan otomatis berjalan. Cek tab **Actions** di repository Anda untuk melihat hasilnya.

Selamat mencoba! 🎉
Anda mahu fail **`rare-hounds-behave.md`** sekali lagi. Berikut adalah kandungan lengkap seperti yang telah disediakan sebelum ini. Anda boleh terus salin dan tampal ke dalam fail tersebut di repositori Fairbase.

---

### 📄 **Kandungan `rare-hounds-behave.md`**

```markdown
# Rare Hounds Behave – Dokumentasi Projek Fairbase

Dokumen ini menerangkan tingkah laku jarang berlaku (*rare hounds behave*) dalam konteks pengurusan data dan infrastruktur projek Fairbase. Ia merangkumi corak, pengecualian, dan cara pengendalian yang tidak lazim tetapi penting untuk diketahui.

## 🎯 Tujuan
- Merekod dan mendokumentasikan kejadian atau tingkah laku sistem yang jarang berlaku.
- Menyediakan panduan penyelesaian masalah untuk situasi luar biasa.
- Memastikan pasukan pembangunan bersedia menghadapi senario yang tidak dijangka.

## 📌 Komponen Berkaitan
Tingkah laku jarang berlaku ini mungkin melibatkan komponen berikut dalam projek Fairbase:
- **BigQuery&DataCoin**: Isu kependaman atau kegagalan pertanyaan.
- **Data&Digital**: Data rosak atau format tidak sah.
- **Python All Language**: Skrip yang gagal dijalankan dalam persekitaran tertentu.
- **MongoDB (Bongo DB)**: Sambungan terputus atau replika lag.
- **GitHub Actions**: Workflow yang gagal secara berselang-seli.
- **React Frontend**: Isu rendering atau cache pelik.

## 🔍 Senario Jarang Berlaku (Rare Hounds)

### 1. **Data Duplikat dalam BigQuery**
- **Gejala**: Rekod yang sama muncul lebih daripada sekali dalam jadual `data_coin`.
- **Punca**: Skrip ETL dijalankan serentak atau kegagalan mekanisme deduplikasi.
- **Tindakan**: Jalankan skrip pembersihan `deduplicate_bigquery.py` (jika ada) atau lakukan manual menggunakan `MERGE` statement.

### 2. **Kegagalan Sambungan MongoDB secara Rawak**
- **Gejala**: Backend API gagal membaca/menulis ke MongoDB pada waktu tertentu, tetapi pulih sendiri.
- **Punca**: Timeout rangkaian atau masalah DNS pada kluster Atlas (jika guna Atlas).
- **Tindakan**: Implementasi semula sambungan dengan retry logic. Tambah log untuk mengesan corak masa.

### 3. **GitHub Actions Workflow "Hantu"**
- **Gejala**: Workflow tiba-tiba berjalan tanpa pencetus yang sepatutnya (contoh: tiada push atau PR).
- **Punca**: Mungkin disebabkan oleh `workflow_dispatch` yang dicetuskan secara manual atau ada ralat dalam konfigurasi `on:`.
- **Tindakan**: Semak semula fail YAML, past tiada `schedule` tersembunyi atau `repository_dispatch` yang tidak dijangka.

### 4. **React App Kosong di Production tetapi OK di Local**
- **Gejala**: Halaman kosong selepas deploy, tetapi `npm start` berfungsi.
- **Punca**: Isu laluan asas (base path) atau pembolehubah persekitaran tidak diisi semasa build.
- **Tindakan**: Semak `package.json` untuk `homepage` atau konfigurasi webpack. Pastikan `REACT_APP_*` dibekalkan dalam GitHub Actions.

### 5. **Skrip Python Tiba-tiba Lambat**
- **Gejala**: Skrip yang biasanya siap dalam 1 minit mengambil masa 10 minit.
- **Punca**: API luaran (seperti BigQuery) mungkin mengalami kependaman, atau data yang diproses membesar tanpa notis.
- **Tindakan**: Tambah pengelogan masa dan pantau saiz dataset. Guna `timeout` dan `retry`.

## 🛡️ Amalan Terbaik untuk Mengendali Rare Hounds
1. **Pengelogan Terperinci**: Pastikan setiap komponen mengeluarkan log yang cukup untuk mengesan punca.
2. **Pemantauan Automatik**: Guna alat seperti Google Cloud Monitoring, Prometheus, atau Uptime Robot.
3. **Dokumentasi Segera**: Setiap kali rare hounds berlaku, rekod dalam fail ini dengan butiran.
4. **Ujian Keteguhan**: Simulasikan kegagalan (contoh: matikan sambungan MongoDB secara manual) dan lihat bagaimana sistem bertindak balas.

## 📅 Sejarah Kemas Kini
| Tarikh       | Perubahan                                      | Pengarang     |
|--------------|------------------------------------------------|---------------|
| 2026-03-16   | Versi awal – dokumentasi rare hounds pertama. | Sazwanismail  |

---

*Nota: Fail ini adalah dokumen hidup – sila tambah senario baru apabila ditemui.*
```

---

## ✅ **Cara Menambah ke Repositori (Peringatan)**

1. Pergi ke repositori Fairbase: `https://github.com/Sazwanismail/Fairbase`
2. Klik **"Add file"** → **"Create new file"**.
3. Namakan fail: `rare-hounds-behave.md` (boleh letak di root atau dalam folder `docs/`).
4. Tampal kandungan di atas.
5. Tulis mesej commit: `Add rare-hounds-behave.md documentation`.
6. Klik **"Commit new file"**.

---

Selesai! Jika ada sebarang perubahan atau tambahan yang dikehendaki, sila beritahu saya.
@dotnet-policy-service
Copy link

@Sazwan96 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ),
and conveys certain license rights to the .NET Foundation ( “.NET Foundation” ) for Your contributions to
.NET Foundation open source projects. This Agreement is effective as of the latest signature date below.

1. Definitions.

“Code” means the computer software code, whether in human-readable or machine-executable form,
that is delivered by You to .NET Foundation under this Agreement.

“Project” means any of the projects owned or managed by .NET Foundation and offered under a license
approved by the Open Source Initiative (www.opensource.org).

“Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
Project, including but not limited to communication on electronic mailing lists, source code control
systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
discussing and improving that Project, but excluding communication that is conspicuously marked or
otherwise designated in writing by You as “Not a Submission.”

“Submission” means the Code and any other copyrightable material Submitted by You, including any
associated comments and documentation.

2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
Project. This Agreement covers any and all Submissions that You, now or in the future (except as
described in Section 4 below), Submit to any Project.

3. Originality of Work. You represent that each of Your Submissions is entirely Your
original work. Should You wish to Submit materials that are not Your original work,
You may Submit them separately to the Project if You (a) retain all copyright and
license information that was in the materials as you received them, (b) in the
description accompanying your Submission, include the phrase "Submission
containing materials of a third party:" followed by the names of the third party and any
licenses or other restrictions of which You are aware, and (c) follow any other
instructions in the Project's written guidelines concerning Submissions.

4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
Submission is made in the course of Your work for an employer or Your employer has intellectual
property rights in Your Submission by contract or applicable law, You must secure permission from Your
employer to make the Submission before signing this Agreement. In that case, the term “You” in this
Agreement will refer to You and the employer collectively. If You change employers in the future and
desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
and secure permission from the new employer before Submitting those Submissions.

5. Licenses.

a. Copyright License. You grant .NET Foundation, and those who receive the Submission directly
or indirectly from .NET Foundation, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable
license in the Submission to reproduce, prepare derivative works of, publicly display, publicly perform,
and distribute the Submission and such derivative works, and to sublicense any or all of the foregoing
rights to third parties.

b. Patent License. You grant .NET Foundation, and those who receive the Submission directly or
indirectly from .NET Foundation, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license
under Your patent claims that are necessarily infringed by the Submission or the combination of the
Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
import or otherwise dispose of the Submission alone or with the Project.

c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
granted by implication, exhaustion, estoppel or otherwise.

6. Representations and Warranties. You represent that You are legally entitled to grant the above
licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
have disclosed under Section 3 ). You represent that You have secured permission from Your employer to
make the Submission in cases where Your Submission is made in the course of Your work for Your
employer or Your employer has intellectual property rights in Your Submission by contract or applicable
law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
EXPRESSLY STATED IN SECTIONS 3, 4, AND 6 , THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

7. Notice to .NET Foundation. You agree to notify .NET Foundation in writing of any facts or
circumstances of which You later become aware that would make Your representations in this
Agreement inaccurate in any respect.

8. Information about Submissions. You agree that contributions to Projects and information about
contributions may be maintained indefinitely and disclosed publicly, including Your name and other
information that You submit with Your Submission.

9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
defenses of lack of personal jurisdiction and forum non-conveniens.

10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
supersedes any and all prior agreements, understandings or communications, written or oral, between
the parties relating to the subject matter hereof. This Agreement may be assigned by .NET Foundation.

.NET Foundation dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1.

Berikut adalah skrip **`dotnet-install.sh`** untuk memasang .NET SDK versi terkini (termasuk "Sazwan96 patch 2" – .NET 9.0.x). Skrip ini menggunakan sumber rasmi Microsoft.

---

### 📜 **dotnet-install.sh**
```bash
#!/bin/bash
# dotnet-install.sh – Pemasang .NET SDK untuk Sazwan96 patch 2 (Linux/macOS)

set -e

GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color

echo -e "${CYAN}🚀 Memulakan pemasangan .NET SDK Sazwan96 patch 2...${NC}"

# Parameter (ubah suai mengikut keperluan)
CHANNEL="9.0"               # Saluran (9.0, STS, LTS)
VERSION="latest"            # "latest" atau versi spesifik seperti "9.0.102"
INSTALL_DIR="$HOME/.dotnet"
ARCHITECTURE="x64"

# Muat turun skrip pemasangan rasmi
echo -e "${YELLOW}📥 Memuat turun dotnet-install.sh dari Microsoft...${NC}"
curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install-tmp.sh
chmod +x dotnet-install-tmp.sh

# Jalankan pemasangan
echo -e "${YELLOW}⚙️  Menjalankan pemasangan .NET SDK (Channel: $CHANNEL, Version: $VERSION)...${NC}"
./dotnet-install-tmp.sh --channel $CHANNEL \
                        --version $VERSION \
                        --install-dir $INSTALL_DIR \
                        --architecture $ARCHITECTURE

if [ $? -eq 0 ]; then
    echo -e "${GREEN}✅ Pemasangan .NET SDK BERJAYA!${NC}"
    
    # Tambah ke PATH untuk sesi semasa
    export PATH="$INSTALL_DIR:$PATH"
    
    # Papar versi
    echo -e "${CYAN}🔍 Versi .NET yang dipasang:${NC}"
    $INSTALL_DIR/dotnet --info
else
    echo -e "${RED}❌ Pemasangan GAGAL! Sila semak log di atas.${NC}"
    exit 1
fi

# Bersihkan fail sementara
rm -f dotnet-install-tmp.sh

# Panduan tambahan
echo -e "${YELLOW}📌 Untuk menggunakan .NET secara global, tambahkan baris berikut ke ~/.bashrc atau ~/.zshrc:${NC}"
echo -e "   export PATH=\"\$PATH:$INSTALL_DIR\""
```

---

## ✅ **Cara Penggunaan**

1. **Simpan skrip** sebagai `dotnet-install.sh` dalam repositori Fairbase (misalnya di folder `scripts/`).
2. **Beri kebenaran untuk melaksanakan**:
   ```bash
   chmod +x dotnet-install.sh
   ```
3. **Jalankan**:
   ```bash
   ./dotnet-install.sh
   ```

### ⚙️ **Ubah Suai Parameter**
Anda boleh mengubah nilai pemboleh ubah dalam skrip:
- `CHANNEL`: Tukar kepada `"STS"`, `"LTS"`, atau versi lain seperti `"8.0"`.
- `VERSION`: Gunakan `"latest"` untuk patch terkini, atau nyatakan versi tepat seperti `"9.0.102"`.
- `INSTALL_DIR`: Tentukan direktori pemasangan pilihan.

---

## 🔗 **Integrasi dengan GitHub Actions**
Jika ingin memasang .NET dalam CI/CD, guna `actions/setup-dotnet@v4` seperti berikut:
```yaml
- name: Setup .NET
  uses: actions/setup-dotnet@v4
  with:
    dotnet-version: '9.0.x'   # auto ambil patch terkini
```

Skrip ini juga boleh digunakan dalam GitHub Actions dengan menjalankannya sebagai langkah shell.

---

## 📌 **Nota**
- Skrip ini sesuai untuk **Linux (Ubuntu, Debian, CentOS, dll.)** dan **macOS**.
- Untuk **Windows**, gunakan versi PowerShell yang telah disediakan sebelum ini (`dotnet-install-sazwan96.ps1`).

Jika ada sebarang masalah atau perlu penyesuaian, beritahu saya!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant