简体   繁体   English

如何在Build Pipeline中覆盖MsBuild Targets“Build Solution”任务?

[英]How to override MsBuild Targets “Build Solution” Task in Build Pipeline?

I have 2 Web Projects in my Solution. 我的解决方案中有2个Web项目。 When I build them using Build SOlution Task in Build Pipeline, I pass the MS Build Params as "/p:PackageAsSingleFile=true". 当我使用Build Pipeline中的Build SOlution Task构建它们时,我将MS Build Params传递为“/ p:PackageAsSingleFile = true”。 After Build completes, I get both projects as Zip Files as epxected. 构建完成后,我将两个项目作为Zip文件获取为epxected。 But when I modify the Param as "/p:PackageAsSingleFile=false" and reBuild, I get only the second project (in Build order) in the drop folder. 但是当我将Param修改为“/ p:PackageAsSingleFile = false”并重新构建时,我只获得drop文件夹中的第二个项目(在构建顺序中)。

When I compared the Log file of both cases I found the root cause. 当我比较两种情况的日志文件时,我找到了根本原因。 When I set param as "/p:PackageAsSingleFile=false", I see that after the First Project is built, the "CleanWebsitesPackageCore" Event takes place there by deleting the First Project's Build Output in Archive file. 当我将param设置为“/ p:PackageAsSingleFile = false”时,我看到在构建第一个项目之后,通过删除存档文件中的第一个项目的构建输出来进行“CleanWebsitesPackageCore”事件。 After that 2nd Project builds, thereby leaving only one Project's Build output in final Drop folder. 在第二个项目构建之后,从而在最终的Drop文件夹中只留下一个Project的Build输出。

How to override this event or stop it from deleting? 如何覆盖此事件或阻止其删除? Microsoft Docs website has nothing about this. Microsoft Docs网站对此一无所知。 Very poor documentation. 文件很差。


2019-06-03T18:30:35.8155256Z CleanWebsitesPackageCore: 2019-06-03T18:30:35.8155256Z CleanWebsitesPackageCore:
2019-06-03T18:30:35.8155396Z Removing directory "d:\\a\\4\\b\\Archive". 2019-06-03T18:30:35.8155396Z删除目录“d:\\ a \\ 4 \\ b \\ Archive”。
2019-06-03T18:30:36.2608007Z CleanWebsitesPackage: 2019-06-03T18:30:36.2608007Z CleanWebsitesPackage:
2019-06-03T18:30:36.2608223Z Deleting file 2019-06-03T18:30:36.2608223Z删除文件
"d:\\a\\4\\b\\Archive.SourceManifest.xml". “d:\\一个\\ 4 \\ B \\ Archive.SourceManifest.xml”。
2019-06-03T18:30:36.2614576Z Deleting file "d:\\a\\4\\b\\Archive.deploy.cmd". 2019-06-03T18:30:36.2614576Z删除文件“d:\\ a \\ 4 \\ b \\ Archive.deploy.cmd”。
2019-06-03T18:30:36.2619115Z Deleting file "d:\\a\\4\\b\\Archive.deploy-readme.txt". 2019-06-03T18:30:36.2619115Z删除文件“d:\\ a \\ 4 \\ b \\ Archive.deploy-readme.txt”。
2019-06-03T18:30:36.2623864Z Deleting file 2019-06-03T18:30:36.2623864Z删除文件
"d:\\a\\4\\b\\Archive.SetParameters.xml". “d:\\一个\\ 4 \\ B \\ Archive.SetParameters.xml”。


I want the Build to produce 2 folders with Build output for each and not call Delete. 我希望Build为每个文件夹生成2个带有Build输出的文件夹,而不是调用Delete。

How to override MsBuild Targets “Build Solution” Task in Build Pipeline? 如何在Build Pipeline中覆盖MsBuild Targets“Build Solution”任务?

When we check the Microsoft.Web.Publishing.targets file, we could find following scripts: 当我们检查Microsoft.Web.Publishing.targets文件时,我们可以找到以下脚本:

  <PropertyGroup>
    <CleanWebsitesPackageCoreDependsOn Condition="'$(CleanWebsitesPackageCoreDependsOn)' == ''">
      GenerateMsDeployManifestSettings;
    </CleanWebsitesPackageCoreDependsOn>
  </PropertyGroup>

  <Target Name="CleanWebsitesPackageCore" DependsOnTargets="$(CleanWebsitesPackageCoreDependsOn)">
    <!--Assertion check-->
    <CheckItemsCount Items="@(_MSDeployPackageLocation)" Condition="$(EnablePackageProcessLoggingAndAssert)">
      <Output TaskParameter="Count" PropertyName="_InternalItemsCount" />
    </CheckItemsCount>

So, to resolve this issue, we could try to disable this target to executed. 因此,要解决此问题,我们可以尝试禁用此目标以执行。 You can try to add the parameter /p:CleanWebsitesPackageCoreDependsOn=False in the MSBuild Arguments. 您可以尝试在MSBuild参数中添加参数/p:CleanWebsitesPackageCoreDependsOn=False

If above not resolve your question, please share your build definition to us or you could share a sample demo to us, so that we could reproduce this issue and find the reason for this issue. 如果上面没有解决您的问题,请与我们分享您的构建定义,或者您可以向我们分享示例演示,以便我们可以重现此问题并找到此问题的原因。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 管道中的.NetCore、VisualStudio 构建和 MSBuild 任务之间的区别? - Difference between .NetCore, VisualStudio build and MSBuild task in Azure Pipeline? Visual Studio 2022 未在 devops 构建解决方案管道任务中列出 - Visual Studio 2022 not listed in devops build solution pipeline task 如何强制执行 Azure 管道构建任务? - How to make a Azure Pipeline Build task mandatory? Azure DevOps构建管道:从MsBuild.exe解决方案创建NuGet程序包 - Azure DevOps Build Pipeline: Create NuGet Package from MsBuild.exe Solution 如何将构建管道作为发布管道中的任务进行排队? - How to queue build pipeline as task from release pipeline? 如何在msbuild内置目标(如Build / Rebuild)上设置条件? - How do I put a condition on msbuild built-in targets like Build/Rebuild? 构建管道中 AzurePowershell 任务中的 IF 条件 - IF condition in AzurePowershell task in build pipeline 如何在 YAML 管道中构建特定项目的 select 解决方案文件? - How to select Solution file of a particular project to build in YAML pipeline? 如何使用 powershell 脚本启用或禁用构建管道中的任务 - How to enable or disable a task in build pipeline using powershell script VSTS构建管道如何共享docker任务的output? - VSTS build pipeline how to share output of a docker task?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM