Recently, we encountered a build error in one of our Dynamics 365 projects where Visual Studio was unable to find metadata files for NuGet packages, even though the packages were installed.
CSC : error CS0006: Metadata file ‘C:\Users\NishantRana\source\repos\Compass Optimisation\ABC.Xrm.Solution\packages\ABC.Extensions.1.0.3\lib\netstandard2.0\ABC.Extensions.dll’ could not be found

On checking the packages folder, we could see that all our the ABC.Extensions / ABC.Xrm.Common DLLs were present in their respective directories. However, the build was still failing with the CS0006 error.
What was tried first – A typical CS0006 checklist includes:
Clean + Rebuild the entire solution.
Delete bin and obj folders and rebuild.
Restore NuGet packages
Verify the project references and hint paths in the .csproj file.
All of the above were tried, but the CS0006 errors persisted for the assemblies , even though other package references worked fine.
After some investigation, we noticed something interesting in the error message – the repository path contained a space: “Compass Optimisation“
Some tools, build scripts, or older MSBuild / custom targets can still be sensitive to spaces in paths, especially if any custom build logic concatenates paths without proper quoting. In this case, the the assemblies were referenced from packages, but the effective build path that MSBuild/targets resolved appeared to break because of the space in the parent folder name.
To confirm this, a new Git repo and solution were created in a folder without spaces:
C:\Users\NishantRana\source\repos\CompassOptimisation\ABC.Xrm.Solution\…
After moving the solution and re‑cloning into CompassOptimisation (no space), restoring packages, and rebuilding, the CS0006 errors disappeared and the project built successfully.
So the issue was caused by the space in the repository folder name. While modern development tools generally handle spaces in paths, some parts of the MSBuild or NuGet resolution process still struggle with them, causing the compiler to incorrectly parse the file paths.
The solution here is to avoid using spaces in your repository or project folder names. Use naming conventions like PascalCase (CompassOptimisation), kebab-case (compass-optimisation), or snake_case (compass_optimisation) instead.
Hope it helps..
