【问题标题】:TFS Online Build and publishTFS 在线构建和发布
【发布时间】:2018-03-11 14:17:41
【问题描述】:

我尝试为我的提供商托管的共享点应用程序在 tfs 上进行简单的构建和发布。 在完成一些 NuGet 任务后,我使用“Visual Studio Build”任务,之后我尝试使用“dotnet publish”任务发布它。 问题:我没有得到任何已发布的文件来进行删除。 构建似乎是成功的,但没有发布文件。 以下是日志中的一些项目:

******************************************************************************
Starting: Build solution **\*.sln
******************************************************************************
==============================================================================
Task         : Visual Studio Build
Description  : Build with MSBuild and set the Visual Studio version property
Version      : 1.120.0
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613727)
==============================================================================
"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.120.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
The 'Restore NuGet Packages' option is deprecated. To restore NuGet packages in your build, add a NuGet Installer task to your build definition.
"C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.123.0\externals\nuget\NuGet.exe" restore "d:\a\1\s\MySampleApp.sln" -NonInteractive
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
All packages listed in packages.config are already installed.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "d:\a\1\s\MySampleApp.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.120.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=09f9adae-970e-4be0-bcfa-d953d972e1ed|SolutionDir=d:\a\1\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.120.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="d:\a\1\a//" /p:platform="$(BuildPlatform)" /p:configuration="$(BuildConfiguration)" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_bf1ff99a-938b-4307-8b5d-344c8a51e178_build_197_36516"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 9/29/2017 3:51:58 PM.
d:\a\1\s\MySampleApp.sln.metaproj(0,0): Warning MSB4126: The specified solution configuration "$(BuildConfiguration)|$(BuildPlatform)" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.
Project "d:\a\1\s\MySampleApp.sln" on node 1 (default targets).
d:\a\1\s\MySampleApp.sln.metaproj : warning MSB4126: The specified solution configuration "$(BuildConfiguration)|$(BuildPlatform)" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [d:\a\1\s\MySampleApp.sln]
Done Building Project "d:\a\1\s\MySampleApp.sln" (default targets).
Build succeeded.
"d:\a\1\s\MySampleApp.sln" (default target) (1) ->
(ValidateSolutionConfiguration target) -> 
  d:\a\1\s\MySampleApp.sln.metaproj : warning MSB4126: The specified solution configuration "$(BuildConfiguration)|$(BuildPlatform)" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [d:\a\1\s\MySampleApp.sln]
    1 Warning(s)
    0 Error(s)
Time Elapsed 00:00:00.14
******************************************************************************
Finishing: Build solution **\*.sln
******************************************************************************
******************************************************************************
Starting: dotnet restore
******************************************************************************
==============================================================================
Task         : .NET Core
Description  : Build, test and publish using dotnet core command-line.
Version      : 1.0.2
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
Project file(s) matching the specified pattern were not found.
******************************************************************************
Finishing: dotnet restore
******************************************************************************
******************************************************************************
Starting: dotnet publish
******************************************************************************
==============================================================================
Task         : .NET Core
Description  : Build, test and publish using dotnet core command-line.
Version      : 1.0.2
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
"C:\Program Files\dotnet\dotnet.exe" publish d:\a\1\s\MySampleApp\MySampleAppWeb\MySampleAppWeb.csproj -c $(build.configuration) -o d:\a\1\a\pub\MySampleAppWeb
C:\Program Files\dotnet\sdk\2.0.0\NuGet.targets(782,5): warning MSB3202: The project file "d:\a\1\MasterPageApp\XXXXXCommon\XXXXXCommon.csproj" was not found. [d:\a\1\s\MySampleApp\MySampleAppWeb\MySampleAppWeb.csproj]
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
******************************************************************************
Finishing: dotnet publish
******************************************************************************
******************************************************************************
Starting: Publish Artifact: drop
******************************************************************************
==============================================================================
Task         : Publish Build Artifacts
Description  : Publish Build artifacts to the server or a file share
Version      : 1.120.1
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=708390)
==============================================================================
Directory 'd:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.
******************************************************************************
Finishing: Publish Artifact: drop
******************************************************************************
******************************************************************************
Starting: Post Job Cleanup
******************************************************************************
Cleaning any cached credential from repository: MySampleApp (Git)
git remote set-url origin https://XXXXX.visualstudio.com/MyProject%20Development/_git/MySampleApp
git remote set-url --push origin https://XXXXX.visualstudio.com/MyProject%20Development/_git/MySampleApp
******************************************************************************
Finishing: Post Job Cleanup
******************************************************************************
******************************************************************************
Finishing: Phase 1
******************************************************************************

