【问题标题】:Build a net core project on TFS 2017在 TFS 2017 上构建一个 net core 项目
【发布时间】:2017-07-06 15:04:23
【问题描述】:

我有一个包含 30 个奇怪项目的解决方案,我正在尝试使用 TFS2017 构建过程进行构建。目前我遇到了一些减速带。

这些项目是在 VS2017 的 RTM 版本中创建的,并且在开发机器上使用 msbuild 构建完全正常。我还在仅运行 dotnet restore 的机器之间转移了项目,以使所有依赖项正常工作。

对非“库存”项目的唯一更改是我使用csproj 中的<TargetFrameworks /> 参数同时定位NET46 和NETCORE。

以下是我为构建项目而设置 TFS 所采取的步骤。步骤 4、5 和 6 是试图让它工作无济于事。

我经常收到的错误是 TFS 找不到 dotnet 可执行文件,您可以在底部的日志输出中看到。

  1. 安装 TFS 2017 - 这是 2015 年的升级版
  2. 在构建服务器上安装 VS 2017,确保已安装所有框架和编译器。
  3. 以构建服务器帐户启动 VS,并按照此处的建议 (https://stackoverflow.com/a/38173701/2302383) 创建和构建一个新的 net core 项目
  4. 设置此处描述的构建 (https://www.visualstudio.com/en-us/docs/build/apps/aspnet/ci/build-aspnet-core)。
  5. 克隆适用于 4.5.2 的现有构建并添加 dotnet restore 命令。
  6. 使用 Net Core 预览构建模板创建构建。

第 4 步和第 5 步的调试日志(使用带有dotnet restore 的 cmd 任务)

2017-07-05T15:11:46.5154865Z ##[warning]File name doesn't indicate a full path to a executable file.
2017-07-05T15:11:46.5174870Z Executing the following command-line. (workingFolder = E:\VsoAgents\agent1\_work\31\s)
2017-07-05T15:11:46.5204867Z dotnet restore
2017-07-05T15:11:46.5214870Z Error message highlight pattern: 
2017-07-05T15:11:46.5214870Z Warning message highlight pattern: 
2017-07-05T15:11:46.5224872Z C:\Windows\system32\cmd.exe /c "dotnet restore"
2017-07-05T15:11:46.5624906Z 'dotnet' is not recognized as an internal or external command,
2017-07-05T15:11:46.5634910Z operable program or batch file.

第 6 步的调试日志(敏感信息已替换为 [[REDACTED]])

2017-07-05T15:15:37.1734770Z Set workingFolder to default: E:\VsoAgents\agent1\tasks\DotNetCoreCLI\0.3.1
2017-07-05T15:15:37.7375119Z ##[debug]agent.workFolder=E:\VsoAgents\agent1\_work
2017-07-05T15:15:37.7385124Z ##[debug]loading inputs and endpoints
2017-07-05T15:15:37.7415122Z ##[debug]loading ENDPOINT_AUTH_$/
2017-07-05T15:15:37.7455138Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
2017-07-05T15:15:37.7465136Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2017-07-05T15:15:37.7475134Z ##[debug]loading ENDPOINT_AUTH_SCHEME_$/
2017-07-05T15:15:37.7485123Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2017-07-05T15:15:37.7495157Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2017-07-05T15:15:37.7505131Z ##[debug]loading INPUT_COMMAND
2017-07-05T15:15:37.7515125Z ##[debug]loading INPUT_PROJECTS
2017-07-05T15:15:37.7525123Z ##[debug]loading INPUT_PUBLISHWEBPROJECTS
2017-07-05T15:15:37.7535143Z ##[debug]loading INPUT_ZIPAFTERPUBLISH
2017-07-05T15:15:37.7545134Z ##[debug]loaded 10
2017-07-05T15:15:38.1705390Z ##[debug]command=restore
2017-07-05T15:15:38.1715403Z ##[debug]projects=**/project.json
2017-07-05T15:15:38.1725392Z ##[debug]arguments=null
2017-07-05T15:15:38.1735387Z ##[debug]publishWebProjects=true
2017-07-05T15:15:38.1745389Z ##[debug]zipAfterPublish=true
2017-07-05T15:15:38.1755406Z ##[debug]check path : E:\VsoAgents\agent1\tasks\DotNetCoreCLI\0.3.1\task.json
2017-07-05T15:15:38.1765390Z ##[debug]set resource file to: E:\VsoAgents\agent1\tasks\DotNetCoreCLI\0.3.1\task.json
2017-07-05T15:15:38.1775415Z ##[debug]system.culture=en-US
2017-07-05T15:15:38.1825417Z ##[debug]Absolute path for pathSegments: C:\Program Files\Python 3.5\Scripts\/dotnet = C:\Program Files\Python 3.5\Scripts\dotnet
2017-07-05T15:15:38.1835414Z ##[debug]Absolute path for pathSegments: C:\Program Files\Python 3.5\/dotnet = C:\Program Files\Python 3.5\dotnet
2017-07-05T15:15:38.1845418Z ##[debug]Absolute path for pathSegments: C:\Windows\system32/dotnet = C:\Windows\system32\dotnet
2017-07-05T15:15:38.1855401Z ##[debug]Absolute path for pathSegments: C:\Windows/dotnet = C:\Windows\dotnet
2017-07-05T15:15:38.1855401Z ##[debug]Absolute path for pathSegments: C:\Windows\System32\Wbem/dotnet = C:\Windows\System32\Wbem\dotnet
2017-07-05T15:15:38.1865430Z ##[debug]Absolute path for pathSegments: C:\Windows\System32\WindowsPowerShell\v1.0\/dotnet = C:\Windows\System32\WindowsPowerShell\v1.0\dotnet
2017-07-05T15:15:38.1875421Z ##[debug]Absolute path for pathSegments: %USERPROFILE%\.dnx\bin/dotnet = E:\VsoAgents\agent1\tasks\DotNetCoreCLI\0.3.1\%USERPROFILE%\.dnx\bin\dotnet
2017-07-05T15:15:38.1885418Z ##[debug]Absolute path for pathSegments: C:\Program Files\Microsoft DNX\Dnvm\/dotnet = C:\Program Files\Microsoft DNX\Dnvm\dotnet
2017-07-05T15:15:38.1895423Z ##[debug]Absolute path for pathSegments: C:\Program Files\Microsoft SQL Server\120\Tools\Binn\/dotnet = C:\Program Files\Microsoft SQL Server\120\Tools\Binn\dotnet
2017-07-05T15:15:38.1905429Z ##[debug]Absolute path for pathSegments: C:\Program Files\Microsoft Office Servers\15.0\Bin\/dotnet = C:\Program Files\Microsoft Office Servers\15.0\Bin\dotnet
2017-07-05T15:15:38.1915417Z ##[debug]Absolute path for pathSegments: C:\Program Files\Babel/dotnet = C:\Program Files\Babel\dotnet
2017-07-05T15:15:38.1925419Z ##[debug]Absolute path for pathSegments: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\/dotnet = C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\dotnet
2017-07-05T15:15:38.1935419Z ##[debug]Absolute path for pathSegments: C:\Program Files\Microsoft SQL Server\110\Tools\Binn\/dotnet = C:\Program Files\Microsoft SQL Server\110\Tools\Binn\dotnet
2017-07-05T15:15:38.1945409Z ##[debug]Absolute path for pathSegments: C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\/dotnet = C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\dotnet
2017-07-05T15:15:38.1955423Z ##[debug]Absolute path for pathSegments: C:\Program Files\Microsoft\Web Platform Installer\/dotnet = C:\Program Files\Microsoft\Web Platform Installer\dotnet
2017-07-05T15:15:38.1955423Z ##[debug]Absolute path for pathSegments: C:\Program Files (x86)\NuGet/dotnet = C:\Program Files (x86)\NuGet\dotnet
2017-07-05T15:15:38.1965419Z ##[debug]Absolute path for pathSegments: C:\Program Files\Microsoft SQL Server\130\Tools\Binn\/dotnet = C:\Program Files\Microsoft SQL Server\130\Tools\Binn\dotnet
2017-07-05T15:15:38.1975423Z ##[debug]Absolute path for pathSegments: C:\Users\[[REDACTED]]\.dnx\bin/dotnet = C:\Users\[[REDACTED]]\.dnx\bin\dotnet
2017-07-05T15:15:38.1985426Z ##[debug]check path : null
2017-07-05T15:15:38.2065429Z ##[debug]task result: Failed
2017-07-05T15:15:38.2245432Z ##[error]Error: Failed which: Not found dotnet: null

【问题讨论】:

  • 安装VS后是否重启了构建代理服务?它可能没有接收到您系统的 PATH 环境变量的更改。还要检查此变量是否在系统范围内设置,不仅适用于您安装 VS 的用户。
  • “嗨,迈克,你试过关掉它然后再打开吗?” ... :| - 谢谢@MartinUllrich,原来我是个白痴。
  • @starain-MSFT 我实际上只是重新启动了整台机器。之后一切都很完美。
  • 您可以发布答案。
  • 将其添加为答案。 @MichaelCoxon 你绝对不是一个白痴 - 猜猜我是如何这么快提出这个建议的;)(或者至少这让我们两个人)

标签: tfs .net-core


【解决方案1】:

代理在启动时扫描PATH 和其他与环境相关的配置,因此您需要重新启动代理服务才能使与环境相关的更改生效。更完整的方法是重新启动机器,这将允许通过安装/更新组件所做的所有系统范围的更改生效。

【讨论】:

    猜你喜欢
    • 2018-09-15
    • 2018-01-31
    • 1970-01-01
    • 2017-10-27
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多