Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 6, 2025

The DotNetCoreCLI@2 task's test command was inconsistently handling missing project files compared to other commands. When no project files matched the specified pattern, the test command would only log a warning and succeed, while other commands (build, restore, pack, push) would properly fail the task.

This dangerous behavior could lead to scenarios where teams believe their tests passed when they actually never ran due to typos in project file paths or missing files.

Problem

- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: 'test'
    projects: garbage.dll  # Typo or non-existent file

Before this fix:

  • Task succeeds with warning: "Project file(s) matching the specified pattern were not found."
  • Pipeline continues, giving false confidence that tests passed

After this fix:

  • Task fails with error: "Project file(s) matching the specified pattern were not found."
  • Pipeline stops, alerting developers to the configuration issue

Solution

Changed the executeTestCommand() method in dotnetcore.ts to throw an error instead of logging a warning when no project files are found, making it consistent with other dotnet commands.

// Before
if (projectFiles.length === 0) {
    tl.warning(tl.loc('noProjectFilesFound'));
    return;
}

// After  
if (projectFiles.length === 0) {
    throw tl.loc('noProjectFilesFound');
}

Also updated the corresponding test case to expect task failure instead of success.

This ensures all DotNetCoreCLI commands now behave consistently when project files are not found, preventing silent failures that could mask configuration errors.

Fixes #21193.

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)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • 40qvsblobprodwcus022.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 4fdvsblobprodwcus012.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • 5tbvsblobprodwcus06.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
  • 61cvsblobprodwcus010.vsblob.vsassets.io
    • Triggering command: npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (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)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (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:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] [BUG]: DotNetCoreCLI@2 doesn't fail when asked to run tests that don't exist Fix DotNetCoreCLI@2 test command to fail when no project files found Aug 6, 2025
@Copilot Copilot AI requested a review from raujaiswal August 6, 2025 04:34
Copilot finished work on behalf of raujaiswal August 6, 2025 04:34
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 doesn't fail when asked to run tests that don't exist
2 participants