在GitHub Actions中执行Windows应用程序错误:无法识别工具版本“ 15.0”

问题描述

我正在扩展Windows应用程序,该应用程序分析C#代码并检测各种气味。该扩展还将在GitHub Action中运行。目的是使用此应用程序分析提交的代码,并将其作为CI周期的一部分。该应用程序是基于.NET Framework 4.7.2的控制台应用程序。

为了将应用程序与GitHub Actions集成,我整理了一个yml文件(如下所示)。一切正常,但应用程序失败并显示以下消息。

The tools version "15.0" is unrecognized. Available tools versions are "2.0","3.5","4.0". 

我正在使用以下yml文件。如您所见,我已将MSBuild添加到路径中,将环境变量设置为使用版本15,将环境变量VSINSTALLDIR设置为Visual Studio 2017安装,并安装了构建工具。但是,我仍然会收到错误消息。我想念什么?

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/setup-msbuild@v1.0.0
      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

解决方法

希望我能正确理解您的问题。

查看此问题 https://github.com/microsoft/setup-msbuild/issues/18#issuecomment-644485409

托管代理仅具有最新版本的VS。如果发生更改和/或您拥有自托管代理,则版本标记确实存在。

https://github.com/microsoft/setup-msbuild/issues/5#issue-588501457

最近,在指定版本参数时,运行程序未能执行此引擎。 解决方法:删除该操作对vs-version参数的任何使用,并将其默认设置为最新。

,

经过多次尝试,我得以使其运行。这是工作中的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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...