简体   繁体   中英

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

I have 2 Web Projects in my Solution. When I build them using Build SOlution Task in Build Pipeline, I pass the MS Build Params as "/p:PackageAsSingleFile=true". After Build completes, I get both projects as Zip Files as 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.

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. After that 2nd Project builds, thereby leaving only one Project's Build output in final Drop folder.

How to override this event or stop it from deleting? Microsoft Docs website has nothing about this. Very poor documentation.


2019-06-03T18:30:35.8155256Z CleanWebsitesPackageCore:
2019-06-03T18:30:35.8155396Z Removing directory "d:\\a\\4\\b\\Archive".
2019-06-03T18:30:36.2608007Z CleanWebsitesPackage:
2019-06-03T18:30:36.2608223Z Deleting file
"d:\\a\\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.2619115Z Deleting file "d:\\a\\4\\b\\Archive.deploy-readme.txt".
2019-06-03T18:30:36.2623864Z Deleting file
"d:\\a\\4\\b\\Archive.SetParameters.xml".


I want the Build to produce 2 folders with Build output for each and not call Delete.

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

When we check the Microsoft.Web.Publishing.targets file, we could find following scripts:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM