如何设置TFS NuGet还原以从sln文件中获取所有需要的版本?

时间:2017-05-22 14:10:37

标签: tfs nuget tfsbuild nuget-package nuget-package-restore

我正在使用TFS步骤恢复我的NuGet包。 在"解决方案路径或packages.config" 字段中,我设置了sln文件的路径。  我得到的问题是,在我的解决方案中,我有两个项目:

项目" A"引用" commom.package"版本1.1

项目" B"引用" commom.package"版本1.3

在恢复步骤之后,我只在包目录中获得1.3版本,并且在项目" A"之后编译后我可以在" bin \ release"中看到文件夹拥有1.3版本而不是1.1版本。

我该如何解决这个问题?我是否需要为解决方案中的每个项目设置还原 - 意味着每个package.config文件?

1 个答案:

答案 0 :(得分:1)

nuget restore task只是使用#include <iostream> using namespace std; class Test { public: int a, b, c; Test(int x, int y, int z) { a = x; b = y; c = z; } void print() { cout << "a= " << a << "b= " << b << "c= " << c << endl; } }; class Test2 : public Test { public: int d, e; Test2(int a, int b, int c, int x, int y) : Test(a, b, c) { d = x; e = y; } virtual void print() { cout << "d= " << d << "e= " << e << endl; } }; class Test3 : public Test2 { public: int f; Test3(int a, int b, int c, int d, int e, int x) : Test2(a, b, c, d, e) { f = x; } void print() { cout << "f= " << f << endl; } }; class Test4 : public Test3 { public: int g; Test4(int a, int b, int c, int d, int e, int f, int x) : Test3(a, b, c, d, e, f) { g = x; } void print() { cout << "g= " << g << endl; } }; int main() { Test *test; Test2 *test2; Test3 *test3; Test4 test4(1, 2, 3, 4, 5, 6, 7); test = &test4; test2 = &test4; test3 = &test4; test->print(); test2->print(); test3->print(); test4.print(); return 0; } 命令来恢复软件包。如果在本地使用nuget.exe命令,也会得到相同的结果。 nuget.exe是项目级别,而不是解决方案级别。因此,如果您在这种情况下直接恢复解决方案,它将只获得一个适用于这两个项目的1.3版本。

但是在VS中,有一个选项 在Visual Studio中构建期间自动检查缺少的包 。您将在VS恢复中同时获得版本1.1和1.3。

enter image description here

要解决此问题,您必须为每个package.config文件设置还原。与恢复整个解决方案不同,您还需要在任务的NuGet Arguments中使用Package.conifg