2017-09-29 68 views
0

我嘗試在我的提供程序託管的Sharepoint應用程序的在線tfs上進行簡單構建和發佈。 在使用「Visual Studio Build」任務完成一些NuGet任務之後,我嘗試使用「dotnet發佈」任務發佈它。 問題:我沒有得到任何發佈的文件來進行刪除。 構建似乎成功,但沒有發佈文件。 這裏從日誌中的一些項目:TFS在線構建和發佈

****************************************************************************** 
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 
****************************************************************************** 

這裏是一些CONFIGS: 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) 

我希望有人能幫助我。 謝謝!

+0

您可以在** Visual Studio Build **任務之前使用** NuGet **任務與命令'restore'嗎?如果你將變量'BuildConfiguration'改爲'debug','BuildPlatform'改爲'any cpu'來重新構建呢? –

+0

您可以在構建定義中共享變量設置嗎? –

+0

@ Marina-MSFT:我做了兩次(NuGet恢復和設置變量),但沒有出現積極的結果。 – AJRames

回答

1
  • 對於最初的問題,你可以在變量選項卡中添加變量:

    BuildPlatform = any cpu

    BuildConfiguration = debug

  • 對於第二個問題,參考其位於另一個項目一個不同的git倉庫,你應該把被引用的項目放在你自己的倉庫中。有兩個選項:

    選項1:將項目直接複製到你的git回購

    您可以在您的git回購複製引用的項目,並在自己的git倉庫的新路徑提到。然後提交併將更改推送到遠程,然後您可以成功構建項目。

    選項2:添加其他回購(該refernced項目落戶)爲子模塊/子樹的git倉庫

    您可以使用git submodule add <URL for the other repo>對待回購的子模塊爲自己的回購,也可以使用git subtree add --prefix=foldername <URL for the other repo> branchname將自己的回購庫中的branchname從其他回購添加爲foldername

    然後,您可以從您自己的項目的路徑下引用項目,提交併推送更改,然後您就可以成功構建。

+0

我試過了,它似乎是一個很好的解決方案。但我無法建立我的解決方案。在網上tfs不是本地與msbuild。我收到此錯誤消息,並嘗試了太多...... '「C:\ Program Files文件(x86)\ Microsoft Visual Studio \ 2017 \ Enterprise \ MSBuild \ Microsoft \ VisualStudio \ v15.0 \ SharePointTools \ Microsoft。 VisualStudio.SharePoint.targets(395,5):錯誤:無法加載文件或程序集「Microsoft.VisualStudio.Shell.15.0,版本= 15.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a」或其某個依賴項。找不到指定的文件。「' – AJRames

+0

請檢查'.csproj'文件中的包路徑是否正確。作爲第一個建議在這個鏈接https://stackoverflow.com/questions/46039846/vsts-building-asp-net-core-2-0-compile-error-could-not-locate-the-assembly/46048058#46048058 。 –

+0

我將構建方法從「Visual Studio Build」更改爲MSBuild,並設置參數/ p:VisualStudioVersion = 15 - 使其工作。下一個問題:無法找到子模塊項目(我將項目XXXCommon添加到我的解決方案)。 'd:\ a \ 1 \ s \ MySampleApp \ MySampleApp \ MySampleApp.csproj.metaproj(0,0):錯誤MSB3202:項目文件「d:\ a \ 1 \ s \ .. \ MasterPageApp \ XXXCommon \ XXXCommon .csproj「找不到.' – AJRames