Skip to content

Fix DotNetCoreCLI@2 zipAfterPublish to preserve ZIP file location #21045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 22, 2025

Issue

When using the DotNetCoreCLI@2 task with zipAfterPublish set to true, the task was removing the produced ZIP file from its original location and placing it inside a newly created directory with the same name as the output path. This resulted in a confusing directory structure where the artifact was an empty folder containing a ZIP file, rather than just the ZIP file itself.

Solution

The fix removes the unnecessary directory creation and file moving logic in the zipAfterPublishIfRequired method:

// Old behavior - created unnecessary directory structure
if (moveZipToOutputSource) {
    fs.mkdirSync(outputSource);
    fs.renameSync(outputTarget, path.join(outputSource, path.basename(outputTarget)));
}

Now when zipAfterPublish is true, the ZIP file remains at the original location where it was created, resulting in a simpler and more intuitive output.

Testing

Created a new test case to ensure the zipAfterPublish functionality works as expected.

Fixes #20974.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)
  • pkgs.dev.azure.com
    • Triggering command: npm install (dns block)
    • Triggering command: npm install @types/node @types/mocha @types/q @types/ltx @types/uuid @types/semver (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: sanjuyadav24 <185911972+sanjuyadav24@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [BUG]: DotNetCoreCLI@2 publish removes the produced ZIP file and leaves the ZIP source files in place Fix DotNetCoreCLI@2 zipAfterPublish to preserve ZIP file location May 22, 2025
@Copilot Copilot AI requested a review from sanjuyadav24 May 22, 2025 12:59
Copilot finished work on behalf of sanjuyadav24 May 22, 2025 12:59
fs.mkdirSync(outputSource);
fs.renameSync(outputTarget, path.join(outputSource, path.basename(outputTarget)));
}
// When moveZipToOutputSource is true and zipAfterPublish is true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this might be expected behavior for some customers, can we make this feature flag based to control the use case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right. I've implemented this as a feature flag to preserve backwards compatibility. Added a new zipAfterPublishCreateDirectory parameter (defaults to true for legacy behavior) that controls whether the ZIP file is moved into a subdirectory or left at the original location. This way customers can choose the behavior that works best for their use case. Commit: aab9dd2

Co-authored-by: sanjuyadav24 <185911972+sanjuyadav24@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jun 11, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 03nvsblobprodwcus014.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 055vsblobprodwcus02.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 1g1vsblobprodwcus01.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 3eavsblobprodwcus03.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 3zgvsblobprodwcus024.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 40qvsblobprodwcus022.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 4fdvsblobprodwcus012.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 5tbvsblobprodwcus06.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 61cvsblobprodwcus010.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 73dvsblobprodwcus07.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 8usvsblobprodwcus011.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 9owvsblobprodwcus020.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • arpvsblobprodwcus017.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • crcvsblobprodwcus021.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • fslvsblobprodwcus015.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • grnvsblobprodwcus04.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • k92vsblobprodwcus08.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • mnzvsblobprodwcus05.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • pl8vsblobprodwcus09.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • uubvsblobprodwcus018.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • vwmvsblobprodwcus016.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • x4wvsblobprodwcus013.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • xg1vsblobprodwcus019.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • xlkvsblobprodwcus023.vsblob.vsassets.io
    • Triggering command: npm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of sanjuyadav24 June 11, 2025 07:00
if (moveZipToOutputSource) {

// Check if we should create directory for ZIP output (legacy behavior)
if (moveZipToOutputSource && this.zipAfterPublishCreateDirectory) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this change is asking customer to provide this input, make it a feature flag based check tl.getPipelineFeature

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented the change to use a pipeline feature flag instead of customer input. The zipAfterPublishCreateDirectory parameter has been removed and replaced with tl.getPipelineFeature('DotNetCoreCLIZipAfterPublishSimplified'). When the feature flag is enabled, it uses the simplified behavior (no directory creation), and when disabled it uses the legacy behavior. This maintains backward compatibility while allowing service-level control. Commit: 9d3ea7d

…y behavior

Co-authored-by: sanjuyadav24 <185911972+sanjuyadav24@users.noreply.github.com>
Copilot finished work on behalf of sanjuyadav24 June 11, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: DotNetCoreCLI@2 publish removes the produced ZIP file and leaves the ZIP source files in place
2 participants