我们的主要产品组合中有 20 多个解决方案(超过 880 个项目),并且我们有一组运行良好的复杂构建脚本,但我们正在尝试从 msbuild 管道中自动恢复 nuget 包。目前,这是通过手动调用 nuget 来恢复包来完成的。
根据https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets我应该能够运行此命令并运行恢复:
# works
& $script:msBuildPath $solutionName /t:build /v:q /clp:ErrorsOnly /nologo /p:...
# doesn't works
& $script:msBuildPath $solutionName /t:restore,build /v:q /clp:ErrorsOnly /nologo /p:...
但是,当我将其添加restore,
到上面时,它会引发错误
MSB4057: The target "restore" does not exist in the project
我从哪里开始研究以了解为什么找不到这个目标?我们主要在 VS 2015 和 .NET 4.6.2 上,所以目前我不适合 VS2017 的任何特定内容。
如果我省略/v:q
and/clp:ErrorsOnly
标志,我会得到这个(稍微清理过的解决方案/项目名称和路径)
PS Z:\git\company> build c
building Common\Common.sln
Build started 11/15/2017 11:08:54 AM.
1>Project "Z:\git\company\Common\Common.sln" on node 1 (restore;build target(s)).
1>ValidateSolutionConfiguration:
Building solution configuration "DEBUG|Any CPU".
1>Z:\git\company\Common\Common.sln.metaproj : error MSB4057: The target "restore" does not exist in the project. [Z:\git\company\Common\Common.sln]
1>Done Building Project "Z:\git\company\Common\Common.sln" (restore;build target(s)) -- FAILED.
Build FAILED.
"Z:\git\company\Common\Common.sln" (restore;build target) (1) ->
Z:\git\company\Common\Common.sln.metaproj : error MSB4057: The target "restore" does not exist in the project. [Z:\git\company\Common\Common.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.03
runBuildPackage : ... failed
At Z:\git\company\psincludes\buildFunctions.ps1:11 char:5
+ runBuildPackage "Common\Common.sln"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,runBuildPackage
msbuild failed
At Z:\git\company\psincludes\buildInternals.ps1:63 char:21
+ throw "msbuild failed";
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (msbuild failed:String) [], RuntimeException
+ FullyQualifiedErrorId : msbuild failed
我意识到其中一些是我们的内部工具,我只是觉得没有必要掩盖那部分。
根据“互联网”,这应该只是作为构建过程的一部分“免费”,我不确定我们在此处的 csproj 文件中缺少什么。