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

[BUG] Renaming .csproj results in build errors in dependent projects due to cache #850

Open
Tungsten78 opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member

Comments

@Tungsten78
Copy link
Contributor

Tungsten78 commented Apr 19, 2024

Current Behavior

When renaming a .csproj without touching any other files under the {projectRoot}

  • nx build {my-project} results in a cache hit (false positive), using invalidated cache outputs - the output assembly name changed

In the process of renaming the .csproj, dependent projects have their respective .csproj updated with renamed ProjectReference

  • nx build will properly rebuild these, however the cached result of the renamed project causes build failures

Root causing it appears the computational cache is at fault.
It correctly includes file contents, and new files. BUT ignore renames of existing files.

Workarounds:

  • --skip-nx-cache
  • touch/change the file contents of the renamed file to force the cache hash to change

Expected Behavior

nx build {my-project} should not use a cached result after renaming the csproj under {my-project}.

Github Repo

No response

Steps to Reproduce

  1. Create projects A and B, where B references A.
  2. Build to establish cache
  3. rename A.csproj, update B.csproj accordingly
  4. Build B

Nx Report

 nx-vigil  nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 20.10.0
   OS     : win32-x64
   npm    : 10.5.0

   nx (global)        : 17.1.2
   nx                 : 17.2.8
   @nx/js             : 17.2.8
   @nx/jest           : 17.2.8
   @nx/linter         : 17.2.8
   @nx/eslint         : 17.2.8
   @nx/workspace      : 17.2.8
   @nx/angular        : 17.2.8
   @nx/cypress        : 17.2.8
   @nx/devkit         : 17.0.2
   @nx/eslint-plugin  : 17.2.8
   @nrwl/tao          : 17.2.8
   @nx/web            : 17.2.8
   @nx/webpack        : 17.2.8
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @auth0/auth0-angular         : 2.2.1
   @ngrx/component              : 17.0.1
   @ngrx/component-store        : 17.0.1
   @nx-dotnet/core              : 2.1.1
   @nx-tools/nx-container       : 5.1.0
   @nxlv/python                 : 17.0.0
   @trumbitta/nx-plugin-openapi : 1.12.1
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nx/devkit@17.0.2
     - @nrwl/devkit@17.0.2

   To fix this, run `nx migrate nx@17.2.8`

nx.json

{
  "plugins": ["@nx-dotnet/core", "@nxlv/python", "@nx-tools/nx-container"],
  "workspaceLayout": {
    "projectNameAndRootFormat": "derived",
    "appsDir": "apps",
    "libsDir": "libs"
  },
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": [
      "default",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/jest.config.[jt]s",
      "!{projectRoot}/.eslintrc.json",
      "!{projectRoot}/cypress/**/*",
      "!{projectRoot}/**/*.cy.[jt]s?(x)",
      "!{projectRoot}/cypress.config.[jt]s",
      "!{projectRoot}/src/test-setup.[jt]s"
    ],
    "sharedGlobals": []
  },
  "targetDefaults": {
    "serve": {
      "dependsOn": ["codegen", "^codegen"],
      "inputs": ["production", "^production"]
    },
    "build": {
      "dependsOn": ["^build", "codegen", "^codegen"],
      "inputs": ["production", "^production"],
      "cache": true
    },
    "component-test": {
      "inputs": ["default", "^production"],
      "outputs": ["{projectRoot}/cypress/results"],
      "cache": true
    },
    "test": {
      "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
      "outputs": [
        "{projectRoot}/junit.xml",
        "{projectRoot}/test-results.xml",
        "{workspaceRoot}/coverage/{projectRoot}"
      ],
      "cache": true
    },
    "e2e": {
      "inputs": ["default", "^production"],
      "outputs": ["{projectRoot}/cypress/results"],
      "cache": true
    },
    "@nx-dotnet/core:build": {
      "dependsOn": ["^build", "codegen", "^codegen"],
      "inputs": [
        "default",
        "production",
        "^production",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/Directory.Build.props",
        "{workspaceRoot}/Directory.Build.targets",
        "{workspaceRoot}/Directory.Packages.props"
      ],
      "cache": true
    },
    "@nx-dotnet/core:test": {
      "inputs": [
        "default",
        "^production",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/Directory.Build.props",
        "{workspaceRoot}/Directory.Build.targets",
        "{workspaceRoot}/Directory.Packages.props"
      ],
      "outputs": ["{projectRoot}/TestResults"],
      "cache": true
    },
    "@nxlv/python:build": {
      "options": {
        "outputPath": "{workspaceRoot}/dist/{projectRoot}"
      }
    },
    "publish": {
      "cache": true
    },
    "lint": {
      "cache": true
    },
    "swagger": {
      "cache": true
    },
    "codegen": {
      "cache": true
    },
    "preview": {
      "cache": true
    },
    "@nx/jest:jest": {
      "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
      "outputs": [
        "{projectRoot}/junit.xml",
        "{projectRoot}/test-results.xml",
        "{workspaceRoot}/coverage/{projectRoot}"
      ],
      "cache": true,
      "options": {
        "passWithNoTests": true
      },
      "configurations": {
        "ci": {
          "ci": true,
          "codeCoverage": true
        }
      }
    }
  },
  "affected": {
    "defaultBase": "master"
  },
  "generators": {
    "@nx-dotnet/core:application": {
      "language": "C#",
      "template": "webapi",
      "testTemplate": "xunit",
      "tags": "type:app"
    },
    "@nx-dotnet/core:library": {
      "language": "C#",
      "template": "classlib",
      "testTemplate": "xunit"
    },
    "@nx/angular:application": {
      "style": "scss",
      "linter": "eslint",
      "unitTestRunner": "jest",
      "e2eTestRunner": "none",
      "addTailwind": true,
      "standalone": true,
      "inlineTemplate": true,
      "inlineStyle": true,
      "skipTests": true,
      "tags": "type:app"
    },
    "@nx/angular:library": {
      "linter": "eslint",
      "unitTestRunner": "jest",
      "style": "scss",
      "skipModule": true,
      "standalone": true,
      "inlineTemplate": true,
      "inlineStyle": true,
      "skipTests": true
    },
    "@nx/angular:component": {
      "style": "scss",
      "standalone": true,
      "changeDetection": "OnPush",
      "inlineTemplate": true,
      "inlineStyle": true,
      "flat": true,
      "skipTests": true
    }
  },
  "parallel": 3
}

Failure Logs

No response

Additional Information

No response

@Tungsten78 Tungsten78 added bug Something isn't working needs-triage This issue has yet to be looked over by a core team member labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member
Projects
None yet
Development

No branches or pull requests

1 participant