What is the function of "nugetPackages" in .nx-dotnet.rc.json? #609
-
TLDR; why is this file important? When using the Initially, after having used the
Using |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
We track packages here as a way of enforcing single version principle, which is a concept and practice that the team at Nx and Nx users tend to favor. For the use in nx-dotnet, this issue may clear up some of the confusion: #562 |
Beta Was this translation helpful? Give feedback.
-
Nx has a "single version policy" by default to ensure that (in a JS workspace), all projects use the same versions of npm packages. We wanted to adopt a similar policy for .NET projects contained within an Nx workspace. However, .NET requires that all packages used by a given project must be listed in that project's You have discovered a rather interesting bug in this approach. nx-dotnet can only save the versions for packages that were installed through its generators. The two packages in your example were pre-installed by the .NET template you chose. Thus, nx-dotnet didn't know to save them to its config file. Similarly, the config file won't contain any packages that were installed through the dotnet CLI or through Visual Studio. One alternative we are considering is to use Central Package Management, a native .NET feature for accomplishing the same goal. Instead of the |
Beta Was this translation helpful? Give feedback.
-
Thank you both. So it's clear what we're trying to do, but I'm trying to understand from the app's point of view what the recourse would be the file were to fall out of sync. AFAIK,
Is there any benefit to having the generators force sync in certain situations? or perhaps a dependency of restore? |
Beta Was this translation helpful? Give feedback.
Nx has a "single version policy" by default to ensure that (in a JS workspace), all projects use the same versions of npm packages. We wanted to adopt a similar policy for .NET projects contained within an Nx workspace. However, .NET requires that all packages used by a given project must be listed in that project's
.csproj
file. The solution we reached was to create a separate file,.nx-dotnet.rc.json
, which contains a full list of all packages installed in all projects, along with the version number of those packages. The first time you install a package via nx-dotnet, it asks for the version number and saves it to that file. On subsequent installs to other projects, nx-dotnet pulls the…