这里有一些配置: MSBild 参数:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)//"

dotnet 发布参数:

-c $(build.configuration) -o $(Build.ArtifactStagingDirectory)/pub

发布构建工件:

$(Build.ArtifactStagingDirectory)

我希望有人可以帮助我。 谢谢!

【问题讨论】:

  • 能否在 Visual Studio Build 任务之前使用带有命令 restoreNuGet 任务?如果您将变量BuildConfiguration 更改为debug,将BuildPlatform 更改为any cpu 以重新构建呢?
  • 你能在你的构建定义中分享变量设置吗?
  • @Marina-MSFT:我都做了(NuGet 恢复和变量设置),但没有得到肯定的结果。
  • @Eddie-MSFT: system.debug = false。另外 3 个是标准变量(collectionId、teamProject、definitionId)。我没有手动设置任何变量。
  • 现在我有以下错误(我引用了我的另一个项目)。我怎样才能在这个构建中实现它? 2017-10-03T07:43:34.9092084Z ##[error]d:\a\1\s\MySampleApp.sln.metaproj(0,0):错误 MSB3202:项目文件“d:\a\1\s \..\MasterPageApp\XXXCommon\XXXCommon.csproj" 未找到。

标签: tfs continuous-integration azure-devops tfsbuild


【解决方案1】:
  • 对于初始问题,您可以在变量选项卡中添加变量:

    BuildPlatform=any cpu

    BuildConfiguration=debug

  • 对于第二个问题引用位于不同 git repo 中的另一个项目,您应该将引用的项目放在您自己的 repo 下。有两种选择:

    选项 1:将项目直接复制到您的 git 存储库

    您可以将引用的项目复制到您的 git repo 中,并在您自己的 git repo 中使用新路径进行引用。然后提交并将更改推送到远程,然后您就可以成功构建您的项目了。

    选项 2:将另一个 repo(引用的项目所在的位置)添加为您的 git repo 的子模块/子树

    您可以使用git submodule add <URL for the other repo> 将repo 视为您自己repo 的子模块,或者您可以使用git subtree add --prefix=foldername <URL for the other repo> branchname 将来自其他repo 的branchname 添加为您自己的repo 中的foldername

    然后你可以从自己的项目中引用该路径下的项目,提交并推送更改,就可以构建成功了。

【讨论】:

  • 我试过了,似乎是一个不错的解决方案。但我无法构建我的解决方案。在 tfs online 上,在本地使用 msbuild 都不是。我收到此错误消息并尝试了很多......"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets(395,5): Error : Could not load file or assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
  • 请检查.csproj文件中的包路径是否正确。作为此链接中的第一个建议stackoverflow.com/questions/46039846/…
  • 我将构建方法从“Visual Studio Build”更改为 MSBuild,并设置了参数 /p:VisualStudioVersion=15 - 使其工作。下一个问题:找不到子模块项目(我将项目 XXXCommon 添加到我的解决方案中)。 d:\a\1\s\MySampleApp\MySampleApp\MySampleApp.csproj.metaproj(0,0): Error MSB3202: The project file "d:\a\1\s\..\MasterPageApp\XXXCommon\XXXCommon.csproj" was not found.
  • 好的。我通过使用子模块git submodule add ../MasterPageApp/ MasterPageApp的相对路径解决了它然后我将项目添加到MySampleApp并在线tfs中说它应该只构建MySampleApp。
猜你喜欢
  • 2018-07-24
  • 1970-01-01
  • 1970-01-01
  • 2013-05-19
  • 1970-01-01
  • 2014-04-18
  • 2015-07-31
  • 1970-01-01
  • 2018-07-04
相关资源
最近更新 更多