我创建了一个工具,需要您安装csc.exe编译器并将其添加到PATH中。
我想使用 Azure 管道测试程序是否正常工作,但我不知道如何安装并将其添加到 PATH 变量。
我该怎么做(并删除错误'csc' is not recognized as an internal or external command, operable program or batch file.
(?
这是我的管道运行:
https://dev.azure.com/LumitoLuma/GitHub/_build/results?buildId=30&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9
这是代码:
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)"
echo "##vso[task.setvariable variable=PATH]$(JAVA_HOME_11_X64)bin;$(PATH)"
displayName: Setting up Java
- task: NuGetCommand@2
inputs:
command: 'custom'
arguments: 'install Microsoft.Net.Compilers'
- script: install.bat
displayName: Installing JCC
非常感谢您的帮助!
我该怎么做(并删除错误"csc"未被识别为 内部或外部命令,可操作的程序或批处理文件。
窗口托管的代理安装了相应的 VS。由于你使用的是windows-latest
元素,Azure DevOps 将使用为管道安装了 VS2019 的 windows2019。您可以在下面检查Csc.exe
的不同路径:
对于VS2017 Enterprise
:
C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinRoslyncsc.exe
对于VS2019 Enterprise
:
C:Program Files (x86)Microsoft Visual Studio2019EnterpriseMSBuildCurrentBinRoslyncsc.exe
对于.net 4.0 framework
:
C:WindowsMicrosoft.NETFrameworkv4.0.30319csc.exe
解决方法:
先使用多行脚本设置csc.exe
的路径,然后调用install.bat
。
- script: |
SET PATH=%PATH%;"C:Program Files (x86)Microsoft Visual Studio2019EnterpriseMSBuildCurrentBinRoslyn"
install.bat
displayName: 'Run a multi-line script'
使用代理时,可以使用上面的脚本windows-latest
。您可以随时修改路径,以便使用其他代理。另外,区分单行脚本和多行脚本之间的区别:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'