【问题标题】:How to specifiy --project in the "dotnet run" build step如何在“dotnet run”构建步骤中指定 --project
【发布时间】:2017-10-23 13:29:19
【问题描述】:

这是我的构建步骤

这是生成的日志

2017-10-23T12:46:42.8958745Z ##[section]Starting: dotnet run Tools
2017-10-23T12:46:42.8958745Z ==============================================================================
2017-10-23T12:46:42.8958745Z Task         : .NET Core
2017-10-23T12:46:42.8958745Z Description  : Build, test and publish using dotnet core command-line.
2017-10-23T12:46:42.8958745Z Version      : 1.0.2
2017-10-23T12:46:42.8958745Z Author       : Microsoft Corporation
2017-10-23T12:46:42.8958745Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2017-10-23T12:46:42.8958745Z ==============================================================================
2017-10-23T12:46:43.3968589Z [command]"C:\Program Files\dotnet\dotnet.exe" run d:\a\1\s\Tools\Tools.csproj --configuration test
2017-10-23T12:46:43.5008554Z Couldn't find a project to run. Ensure a project exists in d:\a\1\s, or pass the path to the project using --project.
2017-10-23T12:46:43.5138548Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2017-10-23T12:46:43.5138548Z ##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\Tools\Tools.csproj
2017-10-23T12:46:43.5168542Z ##[section]Finishing: dotnet run Tools

问题是,任务应该运行的项目不是通过--project 参数传递的。但是如何使用构建步骤提供的选项来做到这一点?

【问题讨论】:

  • 工作区映射(获取源)的设置是什么?你的项目的结构是什么? (例如 Tools 文件夹中的 Tools.csproj)提供屏幕截图。

标签: .net-core azure-devops


【解决方案1】:

假设您有一个 .Net Core 控制台应用程序,在 Git 存储库中存储了以下内容:

reporoot/
reporoot/Program.cs
reporoot/temp.csproj

要使用 .net 运行它,请向 .Net Core 任务提供以下参数:

  • 命令:运行
  • 项目:*.csproj
  • 参数 -p temp.csproj

这是一个示例输出:

2017-10-23T18:14:22.2924112Z ##[debug]C:\Program Files\dotnet\dotnet.exe arg: run 2017-10-23T18:14:22.2924112Z ##[debug]C:\Program Files\dotnet\dotnet.exe arg: d:\a\1\s\temp.csproj 2017-10-23T18:14:22.2924112Z ##[debug]C:\Program Files\dotnet\dotnet.exe arg: -p temp.csproj 2017-10-23T18:14:22.2934125Z ##[debug]exec tool: C:\Program Files\dotnet\dotnet.exe 2017-10-23T18:14:22.2934125Z ##[debug]arguments: 2017-10-23T18:14:22.2934125Z ##[debug] run 2017-10-23T18:14:22.2934125Z ##[debug] d:\a\1\s\temp.csproj 2017-10-23T18:14:22.2934125Z ##[debug] -p 2017-10-23T18:14:22.2934125Z ##[debug] temp.csproj 2017-10-23T18:14:22.2943933Z [command]"C:\Program Files\dotnet\dotnet.exe" run d:\a\1\s\temp.csproj -p temp.csproj 2017-10-23T18:14:36.1934899Z Hello World!

【讨论】:

  • 不起作用:[command]"C:\Program Files\dotnet\dotnet.exe" run d:\a\1\s\Tools\Tools.csproj -p Tools.csproj --configuration test 失败并显示MSBUILD : error MSB1009: Project file does not exist. Switch: Tools.csproj
  • 注意你的项目在Tools目录下,-p参数也需要它
  • 我的 csproj 文件位于 reporoot/source 下,所以我的命令是“dotnet build -p source/charttools.csproj --no-restore”“dotnet test -p source/charttools.csproj --no- build --verbosity normal" 但是我得到同样的错误,告诉我工作目录中没有项目,我需要指定它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-04
  • 2020-06-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多