TFS在线构建和发布

时间:2017-09-29 16:04:55

标签: tfs continuous-integration azure-devops tfsbuild

我尝试在tfs在线创建一个简单的构建并在我的提供者托管的sharepoint应用程序上发布。 在一些NuGet任务之后,我正在使用“Visual Studio Build”任务,之后我尝试使用“dotnet publish”任务发布它。 问题:我没有得到任何已发布的文件来进行删除。 Build似乎是成功的,但没有发布文件。 这里有一些日志中的项目:

******************************************************************************
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 publish Arguments:

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

发布构建工件:

$(Build.ArtifactStagingDirectory)

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

1 个答案:

答案 0 :(得分:1)

  • 对于初始问题,您可以在变量选项卡中添加变量:

    BuildPlatform = any cpu

    BuildConfiguration = debug

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

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

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

    选项2:将其他仓库(引用项目所在位置)添加为git仓库的子模块/子树

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

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