Enable NuGet to be centrally controlled by an administrator using group policy.
As we have talked to more customers using NuGet within a large enterprise, the issue has come up repeatedly that it is too easy for developers to install non-sanctioned packages in their projects. This can introduce the enterprise to a range of potential problems from licensing issues to security concerns. Moreover, the public NuGet gallery is enabled for NuGet by default and there is no way for an administrator to disable it for all developer environments.
Additionally, we have observed on a few occasions where an enterprise developer has accidentally pushed what was intended to be an internal NuGet package to the public NuGet gallery. This is a very easy mistake for a developer to make, since – after registering her API key – could be made by simply running the command nuget push
We want to enable core NuGet configuration, including control over available package sources, to be centrally managed using technologies like Windows group policy. This will enable administrators within an enterprise to implement policy around approved packages for development projects. By giving administrators the ability to centrally disable the public NuGet gallery, it can also mitigate the risk of an enterprise developer accidentally publishing an internal package to the public gallery. Administrators can use the Windows Group Policy to set the aforementioned collection of settings or policies So, a file will be used to maintain the collection of settings or policies to be honored by all the NuGet Clients. This will be the NuGet Defaults Config File NuGet Defaults Config File, NuGetDefaults.config, will be located under %PROGRAMDATA%\NuGet folder. Administrators
are expected to set the correct permissions on this file based on the user and/or machine information NuGet Defaults Config File, to begin with, will capture the default package source(s) that the enterprise wants their developers to be using. These default package sources cannot be deleted or modified but may be disabled.
Today, if someone deletes the NuGet Official Package Feed from %appdata%, it is rehydrated as disabled if another package source exists or as enabled if no package source exists. In the same way, now, there will be a set of default package sources instead of just the 1 feed. Note that we still fallback to NuGet Official Feed if there are no Default Package Sources.
However, if there are DefaultPackageSources and NuGetOfficialFeed is NOT one of them, it WILL NOT BE REHYDRATED In addition, NuGet Defaults Config File will also support DefaultPushSource. This will be the defaultPushSource if one is NOT provided in the command line argument of NuGet.exe.
Note that, today, by default, PushSource is the NuGet Official Feed. Using the new configuration though, administrators can change the PushSource used by default. This will help prevent accidental publishing of packages onto NuGet Official Feed which is a public feed.
Unless, one explicitly uses the source parameter for publishing, the DefaultPushSource set by administrator will get used NuGetDefaults.config will support the following cases Following are the list of issues and scenarios that are not planned for 2.7. Based on customer feedback, we might include it in 2.7 or might do add this in the future For comments, suggestions, or any other feedback on this working spec, please use the corresponding CodePlex discussion page here:
https://nuget.codeplex.com/discussions/445625Solution
Goals
Non-Goals
Customer asks
Problems and Solutions
NuGet Defaults Config File
Sample
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- DefaultPushSource key is similar to the 'DefaultPushSource' key of NuGet.config schema-->
<!-- This can be used by administrators to prevent accidental publishing of packages to
NuGet Official Feed which is a public feed -->
<config>
<add key="DefaultPushSource" value="http://contoso.com/packages/" />
</config>
<!-- Default Package Sources -->
<!-- They cannot be deleted or modified but can be disabled/enabled by user -->
<!-- The following section is similar to 'packageSources' section of NuGet.config schema -->
<packageSources>
<add key="Contoso Package Source" value="http://contoso.com/packages/" />
<add key="NuGet Official Feed" value="http://nuget.org/api/v2/" />
</packageSources>
<!-- Default Package Sources that are Disabled by Default -->
<!-- They cannot be modified or deleted either but can be enabled/disabled by user -->
<!-- The following section is similar to 'disabledPackageSources' section of NuGet.config schema-->
<disabledPackageSources>
<add key="NuGet Official Feed" value="true" />
</disabledPackageSources>
</configuration>
Open Issues and Scenarios
Discussion