默认配置:

  默认配置文件的路径%APPDATA%\NuGet\NuGet.Config (DOS) 或 $ENV:APPDATA\NuGet\NuGet.Config (PowerShell),(例如  D:\Users\username\AppData\Roaming\NuGet\NuGet.config)我们可以增加配置文件修改默认配置,

默认的配置文件如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<activePackageSource>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</activePackageSource>
</configuration>

  配置文件说明:(http://docs.nuget.org/docs/reference/nuget-config-settings)

  1. 自定义nuget 包路径。

  <config>
       <add key="repositorypath" value="C:\Temp" />
     </config>

  2。自动检查缺失包和自动恢复

<packageRestore>
        <!-- Allow NuGet to download missing packages -->
        <add key="enabled" value="True" />

<!-- Automatically check for missing packages during build in Visual Studio -->
        <add key="automatic" value="True" />
    </packageRestore>

  3.执行包寻找路径

  PackageSources:指定包来源地址

  DisabledPackageSources:禁止的来源地址

  ActivePackageSource:指定为”(Aggregate source)“为除了禁止的来源地址的所有包来源地址

<packageSources>
        <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
        <add key="TestSource" value="C:\Temp" />
    </packageSources>
    <disabledPackageSources />
    <activePackageSource>
        <add key="All" value="(Aggregate source)"  />
    </activePackageSource>

  4。禁止源代码管理整合

  <configuration>
    <solution>
      <add key="disableSourceControlIntegration" value="true" />
    </solution>
  </configuration>

  5. 其他,代理设置 ,身份验证设置,设置API Key 访问包来源

  完整的实例

  

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!--
Used to specify the default location to expand packages.
See: NuGet.exe help install
See: NuGet.exe help update
-->
<add key="repositorypath" value="External\Packages" />
<!--
Used to specify default source for the push command.
See: NuGet.exe help push
-->
<add key="DefaultPushSource" value="http://MyRepo/ES/api/v2/package" />
<!--
Proxy settings
-->
<add key="http_proxy" value="host" />
<add key="http_proxy.user" value="username" />
<add key="http_proxy.password" value="encrypted_password" />
</config>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" /> <!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<!--
Used to specify the default Sources for list, install and update.
See: NuGet.exe help list
See: NuGet.exe help install
See: NuGet.exe help update
-->
<packageSources>
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
<add key="MyRepo - ES" value="http://MyRepo/ES/nuget" />
</packageSources>
<!-- used to store credentials -->
<packageSourceCredentials />
<!-- Used to specify which one of the sources are active -->
<activePackageSource>
<!-- this tells only one given source is active -->
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
<!-- this tells that all of them are active -->
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<!-- Used to disable package sources -->
<disabledPackageSources />
<!--
Used to specify default API key associated with sources.
See: NuGet.exe help setApiKey
See: NuGet.exe help push
See: NuGet.exe help mirror
-->
<apikeys>
<add key="http://MyRepo/ES/api/v2/package" value="encrypted_api_key" />
</apikeys>
</configuration>

  (http://docs.nuget.org/docs/reference/nuget-config-settings)

  自定义配置文件寻找规则:

  1.nuget默认配置文件链,默认配置文件(nuget.config)路径——当前磁盘根目录——当前目录。

  当前目录指:nuget.exe 执行的目录或者当前解决方案加载的目录。

  2.nuget.config配置文件读取顺序,

  例:当前解决方案的路径为c:\a\b\c,那么配置文件的加载加载规则如下 

  • c:\a\b\c\.nuget\nuget.config
  • c:\a\b\c\nuget.config
  • c:\a\b\nuget.config
  • c:\a\nuget.config
  • c:\nuget.config
  • 指定的配置文件源, %AppData%\NuGet\nuget.config.
  • 用户通过配置指定的文件

  nuget 2.6以后扩展了部分加载规则,除了上述的路径外,还会从以下路径寻找

  • %ProgramData%\NuGet\Config{IDE}{Version}{SKU}*.config, e.g. %ProgramData%\NuGet\Config\VisualStudio{VSVersion}\Pro\a.config
  • %ProgramData%\NuGet\Config{IDE}{Version}*.config
  • %ProgramData%\NuGet\Config{IDE}*.config
  • %ProgramData%\NuGet\Config*.config

  

  ( http://docs.nuget.org/docs/reference/nuget-config-file)

  

NuGet 自定义配置的更多相关文章

  1. NuGet:自定义配置信息(2)

    有些类库项目打包后,如何让别人引用的时候自动添加上对应的配置项目呢,比如EntityFramework的NuGet包,打开后可以看到类似下面的结构: 空白处右击——Add Content Folder ...

  2. Nuget 自定义配置(官网)

    <?xml version="1.0" encoding="utf-8"?> <configuration> <config> ...

  3. ASP.NET系列:自定义配置节点的复用

    appSettings太简单,为每个程序自定义配置节点太复杂,因此要解决app.config&web.config自定义配置的复用问题. 1.读取不依赖SectionName,根节点可以定义为 ...

  4. ASP.NET 5 入门 (2) – 自定义配置

    ASP.NET 5 入门 (2) – 自定义配置 ASP.NET 5 理解和入门 建立和开发ASP.NET 5 项目 初步理解ASP.NET5的配置 正如我的第一篇文章ASP.NET 5 (vNext ...

  5. 基于Spring的可扩展Schema进行开发自定义配置标签支持

    一.背景 最近和朋友一起想开发一个类似alibaba dubbo的功能的工具,其中就用到了基于Spring的可扩展Schema进行开发自定义配置标签支持,通过上网查资料自己写了一个demo.今天在这里 ...

  6. C#创建自定义配置节

    在.Net应用程序中,我们经常看到VS为我们生成的项目工程中都会含有nfig或者nfig这样的文件.这个文件就是我们所说的应用程序配置文件.在这个文件里面记述着一些与我们的应用程序相关的信息,如:数据 ...

  7. [转]通过继承ConfigurationSection,在web.config中增加自定义配置

    本文转自:http://www.blue1000.com/bkhtml/2008-02/55810.htm 前几天写了一篇使用IConfigurationSectionHandler在web.conf ...

  8. VS2012 常用web.config配置解析之自定义配置节点

    在web.config文件中拥有一个用户自定义配置节点configSections,这个节点可以方便用户在web.config中随意的添加配置节点,让程序更加灵活(主要用于第三方插件的配置使用) 自定 ...

  9. C#如何使用和开发自定义配置节

    在日常的程序设计中,如何灵活和巧妙地运用配置信息是一个成功的设计师的首要选择.这不仅是为了程序设计得更灵活性和可扩展性,也是为了让你的代码给人以清新的感觉.程序中的配置信息一般放在应用程序的app.c ...

随机推荐

  1. JNI之C初探

    JNI是Java Native Interface的缩写,从Java1.1开始,JNI标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互.JNI一开始是为了本地已编译语言,尤其 ...

  2. 基于Asp.Net Core Mvc和EntityFramework Core 的实战入门教程系列-3

    来个目录吧: 第一章 第二章 第三章 暂时就这么多.后面路线更新吧 创建.查询.更新.删除 这章主要讲解使用EF完成 增删改查的功能. 自定义"详情信息"页面 我们通过基架生成的代 ...

  3. MySQL中的完整性约束条件(主键、外键、唯一、非空)

    数据库的完整性约束用来防止对数据的意外破坏,来保证数据的安全性和一致性. 主键 1.创建表时候指定主键 创建表user(id, username, age),并且id字段非空自增. CREATE TA ...

  4. sys模块和Python常用的内建函数

    1.sys模块 当Python执行import sys语句的时候,它在sys.path变量中所列目录中寻找sys.py模块.如果找到了这个文件,这个模块的主块中的语句将被运行,然后这个模块将能够被使用 ...

  5. linux CentOS6.5 安装SVN & 可视化管理工具iF.SVNAdmin

    转:http://tanghenxin.lofter.com/post/1cc667b3_5ac50dc 实际系统环境: CentOS 6.5 x64 一.安装Apache 通常系统都已经装好了,但我 ...

  6. Python中类的方法属性与方法属性的动态绑定

    最近在学习python,纯粹是自己的兴趣爱好,然而并没有系统地看python编程书籍,觉得上面描述过于繁琐,在网站找了一些学习的网站,发现廖雪峰老师的网站上面的学习资源很不错,而且言简意赅,提取了一些 ...

  7. oracle图形界面乱码

    oracle界面乱码解决方案 在Linux的中文操作系统下使用xmanager进行Oracle进行安装的时候,可能出现乱码界面,可以通过以下方法进行解决 1 修改环境属性  vi /etc/sysco ...

  8. java对String进行sha1加密

    1.使用apache的codec jar包对string进行加密,先下载并引入jar包: http://commons.apache.org/proper/commons-codec/ 2.生成: S ...

  9. C++获取字符cin,getchar,get,getline的区别

    原创作品,转载请注明来源:http://www.cnblogs.com/shrimp-can/p/5241544.html 1.cin>> 1)最常见的是获取输入的一个字符或数字,如 in ...

  10. RegExp类型(正则表达式)

    直接量语法 /pattern/attributes 创建 RegExp 对象的语法: new RegExp(pattern, attributes); 一.attributes: 修饰符 描述 i 执 ...