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>
    
    
  • 相关阅读:
    如何使用API创建OpenStack虚拟机?
    Windows Server 2012 新特性:IPAM的配置
    DNSSec
    Win Server 8中的利器:微软在线备份服务
    AD RMS总结
    开发中辅助功能
    开发中坑爹的地方
    Js 中常用方法
    asp.net 错误处理
    js中的注意事项(持续整理)
  • 原文地址:https://www.cnblogs.com/lindexi/p/12085784.html
Copyright © 2011-2022 走看看