zoukankan      html  css  js  c++  java
  • 2019-2-18-VisualStudio-给项目添加特殊的-Nuget-的链接

    title author date CreateTime categories
    VisualStudio 给项目添加特殊的 Nuget 的链接
    lindexi
    2019-02-18 15:56:48 +0800
    2019-02-18 15:56:36 +0800
    VisualStudio

    有一些项目需要使用一些特殊的 Nuget 才可以下载,但是不能在开源的项目需要小伙伴下载仓库在自己的 VisualStudio 修改自己的 Nuget 链接才能编译,本文告诉大家将某个项目独立的 Nuget 配置放在一个文件

    如果有安装 dotnet core 的小伙伴,只需要在项目所在的文件夹输入下面代码就可以创建 Nuget 配置文件

    dotnet new nuget

    就可以看到在 csproj 文件所在的文件夹看到 nuget.config 文件,里面大概有下面代码

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
     <packageSources>
        <!--To inherit the global NuGet package sources remove the <clear/> line below -->
        <clear />
        <add key="nuget" value="https://api.nuget.org/v3/index.json" />
     </packageSources>
    </configuration>
    
    

    假如我需要通过 myget 下载一些没发布的库,可以在这个文件做下面的修改

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
     <packageSources>
        <!--To inherit the global NuGet package sources remove the <clear/> line below -->
        <clear />
        <add key="nuget" value="https://api.nuget.org/v3/index.json" />
        <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
     </packageSources>
    </configuration>
    
    

    但是我自己全局也有一些特殊的 Nuget 库,这时就可以将 clear 去掉

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
     <packageSources>
        <!--To inherit the global NuGet package sources remove the <clear/> line below -->
        <!-- <clear /> 取消注释将会让全局的配置失效,被清空,只使用下面定义的 Nuget 下载-->
        <add key="nuget" value="https://api.nuget.org/v3/index.json" />
        <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
     </packageSources>
    </configuration>
    
    
  • 相关阅读:
    东边日出西边雨
    ZooKeeper学习(一)了解ZooKeeper
    linux学习(七)文件打包和压缩命令
    linux学习(六)Linux yum 命令
    linux学习(五)Linux 文件与目录管理
    linux学习(四)Linux 文件基本属性
    linux学习(三)Linux 系统目录结构
    linux学习(二)认识Linux
    linux学习(一)认识阿里云
    多线程实战【面试题形式】
  • 原文地址:https://www.cnblogs.com/lindexi/p/12085784.html
Copyright © 2011-2022 走看看