Compare commits

...
Author SHA1 Message Date
Chet HuskandCopilot App a5f6b5adfd Register a problem matcher for MSBuild/csc errors and warnings
- Add .github/msbuild.json with two owners: one matching file-based
  diagnostics (File(line,col): error/warning CODE: msg [project]) and
  one matching engine-level errors without file/line info.
- Register the matcher in src/main.ts via the ##[add-matcher] workflow
  command, resolved relative to __dirname so it works from the ncc
  bundle in dist/.
- Add src/__tests__/msbuild-matcher.test.ts validating the matcher
  regexes against representative CS/MSB error and warning lines.
- Document the new problem matcher in README.md.
- Rebuild dist/index.js via npm run build && npm run pack.

Fixes #4

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-21 16:20:37 -05:00
Chet Husk e93fc1308b Merge pull request #146 from danfiedler-msft/danfiedler/pin-actions
Pin GitHub Actions to full-length commit SHAs
2026-09-14 11:47:36 -05:00
Dan Fiedler 8a6453c901 Pin GitHub Actions to full-length commit SHAs 2026-08-23 22:17:50 -04:00
Tim Heuer 30375c66a4 Merge updates to move to node24
Update to Node24
2026-03-20 14:37:33 -07:00
Tim Heuer 53bd3e099e Merge branch 'timheuer/node24' of https://github.com/microsoft/setup-msbuild into timheuer/node24 2026-03-12 11:08:04 -07:00
Tim Heuer 4031508ab2 fix: move to node24
feat: enhance MSBuild setup summary in workflow 🛠️
- Added matrix strategy for multiple runners
- Improved summary output for MSBuild paths and architecture
2026-03-12 11:07:48 -07:00
Tim Heuer dfc05ccabb feat: enhance MSBuild setup summary in workflow 🛠️
- Added matrix strategy for multiple runners
- Improved summary output for MSBuild paths and architecture
2026-03-12 11:05:38 -07:00
Tim Heuer f62e96d728 fix: change test workflow for arch 2026-03-12 11:01:56 -07:00
Tim Heuer c77b6bc497 fix: move to node24 2026-03-12 10:55:15 -07:00
Tim Heuer 767f00a3f0 [skip ci] Merge pull request #129 from GeckoEidechse/fix/readme-typo
Fix small typo in README.md
2024-06-12 06:09:14 -07:00
GeckoEidechse 442baebb59 Fix small typo in README.md 2024-06-12 11:27:13 +02:00
Tim Heuer 70b70342ae Update README.md [skip ci]
Updating note on other tools to use !IMPORTANT
2024-04-15 14:04:32 -07:00
Tim Heuer 31e0ba28c7 Update README examples [skip ci]
Update readme examples to use latest version major
2024-01-31 22:46:42 -08:00
10 changed files with 3358 additions and 3169 deletions

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
groups:
github-actions:
patterns: ["*"]
schedule:
interval: "weekly"
cooldown:
default-days: 7
+30
View File
@@ -0,0 +1,30 @@
{
"problemMatcher": [
{
"owner": "msbuild",
"pattern": [
{
"regexp": "^\\s*(?:\\d+>\\s*)?([^\\s].*?)\\((\\d+)(?:,(\\d+))?(?:,\\d+)*\\)\\s*:\\s*(error|warning)\\s+([A-Za-z]+\\d+)\\s*:\\s*(.*?)(?:\\s+\\[(.+?)\\])?\\s*$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6,
"fromPath": 7
}
]
},
{
"owner": "msbuild-no-location",
"pattern": [
{
"regexp": "^(?!.*\\().*\\b(error|warning)\\s+([A-Za-z]+\\d+)\\s*:\\s*(.*)$",
"severity": 1,
"code": 2,
"message": 3
}
]
}
]
}
+33 -23
View File
@@ -4,26 +4,25 @@ on:
branches: branches:
- dev - dev
paths-ignore: paths-ignore:
- '*.md' - "*.md"
push: push:
branches: branches:
- dev - dev
paths-ignore: paths-ignore:
- '*.md' - "*.md"
workflow_dispatch: workflow_dispatch:
branches:
- dev
- arm64
- master
paths-ignore:
- '*.md'
jobs: jobs:
build: build:
runs-on: windows-latest strategy:
fail-fast: false
matrix:
runner:
- windows-latest
- windows-2025-vs2026
runs-on: ${{ matrix.runner }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Setup MSBuild (vswhere-path) - name: Setup MSBuild (vswhere-path)
id: setup_msbuild_explicit id: setup_msbuild_explicit
@@ -39,31 +38,42 @@ jobs:
id: setup_msbuild_fallback id: setup_msbuild_fallback
uses: ./ uses: ./
env: env:
PATH: '' PATH: ""
- name: Setup MSBuild (x64) - name: Setup MSBuild (x64)
if: always() if: runner.arch == 'X64'
id: setup_msbuild_path_x64 id: setup_msbuild_path_x64
uses: ./ uses: ./
with: with:
vs-prerelease: true vs-prerelease: true
msbuild-architecture: 'x64' msbuild-architecture: "x64"
- name: Setup MSBuild (arm64) - name: Setup MSBuild (arm64)
if: always() if: runner.arch == 'ARM64'
id: setup_msbuild_path_arm id: setup_msbuild_path_arm64
uses: ./ uses: ./
with: with:
vs-prerelease: true vs-prerelease: true
msbuild-architecture: 'arm64' msbuild-architecture: "arm64"
- name: echo msbuild path - name: Write MSBuild summary
if: always()
shell: pwsh
run: | run: |
echo "vswhere-path: ${{ steps.setup_msbuild_explicit.outputs.msbuildPath }}" @"
echo "PATH: ${{ steps.setup_msbuild_path.outputs.msbuildPath }}" ## MSBuild setup summary
echo "ARM PATH: ${{ steps.setup_msbuild_path_arm.outputs.msbuildPath }}"
echo "ARM PATH: ${{ steps.setup_msbuild_path_x64.outputs.msbuildPath }}" - Runner label: `${{ matrix.runner }}`
echo "Fallback: ${{ steps.setup_msbuild_fallback.outputs.msbuildPath }}" - Runner architecture: `${{ runner.arch }}`
| Probe | msbuildPath |
| --- | --- |
| vswhere-path | ${{ steps.setup_msbuild_explicit.outputs.msbuildPath || 'N/A' }} |
| PATH | ${{ steps.setup_msbuild_path.outputs.msbuildPath || 'N/A' }} |
| Fallback | ${{ steps.setup_msbuild_fallback.outputs.msbuildPath || 'N/A' }} |
| x64 | ${{ steps.setup_msbuild_path_x64.outputs.msbuildPath || 'N/A' }} |
| arm64 | ${{ steps.setup_msbuild_path_arm64.outputs.msbuildPath || 'N/A' }} |
"@ | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
- name: echo MSBuild - name: echo MSBuild
run: msbuild -version run: msbuild -version
+11 -6
View File
@@ -2,13 +2,14 @@
This action will help discover where the `MSBuild` tool is and automatically add it to the `PATH` environment variables for you so future steps in your Actions workflow can just initiate `msbuild` commands without knowing the full path. This action will help discover where the `MSBuild` tool is and automatically add it to the `PATH` environment variables for you so future steps in your Actions workflow can just initiate `msbuild` commands without knowing the full path.
> [!IMPORTANT]
> Please note this tool does NOT add other Visual Studio tools (like VSTest, cl, cmake, or others) to `PATH` > Please note this tool does NOT add other Visual Studio tools (like VSTest, cl, cmake, or others) to `PATH`
## Example Usage ## Example Usage
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v3
- name: Build app for release - name: Build app for release
run: msbuild src\YourProjectFile.csproj -t:rebuild -verbosity:diag -property:Configuration=Release run: msbuild src\YourProjectFile.csproj -t:rebuild -verbosity:diag -property:Configuration=Release
@@ -16,7 +17,7 @@ This action will help discover where the `MSBuild` tool is and automatically add
## Runners and included software ## Runners and included software
This action is intended to be used within the GitHub Actions workflows using the model of 'runners' either hosted (provided by GitHub) or self-hosted (provided by you). The version and parameters you specify below are going to be scoped to what software actually exists on the runner image being used. For example, hosted runner images from GitHub typically do NOT have pre-release versions of Visual Studio on them so using `vs-prerelease` parameter noted below may not have intended effect when using hosted runners. The software included for GitHub-hosted runner iamges can always be found here: <https://github.com/actions/runner-images> which also includes information on when/how software on hosted images gets updated. This action is intended to be used within the GitHub Actions workflows using the model of 'runners' either hosted (provided by GitHub) or self-hosted (provided by you). The version and parameters you specify below are going to be scoped to what software actually exists on the runner image being used. For example, hosted runner images from GitHub typically do NOT have pre-release versions of Visual Studio on them so using `vs-prerelease` parameter noted below may not have intended effect when using hosted runners. The software included for GitHub-hosted runner images can always be found here: <https://github.com/actions/runner-images> which also includes information on when/how software on hosted images gets updated.
## Optional Parameters ## Optional Parameters
@@ -28,7 +29,7 @@ You may have a situation where your Actions runner has multiple versions of Visu
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v3
with: with:
vs-version: '[16.4,16.5)' vs-version: '[16.4,16.5)'
``` ```
@@ -41,7 +42,7 @@ If you need your Actions runner to target a pre-release version of Visual Studio
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v3
with: with:
vs-prerelease: true vs-prerelease: true
``` ```
@@ -52,7 +53,7 @@ By default the action will use the x86 architecture for MSBuild, but it is possi
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v3
with: with:
msbuild-architecture: x64 msbuild-architecture: x64
``` ```
@@ -63,11 +64,15 @@ This makes use of the vswhere tool which is a tool delivered by Microsoft to hel
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v3
with: with:
vswhere-path: 'C:\path\to\your\tools\' vswhere-path: 'C:\path\to\your\tools\'
``` ```
## Problem matcher
This action registers a [problem matcher](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) for MSBuild/csc-style `error`/`warning` output (for example `error MSB1234:` or `error CS1234:`). Once registered, matching lines in the build log are automatically surfaced as annotations in the GitHub Actions UI and, when applicable, as pull request check annotations.
## Notes on arguments ## Notes on arguments
While the Action enables you to specify a `vswhere` path as well as a `vs-version`, these are more advanced options and when using GitHub-hosted runners you should not need these and is recommended you don't specify them as they are optional. Using these require you to fully understand the runner environment, updates to the tools on the runner, and can cause failures if you are out of sync. For GitHub-hosted runners, omitting these arguments is the preferred usage. While the Action enables you to specify a `vswhere` path as well as a `vs-version`, these are more advanced options and when using GitHub-hosted runners you should not need these and is recommended you don't specify them as they are optional. Using these require you to fully understand the runner environment, updates to the tools on the runner, and can cause failures if you are out of sync. For GitHub-hosted runners, omitting these arguments is the preferred usage.
+1 -1
View File
@@ -23,5 +23,5 @@ outputs:
description: "The resulting location of msbuild for your inputs" description: "The resulting location of msbuild for your inputs"
runs: runs:
using: "node20" using: "node24"
main: "dist/index.js" main: "dist/index.js"
+3147 -3124
View File
File diff suppressed because it is too large. Load diff
+12 -12
View File
@@ -1,12 +1,12 @@
{ {
"name": "setup-msbuild", "name": "setup-msbuild",
"version": "1.3.2", "version": "3.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "setup-msbuild", "name": "setup-msbuild",
"version": "1.3.2", "version": "3.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
@@ -17,7 +17,7 @@
"@types/jest": "^24.0.23", "@types/jest": "^24.0.23",
"@types/node": "^12.12.25", "@types/node": "^12.12.25",
"@typescript-eslint/parser": "^2.8.0", "@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5", "@vercel/ncc": "^0.38.4",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-plugin-github": "^2.0.0", "eslint-plugin-github": "^2.0.0",
"eslint-plugin-jest": "^22.21.0", "eslint-plugin-jest": "^22.21.0",
@@ -789,12 +789,12 @@
} }
} }
}, },
"node_modules/@zeit/ncc": { "node_modules/@vercel/ncc": {
"version": "0.20.5", "version": "0.38.4",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.20.5.tgz", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.4.tgz",
"integrity": "sha512-XU6uzwvv95DqxciQx+aOLhbyBx/13ky+RK1y88Age9Du3BlA4mMPCy13BGjayOrrumOzlq1XV3SD/BWiZENXlw==", "integrity": "sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==",
"deprecated": "@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.",
"dev": true, "dev": true,
"license": "MIT",
"bin": { "bin": {
"ncc": "dist/ncc/cli.js" "ncc": "dist/ncc/cli.js"
} }
@@ -8845,10 +8845,10 @@
"tsutils": "^3.17.1" "tsutils": "^3.17.1"
} }
}, },
"@zeit/ncc": { "@vercel/ncc": {
"version": "0.20.5", "version": "0.38.4",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.20.5.tgz", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.4.tgz",
"integrity": "sha512-XU6uzwvv95DqxciQx+aOLhbyBx/13ky+RK1y88Age9Du3BlA4mMPCy13BGjayOrrumOzlq1XV3SD/BWiZENXlw==", "integrity": "sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==",
"dev": true "dev": true
}, },
"abab": { "abab": {
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "setup-msbuild", "name": "setup-msbuild",
"version": "2.0.0", "version": "3.0.0",
"private": true, "private": true,
"description": "Helps set up specific MSBuild tool into PATH for later usage.", "description": "Helps set up specific MSBuild tool into PATH for later usage.",
"main": "lib/main.js", "main": "lib/main.js",
@@ -9,7 +9,7 @@
"format": "prettier --write **/*.ts", "format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts", "lint": "eslint src/**/*.ts",
"pack": "ncc build", "pack": "ncc build lib/main.js -o dist",
"test": "jest", "test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run pack" "all": "npm run build && npm run format && npm run lint && npm run pack"
}, },
@@ -36,7 +36,7 @@
"@types/jest": "^24.0.23", "@types/jest": "^24.0.23",
"@types/node": "^12.12.25", "@types/node": "^12.12.25",
"@typescript-eslint/parser": "^2.8.0", "@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5", "@vercel/ncc": "^0.38.4",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-plugin-github": "^2.0.0", "eslint-plugin-github": "^2.0.0",
"eslint-plugin-jest": "^22.21.0", "eslint-plugin-jest": "^22.21.0",
+101
View File
@@ -0,0 +1,101 @@
import * as fs from 'fs'
import * as path from 'path'
interface ProblemMatcherPattern {
regexp: string
file?: number
line?: number
column?: number
severity?: number
code?: number
message?: number
fromPath?: number
}
interface ProblemMatcherOwner {
owner: string
pattern: ProblemMatcherPattern[]
}
interface ProblemMatcherFile {
problemMatcher: ProblemMatcherOwner[]
}
const matcherPath = path.join(__dirname, '..', '..', '.github', 'msbuild.json')
const matcherFile: ProblemMatcherFile = JSON.parse(
fs.readFileSync(matcherPath, 'utf8')
)
function findOwner(owner: string): ProblemMatcherOwner {
const found = matcherFile.problemMatcher.find(m => m.owner === owner)
if (!found) {
throw new Error(`No matcher owner named ${owner} found`)
}
return found
}
describe('msbuild problem matcher', () => {
it('is valid JSON with the expected owners', () => {
expect(matcherFile.problemMatcher.map(m => m.owner)).toEqual([
'msbuild',
'msbuild-no-location'
])
})
describe('msbuild owner (file-based diagnostics)', () => {
const regexp = new RegExp(findOwner('msbuild').pattern[0].regexp)
it('matches a csc-style error with file, line, column and project path', () => {
const line =
'Program.cs(10,5): error CS1002: ; expected [C:\\proj\\proj.csproj]'
const match = regexp.exec(line)
expect(match).not.toBeNull()
expect(match?.[1]).toBe('Program.cs')
expect(match?.[2]).toBe('10')
expect(match?.[3]).toBe('5')
expect(match?.[4]).toBe('error')
expect(match?.[5]).toBe('CS1002')
expect(match?.[6]).toBe('; expected')
expect(match?.[7]).toBe('C:\\proj\\proj.csproj')
})
it('matches an MSB-coded warning with file and line only', () => {
const line =
'C:\\proj\\proj.csproj(15,1): warning MSB3277: Found conflicts [C:\\proj\\proj.csproj]'
const match = regexp.exec(line)
expect(match).not.toBeNull()
expect(match?.[4]).toBe('warning')
expect(match?.[5]).toBe('MSB3277')
})
it('matches a diagnostic without a trailing project path', () => {
const line = 'Program.cs(3,1): error CS0246: The type or namespace name could not be found'
const match = regexp.exec(line)
expect(match).not.toBeNull()
expect(match?.[5]).toBe('CS0246')
expect(match?.[6]).toBe(
'The type or namespace name could not be found'
)
expect(match?.[7]).toBeUndefined()
})
})
describe('msbuild-no-location owner (engine-level diagnostics)', () => {
const regexp = new RegExp(findOwner('msbuild-no-location').pattern[0].regexp)
it('matches an MSBuild engine error with no file/line info', () => {
const line = 'MSBUILD : error MSB1009: Project file does not exist.'
const match = regexp.exec(line)
expect(match).not.toBeNull()
expect(match?.[1]).toBe('error')
expect(match?.[2]).toBe('MSB1009')
expect(match?.[3]).toBe('Project file does not exist.')
})
it('does not match lines already covered by the file-based owner', () => {
const line =
'Program.cs(10,5): error CS1002: ; expected [C:\\proj\\proj.csproj]'
expect(regexp.test(line)).toBe(false)
})
})
})
+9
View File
@@ -23,8 +23,17 @@ if (VS_VERSION !== 'latest') {
core.debug(`Execution arguments: ${VSWHERE_EXEC}`) core.debug(`Execution arguments: ${VSWHERE_EXEC}`)
function registerProblemMatcher(): void {
const matcherPath = path.join(__dirname, '..', '.github', 'msbuild.json')
core.info(`##[add-matcher]${matcherPath}`)
}
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
// register the problem matcher so MSBuild/csc errors and warnings are
// annotated in the workflow log and any related pull request
registerProblemMatcher()
// exit if non Windows runner // exit if non Windows runner
if (IS_WINDOWS === false) { if (IS_WINDOWS === false) {
core.setFailed('setup-msbuild can only be run on Windows runners') core.setFailed('setup-msbuild can only be run on Windows runners')