Skip to content
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

fix(core): prevent stale cache entries from breaking swagger on dotnet upgrades #633

Merged
merged 1 commit into from
Feb 27, 2023

Conversation

AgentEnder
Copy link
Member

Root Cause Analysis

Hit a weird issue when updating to .NET 7.

  • Updating .NET changes the subdir within output path that contains your code (e.g. dist/apps/my-api/bin/net7.0 instead of dist/apps/my-api/bin/net6.0).
  • We infer the path to your output when extracting swagger documentation, by globbing for .dll files that match your project's name inside of the root dist folder and using the first match. (e.g. glob(dist/apps/my-api/**/my-api.dll)[0])
  • If you don't remember to clean the dist folder, the .NET build's old results end up in the nx cache.

All of the above combined get you a poisoned cache for nx build my-api that causes nx swagger my-api to fail.

Fix

  • swagger executor will error appropriately when it finds multiple matching DLLs, instead of using the first silently. If you target is meant to create multiple DLLs that would match the glob we use, you can and should manually specify the assembly path in project.json.
  • build executor should clean old artifacts to prevent bad cache entries from cropping up.

@nx-cloud
Copy link

nx-cloud bot commented Feb 27, 2023

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@AgentEnder AgentEnder merged commit 71f6893 into master Feb 27, 2023
@AgentEnder AgentEnder deleted the fix/misc/update-dotnet-old-cache branch February 27, 2023 17:37
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant