diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f19e448de0a..90c2d26d733 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,43 +1,28 @@ { - "name": "AzurePipelines", - "dockerFile": "Dockerfile", + "name": "AzurePipelines", + "image": "mcr.microsoft.com/devcontainers/dotnet:6.0", - // Configure tool-specific properties. - "customizations": { - // Configure properties specific to VS Code. - "vscode": { - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-vscode.azurecli", - "ms-vscode.powershell", - "hashicorp.terraform", - "esbenp.prettier-vscode", - "tfsec.tfsec" - ] - } - }, + "features": { + "ghcr.io/devcontainers/features/azure-cli:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/git-lfs:1": {}, + "ghcr.io/devcontainers/features/powershell:1": {}, + "ghcr.io/devcontainers/features/terraform:1": {} + }, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postStartCommand' to run commands each time the container is successfully started.. - "postStartCommand": "/home/vscode/azure-pipelines/start.sh", - - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode", - // Amend Azure Pipelines agent version and arch type with 'ARCH' and 'AGENT_VERSION'. https://github.com/microsoft/azure-pipelines-agent/releases. - "build": { - "args": { - "UPGRADE_PACKAGES": "true", - "ARCH": "x64", - "AGENT_VERSION": "2.206.1" - } - }, - "features": { - "terraform": "latest", - "azure-cli": "latest", - "git-lfs": "latest", - "github-cli": "latest", - "powershell": "latest" + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.azurecli", + "ms-vscode.powershell", + "hashicorp.terraform", + "esbenp.prettier-vscode", + "tfsec.tfsec", + "ms-dotnettools.csharp" + ] } -} \ No newline at end of file + }, + + "postStartCommand": "bash .devcontainer/start.sh", + "remoteUser": "vscode" +} diff --git a/.devcontainer/start.sh b/.devcontainer/start.sh new file mode 100755 index 00000000000..d262a8c58f6 --- /dev/null +++ b/.devcontainer/start.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -euo pipefail + +# ---------- Config via Codespaces Secrets ---------- +# Required: set these in your repo/Org Codespaces secrets +# ADO_ORG -> org name (e.g. contoso) OR full URL (https://dev.azure.com/contoso) +# ADO_PAT -> PAT with at least "Agent Pools (Read & manage)" +: "${ADO_ORG:?Set Codespaces secret ADO_ORG to your org name or full URL}" +: "${ADO_PAT:?Set Codespaces secret ADO_PAT to your Azure DevOps PAT}" + +# Optional overrides (you can also set these as secrets/envs) +: "${AZP_POOL:=Default}" # Azure DevOps agent pool +: "${AZP_AGENT_VERSION:=2.206.1}" # Agent version +: "${AZP_AGENT_NAME:=$(hostname)}" # Agent name + +# ---------- Derive org URL ---------- +if [[ "$ADO_ORG" =~ ^https?:// ]]; then + AZP_URL="$ADO_ORG" +else + AZP_URL="https://dev.azure.com/${ADO_ORG}" +fi + +# ---------- Prepare workspace folder ---------- +AGENT_ROOT="/home/vscode/azp" +mkdir -p "$AGENT_ROOT" +chown -R vscode:vscode "$AGENT_ROOT" +cd "$AGENT_ROOT" + +# ---------- Download agent from GitHub releases (reliable) ---------- +AGENT_TGZ="vsts-agent-linux-x64-${AZP_AGENT_VERSION}.tar.gz" +AGENT_URL="https://github.com/microsoft/azure-pipelines-agent/releases/download/v${AZP_AGENT_VERSION}/${AGENT_TGZ}" + +if [[ ! -x "./bin/Agent.Listener" ]]; then + echo "Downloading Azure Pipelines agent ${AZP_AGENT_VERSION}..." + curl -fsSL -o "${AGENT_TGZ}" "${AGENT_URL}" + tar -xzf "${AGENT_TGZ}" + rm -f "${AGENT_TGZ}" + ./bin/installdependencies.sh +fi + +# ---------- Configure agent (ephemeral; auto-removes after job) ---------- +# If reconfiguring, clean stale files to avoid conflicts +if [[ -f ".agent" ]]; then + ./config.sh remove --unattended --auth pat --token "$ADO_PAT" || true +fi + +./config.sh --unattended \ + --url "$AZP_URL" \ + --auth pat --token "$ADO_PAT" \ + --pool "$AZP_POOL" \ + --agent "$AZP_AGENT_NAME" \ + --acceptTeeEula \ + --ephemeral \ + --replace + +# ---------- Run a single job, then exit ---------- +exec ./run.sh --once diff --git a/README.md b/README.md index ece99adf323..af94a7ee578 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - +[![Build Status](https://dev.azure.com/kgpraveen/Space%20Game%20-%20web%20-%20Pipeline/_apis/build/status%2Fkg-praveen.mslearn-tailspin-spacegame-web?branchName=main)](https://dev.azure.com/kgpraveen/Space%20Game%20-%20web%20-%20Pipeline/_build/latest?definitionId=2&branchName=main) # Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a @@ -63,3 +63,4 @@ Privacy information can be found at https://privacy.microsoft.com/en-us/ Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents, or trademarks, whether by implication, estoppel or otherwise. + diff --git a/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml b/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml index f7c4c886074..16197a5d169 100644 --- a/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml +++ b/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml @@ -5,7 +5,7 @@
Space Game -

An example site for learning

+

Welcome to the oficial Space Game site!

diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 23402e427df..d8029768590 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,3 +1,30 @@ -pool: MyAgentPool -steps: -- bash: echo hello world \ No newline at end of file +# ASP.NET Core +# Build and test ASP.NET Core projects targeting .NET Core. +# Add steps that run tests, create a NuGet package, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core + +trigger: +- '*' + +pool: + name: 'MyAgentPool' + +variables: + buildConfiguration: 'Release' + +steps: +- task: UseDotNet@2 + displayName: 'Install .NET 8 SDK' + inputs: + packageType: 'sdk' + version: '8.x' # or pin e.g. 8.0.404 + includePreview: false + +- script: dotnet --info + displayName: 'Dotnet info (sanity check)' + +- script: dotnet restore + displayName: 'dotnet restore' + +- script: dotnet build --configuration Release --no-restore + displayName: 'dotnet build Release'