在Linux上更改默认的nuget缓存文件夹

时间:2016-08-04 13:33:45

标签: nuget nuget-package nuget-package-restore nuget-server

我可以在Linux上更改默认的nuget packages文件夹吗?我使用dotnet restore并发现缓存存储在〜/ .nuget / packages中。但这对我来说不方便。谢谢

1 个答案:

答案 0 :(得分:0)

您可以使用--packages env变量执行此操作,也可以在运行dotnet restore时指定dotnet restore --help。 env变量没有记录,因此将来可能会有变化。以下是相关代码的链接:https://github.com/dotnet/cli/blob/rel/1.0.0/build_projects/shared-build-targets-utils/Utils/Dirs.cs#L43

Arguments: [root] List of projects and project folders to restore. Each value can be: a path to a project.json or global.json file, or a folder to recursively search for project.json files. Options: -h|--help Show help information --force-english-output Forces the application to run using an invariant, English-based culture. -s|--source <source> Specifies a NuGet package source to use during the restore. --packages <packagesDirectory> Directory to install packages in. --disable-parallel Disables restoring multiple projects in parallel. -f|--fallbacksource <FEED> A list of packages sources to use as a fallback. --configfile <file> The NuGet configuration file to use. --no-cache Do not cache packages and http requests. --infer-runtimes Temporary option to allow NuGet to infer RIDs for legacy repositories -v|--verbosity <verbosity> The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error. --ignore-failed-sources Only warning failed sources if there are packages meeting version requirement 的输出会为您提供更多详细信息:

#include <iostream>
#include <utility>

template <bool, class T1, class T2, T1, T2>
struct nontype_conditional;

template <class T1, class T2, T1 Foo1, T2 Foo2>
struct nontype_conditional<true, T1, T2, Foo1, Foo2> {
    template<typename ...Args>
    static auto run(Args&&... args) {
        return Foo1(std::forward<decltype(args) && >(args)...);
    }
};

template <class T1, class T2, T1 Foo1, T2 Foo2>
struct nontype_conditional<false, T1, T2, Foo1, Foo2> {
    template<typename ...Args>
    static auto run(Args&&... args) {
        return Foo2(std::forward<decltype(args) && >(args)...);
    }
};

char funW(char) {
    return 'W';
}

char funA(wchar_t) {
    return 'A';
}

constexpr bool value = true;

int main() {
    std::cout << nontype_conditional<value, decltype(funW)&, decltype(funA)&, funW, funA>::run(value ? 'a' : L'a') << std::endl;

    std::cin.get();

    return 0;
}

如果您正在尝试进行离线开发,我还建议您阅读此问题: How do you set up for offline development with .net Core