Update .NET Profile Directory Resolution
When using a .NET Profile, the NuGet packages directory stored in the <Dirs> element of the project is fully resolved to include the username. This poses a problem when committing the ndproj file to source control since the project settings are specific to a developer machine. It would be better to use %userprofile% instead:
%userprofile%\.nuget\packages
Even further, would it be best to just store the .NET Profile configuration itself in the ndproj project file instead of the corresponding paths? The resolved paths could possibly be saved in the suo file instead. This would also help resolve issues when there are different versions of .NET installed on each developer machine.
Completed with NDepend version 2022.2.0
-
Travis Schettler commented
This actually exacerbates the issue, since this means the files will be continuously updated by different developers who use NDepend. Since we are managing these files in source control, this could result in a lot of unnecessary churn on these files.
Our goal is to start with a standard NDepend setup across all of our projects so they are all measured in the same way. This requires consistency in the project setup and we also want to require approval for changes to the ndproj file in order to ensure consistency. It is not ideal for the committed NDepend project file to change when NDepend loads the project, as this will almost always result in a change to the pre-configured NDepend project file.
-
FYI when NDepend loads a project on a machine all those paths gets updated based on the Window user running the NDepend process and an heuristic to locate those paths on the current machine. Does it help?
-
Travis Schettler commented
Thanks for the response Patrick. This seems like it should work, but it doesn't. The setting is added, but the existing user profile information is still present in the ndproj file. Attempts to remove it do not succeed, it just comes back again. Here's what I see in the ndproj file after setting the path with an environment variable:
<Dirs>
<Dir>C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.22</Dir>
<Dir>C:\Program Files\dotnet\sdk\NuGetFallbackFolder</Dir>
<Dir>C:\Users\tschettler\.nuget\packages</Dir>
<Dir>%userprofile%\.nuget\packages</Dir>
</Dirs>I prefer not to have any paths from the developer machine in the ndproj file since we plan to commit the file to source control, as per suggestion here: https://www.ndepend.com/docs/ndepend-storage-and-files#guidances-scm
Every other path referenced in the ndproj file can be modified to be developer-agnostic. The <Dirs/> element is driven mainly on the .NET Profile setting. I think the ideal solution would be to store these paths outside of the ndproj file and just store the .NET Profile setting in the ndproj file.
-
In the NDepend Project Properties > Paths referenced, any path referenced by the project can be prefixed with an environment variable like %USERPROFILE%, does it solve this need?