Compare commits

...
Author SHA1 Message Date
Chet HuskandCopilot App fc127f2e68 Default to auto-detected 64-bit MSBuild on 64-bit hosts (breaking change, v4)
Fixes #88

- msbuild-architecture no longer hardcodes a default of "x86". When the
  input is left unspecified, the action now auto-detects: it prefers x64
  when running on a 64-bit machine and the resolved VS/MSBuild install is
  17.0+ (VS 2022+), and falls back to x86 otherwise. An explicit
  msbuild-architecture value is always respected.
- Extracted resolveMSBuildArchitecture()/parseMajorVersion() as pure,
  exported helpers and added jest tests covering the resolution matrix.
- Bumped package.json version to 4.0.0 (breaking change/new major version).
- Updated action.yml input description and README (usage examples now
  reference @v4, new "Breaking Changes in v4" section, and the
  architecture-selection docs rewritten to describe auto-detection).
- Rebuilt dist/index.js via ncc.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-22 11:15:16 -05:00
Chet HuskandCopilot App ea1f75da7f Add info-level logging for MSBuild path, version, and architecture (#79)
Upgrades key diagnostics from core.debug to core.info so they are
visible by default (not just with ACTIONS_STEP_DEBUG), matching the
request in #79:
- Log the resolved MSBuild path
- Log the resolved MSBuild version (via MSBuild.exe -version -nologo,
  wrapped in try/catch so a failure to obtain it doesn't fail the action)
- Log the architecture used

Other existing debug logs are left unchanged. Rebuilt dist/ via
npm run build && npm run pack.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-21 16:19:59 -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
Tim Heuer 6fb0222098 Address issue #125 releasing the node20 action as major version change 2024-01-30 17:01:17 -08:00
Tim Heuer ede762b26a Reverting to node16 for compat in 1.x versions 2024-01-30 16:51:49 -08:00
Tim Heuer 031090342a Updated lock 2024-01-25 19:02:21 -08:00
Tim Heuer 79fdc4b9cf Version bump 2024-01-25 18:54:32 -08:00
Tim Heuer 56275591f5 Merge branch 'kawon7317-main' 2024-01-25 18:53:59 -08:00
kawon7317 faa06544ad Update action.yml
Replace Node.js 16 with Node.js 20
2024-01-25 17:39:12 +08:00
Tim Heuer c9685f2ae5 Merge pull request #122 from mosfet80/patch-1 [skip ci]
Update test.yml
2024-01-16 12:01:13 -08:00
mosfet80 f37d07ecbd Update test.yml
updated  actions/checkout to v4
2024-01-16 01:01:19 +01:00
Tim Heuer 3404ff3d40 Adding runner image doc note [skip ci] 2023-08-14 08:38:37 -07:00
Tim Heuer 1ff57057b5 Added action-types 2023-02-03 15:02:07 -08:00
Tim Heuer 0e7c76c8f5 Merge pull request #110 from Vampire/issue-109 [skip ci]
Implement #109 adding action types file and fixes #111 as well
2023-02-03 08:46:55 -08:00
Björn Kautler 3ac564e2a5 Implement #109 adding action types file 2023-02-03 17:43:05 +01:00
Tim Heuer d3ea839497 Version bump 2022-12-13 08:12:09 -08:00
Tim Heuer 0a09b7fae9 Fixes #104 reassigning input arg [skip ci] 2022-12-13 08:07:05 -08:00
Tim Heuer 0b93bd95fc Adding arm64 sniffing support 2022-12-12 12:36:10 -08:00
Tim Heuer cc48120b57 Merge branch 'master' into arm64 2022-11-13 08:08:00 -07:00
Tim Heuer 645e3f7313 Modifying version and readme notes [skip ci] 2022-11-13 08:01:59 -07:00
Tim Heuer 1ccd12233c Fixing formatting on string arg [skip ci] 2022-11-07 17:16:50 -07:00
Tim Heuer 750ad4a08c Dedupe IDs [skip ci] 2022-11-07 17:13:28 -07:00
Tim Heuer 8c3da926c2 Dedupe IDs [skip ci] 2022-11-07 17:05:30 -07:00
Tim Heuer e0b9f539d1 Adding arm64 tester [skip ci] 2022-11-07 17:03:36 -07:00
Tim Heuer e38c2fa359 modifying tester [skip ci] 2022-11-07 16:55:30 -07:00
Tim Heuer 1bba226ea3 Adding arm64 detection 2022-11-07 16:54:38 -07:00
Tim Heuer 0b44c6745b Merge pull request #94 from microsoft/v1.1.3
Fixes #93 [skip ci]
2022-10-12 16:19:33 -07:00
Tim Heuer 34cfbaee7f Fixes #93 2022-10-12 16:07:40 -07:00
Tim Heuer a1c1eda384 Merge pull request #90 from microsoft/v1.1.2
V1.1.2
2022-10-11 16:17:00 -07:00
Tim Heuer d6496d378f version bump 2022-10-11 16:11:40 -07:00
Tim Heuer b381dbabab Pruned and packed 2022-10-11 15:59:42 -07:00
Tim Heuer 36d6f2fae1 Updating version 2022-10-11 15:56:19 -07:00
Tim Heuer 65aeb87ed1 Merge branch 'Morrisby-master' into v1.1.1 2022-10-11 15:54:09 -07:00
Matt Verrinder 50f8578df5 Update to use Node.js 16 2022-10-11 21:58:04 +01:00
Tim Heuer fbf0ccc42a Fixes #67 [skip ci] 2021-11-08 15:24:09 -07:00
Tim Heuer fbf959e541 Merge branch 'MarkIngramUK-patch-1' 2021-11-08 15:17:17 -07:00
Mark Ingram ce3de01b52 Updated README.md to include vs-prerelease and msbuild-architecture
Inspired by #67 I thought I would propose an update to the readme to cover the two missing inputs.
2021-11-08 22:02:23 +00:00
Tim Heuer c7c2934c87 Fix #58 clarifying intent and providing example usage [skip ci] 2021-11-03 06:28:29 -07:00
Tim Heuer c4a66a0e8a Updated docs [skip ci] 2021-11-01 20:07:20 -07:00
Tim Heuer e48d8c6605 Merge branch 'baronfel-x64-probing' 2021-11-01 20:03:29 -07:00
Tim Heuer ab534842b4 Merging x64 probe and typos 2021-11-01 20:01:10 -07:00
Tim HeuerandHeath Stewart 84e0d709b2 Update src/main.ts
Co-authored-by: Heath Stewart <heaths@outlook.com>
2021-11-01 18:58:32 -07:00
Tim HeuerandHeath Stewart 613696a2a0 Update action.yml
Co-authored-by: Heath Stewart <heaths@outlook.com>
2021-11-01 18:58:16 -07:00
Chet Husk 6c2e301a93 add probing for x64 msbuild binaries 2021-11-01 16:58:33 -05:00
Tim Heuer 0cd944e169 Merge pull request #61 from microsoft/dependabot/npm_and_yarn/ws-5.2.3 [skip ci]
Bump ws from 5.2.2 to 5.2.3
2021-08-24 14:21:52 -06:00
Tim Heuer aaa8d4fac0 Merge pull request #57 from microsoft/dependabot/npm_and_yarn/path-parse-1.0.7 [skip ci]
Bump path-parse from 1.0.6 to 1.0.7
2021-08-24 14:21:40 -06:00
Tim Heuer 323ede3ce9 Merge pull request #53 from microsoft/dependabot/npm_and_yarn/hosted-git-info-2.8.9 [skip ci]
Bump hosted-git-info from 2.8.5 to 2.8.9
2021-08-24 14:21:26 -06:00
Tim Heuer dfaf113754 Merge pull request #52 from microsoft/dependabot/npm_and_yarn/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21
2021-08-24 14:21:11 -06:00
Tim Heuer 33941d8101 Merge pull request #51 from microsoft/dependabot/npm_and_yarn/handlebars-4.7.7
Bump handlebars from 4.5.3 to 4.7.7
2021-08-24 14:20:59 -06:00
Tim Heuer 8611b39e1b Merge pull request #46 from microsoft/dependabot/npm_and_yarn/y18n-4.0.1 [skip ci]
Bump y18n from 4.0.0 to 4.0.1
2021-08-24 14:20:46 -06:00
dependabot[bot] 2cbcfcb795 Bump ws from 5.2.2 to 5.2.3
Bumps [ws](https://github.com/websockets/ws) from 5.2.2 to 5.2.3.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/5.2.2...5.2.3)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-24 20:00:17 +00:00
Tim Heuer a7d39343f8 Merge pull request #60 from microsoft/v1.0.3 [skip ci]
Merging 1.0.3 changes
2021-08-24 13:59:39 -06:00
Tim Heuer 9546707e6b Fixing input warning message 2021-08-24 12:54:44 -07:00
Tim Heuer f9e64ce582 Adding pre-release input flag 2021-08-24 12:51:38 -07:00
Tim Heuer 6387a9728e Merge branch 'Clancey-patch-1' 2021-08-24 12:45:51 -07:00
dependabot[bot] 412f270368 Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 04:46:29 +00:00
James Clancey 455ec54ae7 Always use -latest 2021-07-13 14:36:17 -08:00
James Clancey 4917605713 Allows vs-prerelease option Fixes #45 2021-07-13 13:31:52 -08:00
James Clancey 7561732237 Added an option for allow-prerelease 2021-07-13 13:22:52 -08:00
dependabot[bot] 047d9a0678 Bump hosted-git-info from 2.8.5 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.5 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.5...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 14:56:14 +00:00
dependabot[bot] 9afe006fef Bump lodash from 4.17.19 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 08:06:47 +00:00
dependabot[bot] babd7930ed Bump handlebars from 4.5.3 to 4.7.7
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.5.3 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.5.3...v4.7.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-08 20:43:55 +00:00
dependabot[bot] 7626c90a39 Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-31 18:28:35 +00:00
Tim Heuer 1982f45c48 Update README.md
Clarifying more that this is only for MSBuild
2021-03-15 08:05:45 -07:00
Tim Heuer 0e477eda77 Adding doc on release process 2020-10-06 09:20:39 -07:00
Tim Heuer f032e55f3f Update readme to latest version 2020-10-06 08:57:14 -07:00
Tim Heuer 6a8fedefe9 Merge pull request #25 from microsoft/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.0 to 1.2.6
2020-10-06 08:28:29 -07:00
dependabot[bot] a0858ffef3 Bump @actions/core from 1.2.0 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.0 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:33:54 +00:00
Tim Heuer 9fe8dba406 Merge pull request #23 from LanceMcCarthy/patch-1
Update README.md
2020-09-01 13:49:32 -07:00
Lance McCarthy 0b5643901b Update README.md
Fixed incorrect indentation of `with` in examples
2020-09-01 16:38:21 -04:00
Tim Heuer 45346b5e09 Merge pull request #21 from kishorejangid/patch-1
Update README.md
2020-08-03 08:10:44 -07:00
Kishore Kumar 06c9a7f31c Update README.md
Incorrect grammar
2020-08-01 18:15:15 +05:30
11 changed files with 12054 additions and 900 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
+60 -24
View File
@@ -4,40 +4,76 @@ 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:
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@v2 - 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
uses: ./ uses: ./
with: with:
vswhere-path: C:\ProgramData\chocolatey\bin vswhere-path: C:\ProgramData\chocolatey\bin
- name: Setup MSBuild (PATH) - name: Setup MSBuild (PATH)
id: setup_msbuild_path id: setup_msbuild_path
uses: ./ uses: ./
- name: Setup MSBuild (fallback) - name: Setup MSBuild (fallback)
id: setup_msbuild_fallback id: setup_msbuild_fallback
uses: ./ uses: ./
env: env:
PATH: '' PATH: ""
- name: echo msbuild path - name: Setup MSBuild (x64)
run: | if: runner.arch == 'X64'
echo "vswhere-path: ${{ steps.setup_msbuild_explicit.outputs.msbuildPath }}" id: setup_msbuild_path_x64
echo "PATH: ${{ steps.setup_msbuild_path.outputs.msbuildPath }}" uses: ./
echo "Fallback: ${{ steps.setup_msbuild_fallback.outputs.msbuildPath }}" with:
vs-prerelease: true
msbuild-architecture: "x64"
- name: echo MSBuild - name: Setup MSBuild (arm64)
run: msbuild -version if: runner.arch == 'ARM64'
id: setup_msbuild_path_arm64
uses: ./
with:
vs-prerelease: true
msbuild-architecture: "arm64"
- name: Write MSBuild summary
if: always()
shell: pwsh
run: |
@"
## MSBuild setup summary
- Runner label: `${{ matrix.runner }}`
- 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
run: msbuild -version
+74 -14
View File
@@ -1,39 +1,98 @@
# microsoft/setup-msbuild # microsoft/setup-msbuild
You know how handy that 'Visual Studio Developer Command Prompt' is on your local machine? And how it adds several things to `PATH` to allow you to just issue commands like `msbuild` or otherwise? Use this action to setup similar flexibility in your Windows-based GitHub Actions runners. This will let you discover where those tool paths are and automatically add them to the `PATH` environment variables for you so future steps in your Actions workflow can just initiate commands without knowing the full path.
## Usage 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`
## Breaking Changes in v4
Starting with `v4`, the default value of `msbuild-architecture` is no longer always `x86`. When
`msbuild-architecture` is not explicitly specified, the action now **auto-detects** the best
architecture:
- `x64` when running on a 64-bit machine **and** the resolved Visual Studio/MSBuild install is
version 17.0 or later (Visual Studio 2022+, which ships a native 64-bit MSBuild).
- `x86` otherwise (older Visual Studio versions, or 32-bit hosts), matching the previous behavior.
If you explicitly set `msbuild-architecture` (e.g. `x86`, `x64`, or `arm64`), that value is always
respected and this auto-detection does not apply. If your workflow depends on always getting the
32-bit MSBuild by default, set `msbuild-architecture: x86` explicitly.
## Example Usage
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.1 uses: microsoft/setup-msbuild@v4
- name: Build app for release
run: msbuild src\YourProjectFile.csproj -t:rebuild -verbosity:diag -property:Configuration=Release
``` ```
## Specifying specific versions of Visual Studio ## 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 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
There are a few additional parameters that can be set if you need them. These are optional and should only be set if you know that you need them or what you are doing.
### Specifying specific versions of Visual Studio (optional)
You may have a situation where your Actions runner has multiple versions of Visual Studio and you need to find a specific version of the tool. Simply add the `vs-version` input to specify the range of versions to find. If looking for a specific version, specify the minimum and maximum versions as shown in the example below, which will look for just 16.4. You may have a situation where your Actions runner has multiple versions of Visual Studio and you need to find a specific version of the tool. Simply add the `vs-version` input to specify the range of versions to find. If looking for a specific version, specify the minimum and maximum versions as shown in the example below, which will look for just 16.4.
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.1 uses: microsoft/setup-msbuild@v4
with: with:
vs-version: '[16.4,16.5)' vs-version: '[16.4,16.5)'
``` ```
The syntax is the same used for Visual Studio extensions, where square brackets like "[" mean inclusive, and parenthesis like "(" mean exclusive. A comma is always required, but eliding the minimum version looks for all older versions and eliding the maximum version looks for all newer versions. See the [vswhere wiki](https://github.com/microsoft/vswhere/wiki) for more details. The syntax is the same used for Visual Studio extensions, where square brackets like "[" mean inclusive, and parenthesis like "(" mean exclusive. A comma is always required, but eliding the minimum version looks for all older versions and eliding the maximum version looks for all newer versions. See the [vswhere wiki](https://github.com/microsoft/vswhere/wiki) for more details.
## How does this work? ### Use pre-release versions of Visual Studio (optional)
This makes use of the vswhere tool which is a tool is delivered by Microsoft to help in identifying Visual Studio installs and various components. This tool is installed on the hosted Windows runners for GitHub Actions. If you are using a self-hosted runner, you either need to make sure vswhere.exe is in your agent's PATH or specify a full path to the location using:
If you need your Actions runner to target a pre-release version of Visual Studio, simply add the `vs-prerelease` input. This is necessary if you want to run an action on a virtual environment that contains a pre-release version of Visual Studio or self-hosted images that you may have that also have pre-release versions of Visual Studio installed.
```yml ```yml
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.1 uses: microsoft/setup-msbuild@v4
with: with:
vswhere-path: 'C:\path\to\your\tools\' vs-prerelease: true
```
### Specifying MSBuild architecture (optional)
By default (as of `v4`), the action auto-detects the preferred MSBuild architecture: it uses `x64`
when running on a 64-bit machine with Visual Studio/MSBuild 17.0 or later installed, and falls back
to `x86` otherwise. You can override this by explicitly setting the `msbuild-architecture` input.
Valid input values are `x86`, `x64`, and `arm64`. Note that the success of these will rely on the
runner OS.
```yml
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v4
with:
msbuild-architecture: x64
```
## How does this work?
This makes use of the vswhere tool which is a tool delivered by Microsoft to help in identifying Visual Studio installs and various components. This tool is installed on the hosted Windows runners for GitHub Actions. If you are using a self-hosted runner, you either need to make sure vswhere.exe is in your agent's PATH or specify a full path to the location using:
```yml
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v4
with:
vswhere-path: 'C:\path\to\your\tools\'
``` ```
## 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. 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.
## Building this repo ## Building this repo
As with most GitHub Actions, this requires NodeJS development tools. After installing NodeJS, you can build this by executing: As with most GitHub Actions, this requires NodeJS development tools. After installing NodeJS, you can build this by executing:
```bash ```bash
@@ -45,13 +104,14 @@ npm run pack
which will modify/create the /dist folder with the final index.js output which will modify/create the /dist folder with the final index.js output
# Credits # Credits
Thank you to [Warren Buckley](https://github.com/warrenbuckley) for being a core contributor to this Action for the benefit of all developers! Thank you to [Warren Buckley](https://github.com/warrenbuckley) for being a core contributor to this Action for the benefit of all developers!
# Contributing # Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
+54
View File
@@ -0,0 +1,54 @@
import {
MIN_VS_VERSION_FOR_X64,
parseMajorVersion,
resolveMSBuildArchitecture
} from '../src/main'
describe('parseMajorVersion', () => {
it('parses a standard installationVersion string', () => {
expect(parseMajorVersion('17.9.34728.123')).toBe(17)
})
it('parses a single-segment version', () => {
expect(parseMajorVersion('16')).toBe(16)
})
it('trims whitespace before parsing', () => {
expect(parseMajorVersion(' 17.0.0.0 ')).toBe(17)
})
it('returns undefined for an empty string', () => {
expect(parseMajorVersion('')).toBeUndefined()
})
it('returns undefined for a non-numeric string', () => {
expect(parseMajorVersion('not-a-version')).toBeUndefined()
})
})
describe('resolveMSBuildArchitecture', () => {
it('always respects an explicit architecture, regardless of OS/version', () => {
expect(resolveMSBuildArchitecture('x86', true, 17)).toBe('x86')
expect(resolveMSBuildArchitecture('x64', false, 15)).toBe('x64')
expect(resolveMSBuildArchitecture('arm64', true, 17)).toBe('arm64')
})
it('defaults to x64 on a 64-bit host with VS/MSBuild 17+', () => {
expect(resolveMSBuildArchitecture('', true, MIN_VS_VERSION_FOR_X64)).toBe(
'x64'
)
expect(resolveMSBuildArchitecture('', true, 18)).toBe('x64')
})
it('defaults to x86 on a 64-bit host with VS/MSBuild older than 17', () => {
expect(resolveMSBuildArchitecture('', true, 16)).toBe('x86')
})
it('defaults to x86 on a non-64-bit host even with VS/MSBuild 17+', () => {
expect(resolveMSBuildArchitecture('', false, 17)).toBe('x86')
})
it('defaults to x86 when the VS/MSBuild version could not be determined', () => {
expect(resolveMSBuildArchitecture('', true, undefined)).toBe('x86')
})
})
+18
View File
@@ -0,0 +1,18 @@
# See https://github.com/krzema12/github-actions-typing
inputs:
vswhere-path:
type: string
vs-version:
type: string
vs-prerelease:
type: boolean
msbuild-architecture:
type: enum
name: Architecture
allowed-values:
- x86
- x64
- arm64
outputs:
msbuildPath:
type: string
+14 -8
View File
@@ -1,20 +1,26 @@
name: 'setup-msbuild' name: "setup-msbuild"
description: 'Helps set up MSBuild into PATH for later usage.' description: "Helps set up MSBuild into PATH for later usage."
author: 'Microsoft' author: "Microsoft"
branding: branding:
color: purple color: purple
icon: terminal icon: terminal
inputs: inputs:
vswhere-path: vswhere-path:
required: false required: false
description: 'Folder location of where vswhere.exe is located if a self-hosted agent' description: "Folder location of where vswhere.exe is located if a self-hosted agent"
vs-version: vs-version:
description: 'Version of Visual Studio to search; defaults to latest if not specified' description: "Version of Visual Studio to search; defaults to latest if not specified"
required: false
vs-prerelease:
description: "Enable searching for pre-release versions of Visual Studio/MSBuild"
required: false
msbuild-architecture:
description: 'The preferred processor architecture of MSBuild. Can be either "x86", "x64", or "arm64". "x64" is only available from Visual Studio version 17.0 and later. If left unspecified, the action auto-detects the best option: "x64" on 64-bit machines when a Visual Studio/MSBuild 17.0+ install is found, otherwise "x86".'
required: false required: false
outputs: outputs:
msbuildPath: msbuildPath:
description: 'The resulting location of msbuild for your inputs' description: "The resulting location of msbuild for your inputs"
runs: runs:
using: 'node12' using: "node24"
main: 'dist/index.js' main: "dist/index.js"
+29
View File
@@ -0,0 +1,29 @@
# Building a release
This is a quick document to walk through the process of building and releasing.
## Building the version
- Create a new branch [vMajor.Minor.Revision] for the version from `dev`
- Make changes in the new branch
- Build the branch/package
- `npm install`
- `npm run build`
- `npm run pack`
- Prune the dependencies to only production
- `npm prune --production`
- Uncomment `node_modules` in `.gitignore` **for this branch only**
- Commit the changes to the branch
- Push the new version branch
- `git push origin [vMajor.Minor.Revision]`
## Releasing the new version
- Draft a new release to [vMajor.Minor.Revision]
## Update major version tag
If the update is non-breaking and the major version binding you can update the version tag to make the new release available to those binding to the major version tag ([GitHub Actions Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)).
Do this from the version branch after push (using a v1 tag as example only here)
```
git tag -fa v1 -m "Update v1 tag"
git push origin v1 --force
```
+3332 -779
View File
File diff suppressed because it is too large. Load diff
+8326 -57
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "setup-msbuild", "name": "setup-msbuild",
"version": "1.0.1", "version": "4.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"
}, },
@@ -28,7 +28,7 @@
"author": "Microsoft", "author": "Microsoft",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.0", "@actions/core": "^1.10.0",
"@actions/exec": "^1.0.3", "@actions/exec": "^1.0.3",
"@actions/tool-cache": "^1.3.0" "@actions/tool-cache": "^1.3.0"
}, },
@@ -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",
+132 -14
View File
@@ -1,6 +1,7 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as exec from '@actions/exec' import * as exec from '@actions/exec'
import * as fs from 'fs' import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path' import * as path from 'path'
import * as io from '@actions/io' import * as io from '@actions/io'
import {ExecOptions} from '@actions/exec/lib/interfaces' import {ExecOptions} from '@actions/exec/lib/interfaces'
@@ -8,9 +9,58 @@ import {ExecOptions} from '@actions/exec/lib/interfaces'
const IS_WINDOWS = process.platform === 'win32' const IS_WINDOWS = process.platform === 'win32'
const VS_VERSION = core.getInput('vs-version') || 'latest' const VS_VERSION = core.getInput('vs-version') || 'latest'
const VSWHERE_PATH = core.getInput('vswhere-path') const VSWHERE_PATH = core.getInput('vswhere-path')
const ALLOW_PRERELEASE = core.getInput('vs-prerelease') || 'false'
const MSBUILD_ARCH_INPUT = core.getInput('msbuild-architecture')
let MSBUILD_ARCH = MSBUILD_ARCH_INPUT
// The minimum Visual Studio/MSBuild major version that ships a native x64 MSBuild.exe
export const MIN_VS_VERSION_FOR_X64 = 17
// Determines the effective MSBuild architecture to use.
// If the user explicitly specified `msbuild-architecture`, that choice is always respected.
// Otherwise (breaking change as of v4), the action auto-detects and prefers x64 when
// running on a 64-bit OS and the resolved VS/MSBuild installation is version 17.0 or later.
// If the VS version can't be determined, or the host isn't 64-bit, it falls back to x86.
export function resolveMSBuildArchitecture(
explicitArch: string,
isWindows64Bit: boolean,
vsMajorVersion: number | undefined
): string {
if (explicitArch) {
return explicitArch
}
if (
isWindows64Bit &&
vsMajorVersion !== undefined &&
vsMajorVersion >= MIN_VS_VERSION_FOR_X64
) {
return 'x64'
}
return 'x86'
}
// Parses the major version number out of a vswhere `installationVersion` string
// such as "17.9.34728.123". Returns undefined if it cannot be parsed.
export function parseMajorVersion(
installationVersion: string
): number | undefined {
const match = installationVersion.trim().match(/^(\d+)/)
if (!match) {
return undefined
}
const major = parseInt(match[1], 10)
return isNaN(major) ? undefined : major
}
// if a specific version of VS is requested // if a specific version of VS is requested
let VSWHERE_EXEC = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest ' let VSWHERE_EXEC =
'-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '
if (ALLOW_PRERELEASE === 'true') {
VSWHERE_EXEC += ' -prerelease '
}
if (VS_VERSION !== 'latest') { if (VS_VERSION !== 'latest') {
VSWHERE_EXEC += `-version "${VS_VERSION}" ` VSWHERE_EXEC += `-version "${VS_VERSION}" `
} }
@@ -58,6 +108,39 @@ async function run(): Promise<void> {
core.debug(`Full tool exe: ${vswhereToolExe}`) core.debug(`Full tool exe: ${vswhereToolExe}`)
// if the user did not explicitly specify an architecture, auto-detect the
// preferred architecture based on the host OS and the resolved VS/MSBuild version
if (!MSBUILD_ARCH_INPUT) {
let vsMajorVersion: number | undefined
const versionOptions: ExecOptions = {}
versionOptions.listeners = {
stdout: (data: Buffer) => {
const installationVersion = data.toString().trim()
core.debug(`Found installation version: ${installationVersion}`)
const parsed = parseMajorVersion(installationVersion)
if (parsed !== undefined) {
vsMajorVersion = parsed
}
}
}
const versionExec = VSWHERE_EXEC.replace(
'-property installationPath',
'-property installationVersion'
)
await exec.exec(`"${vswhereToolExe}" ${versionExec}`, [], versionOptions)
const isWindows64Bit = os.arch() === 'x64' || os.arch() === 'arm64'
MSBUILD_ARCH = resolveMSBuildArchitecture(
MSBUILD_ARCH_INPUT,
isWindows64Bit,
vsMajorVersion
)
core.info(
`Auto-detected msbuild-architecture: ${MSBUILD_ARCH} (os.arch=${os.arch()}, vsMajorVersion=${vsMajorVersion})`
)
}
let foundToolPath = '' let foundToolPath = ''
const options: ExecOptions = {} const options: ExecOptions = {}
options.listeners = { options.listeners = {
@@ -65,25 +148,42 @@ async function run(): Promise<void> {
const installationPath = data.toString().trim() const installationPath = data.toString().trim()
core.debug(`Found installation path: ${installationPath}`) core.debug(`Found installation path: ${installationPath}`)
let toolPath = path.join( // x64 and arm64 only exist in one possible location, so no fallback probing
installationPath, if (MSBUILD_ARCH === 'x64' || MSBUILD_ARCH === 'arm64') {
'MSBuild\\Current\\Bin\\MSBuild.exe' // x64 is actually amd64 so change to that
) if (MSBUILD_ARCH === 'x64') {
MSBUILD_ARCH = 'amd64'
core.debug(`Checking for path: ${toolPath}`) }
if (!fs.existsSync(toolPath)) { let toolPath = path.join(
toolPath = path.join(
installationPath, installationPath,
'MSBuild\\15.0\\Bin\\MSBuild.exe' `MSBuild\\Current\\Bin\\${MSBUILD_ARCH}\\MSBuild.exe`
) )
core.debug(`Checking for path: ${toolPath}`) core.debug(`Checking for path: ${toolPath}`)
if (!fs.existsSync(toolPath)) { if (!fs.existsSync(toolPath)) {
return return
} }
} foundToolPath = toolPath
} else {
let toolPath = path.join(
installationPath,
'MSBuild\\Current\\Bin\\MSBuild.exe'
)
foundToolPath = toolPath core.debug(`Checking for path: ${toolPath}`)
if (!fs.existsSync(toolPath)) {
toolPath = path.join(
installationPath,
'MSBuild\\15.0\\Bin\\MSBuild.exe'
)
core.debug(`Checking for path: ${toolPath}`)
if (!fs.existsSync(toolPath)) {
return
}
}
foundToolPath = toolPath
}
} }
} }
@@ -95,6 +195,24 @@ async function run(): Promise<void> {
return return
} }
core.info(`Found MSBuild tool path: ${foundToolPath}`)
core.info(`Using MSBuild architecture: ${MSBUILD_ARCH}`)
// try to get the MSBuild version for diagnostic purposes; a failure here shouldn't fail the action
try {
let msbuildVersion = ''
const versionOptions: ExecOptions = {}
versionOptions.listeners = {
stdout: (data: Buffer) => {
msbuildVersion += data.toString()
}
}
await exec.exec(`"${foundToolPath}" -version -nologo`, [], versionOptions)
core.info(`Found MSBuild version: ${msbuildVersion.trim()}`)
} catch (error) {
core.debug(`Unable to determine MSBuild version: ${error.message}`)
}
// extract the folder location for the tool // extract the folder location for the tool
const toolFolderPath = path.dirname(foundToolPath) const toolFolderPath = path.dirname(foundToolPath)
@@ -103,7 +221,7 @@ async function run(): Promise<void> {
// add tool path to PATH // add tool path to PATH
core.addPath(toolFolderPath) core.addPath(toolFolderPath)
core.debug(`Tool path added to PATH: ${toolFolderPath}`) core.info(`Tool path added to PATH: ${toolFolderPath}`)
} catch (error) { } catch (error) {
core.setFailed(error.message) core.setFailed(error.message)
} }