I am extending a Windows application that analyzes C# code and detects various smells. The extension will also work within GitHub Action. The intent is to analyze the committed code as part of CI cycle using this application. The application is a console application based on .NET framework 4.7.2.
To integrate the application with the GitHub Actions, I put together a yml file (produced below). Everything else works fine but the application fails with the following message.
The tools version "15.0" is unrecognized. Available tools versions are "2.0", "3.5", "4.0".
I am using the following yml file. As you may observe, I have added MSBuild to the path, set the environment variable to use version 15, set environment variable VSINSTALLDIR to the Visual Studio 2017 installation, and installed build tools. However, I still get the error. What am I missing?
Name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
# Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/[email protected]
with:
vs-version: '15.0'
- name: env var
run: echo ::set-env name=VSINSTALLDIR::"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"
- name: checking sdk
run: echo ::set-env name=VisualStudioVersion::"15.0"
- name: install build tools
run: |
curl.exe -o buildtools.exe https://download.visualstudio.microsoft.com/download/pr/3e542575-929e-4297-b6c6-bef34d0ee648/639c868e1219c651793aff537a1d3b77/vs_buildtools.exe
.\buildtools.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.UniversalBuildTools --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.VCTools
# Runs a set of commands using the runners shell
- name: download DesigniteConsole.exe
run: |
curl.exe -o DesigniteConsole.zip "<download link>"
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('DesigniteConsole.zip','.');}"
- name: Run Designite application (it utilizes GitHub secrets and environment variables)
run: |
.\DesigniteConsole\DesigniteConsole.exe -ci -repo ${{github.repository}} -pat ${{ secrets.PAT }} -k ${{ secrets.D_KEY }}
cat Designite_output/DesigniteAnalysis.xml
After so many hit-and-try attempts, I was able to make it run. Here is the working yaml.
Name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Run a one-line script
run: Invoke-webrequest -uri https://aka.ms/vs/15/release/vs_buildtools.exe -OutFile vs_buildtools.exe
shell: powershell
- name: install build tools
run: .\vs_buildtools.exe --wait --norestart --passive --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.MSBuildTools
shell: cmd
# Runs a set of commands using the runners shell
- name: download DesigniteConsole.exe
run: |
curl.exe -o DesigniteConsole.zip "<download link>"
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('DesigniteConsole.zip','.');}"
- name: Run Designite application (it utilizes GitHub secrets and environment variables)
run: |
.\DesigniteConsole\DesigniteConsole.exe -ci -repo ${{github.repository}} -pat ${{ secrets.PAT }} -k ${{ secrets.D_KEY }}
cat Designite_output/DesigniteAnalysis.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With