2017-08-29 152 views
0

我使用CakeBuild来构建和测试Xamarin可移植类库。CakeBuild:无法安装工具'NUnit.ConsoleRunner'

在build.cake脚本中,我定义了我想使用NUnit-Console来运行我的测试用例。所以我做

#tool nuget:?package=NUnit.ConsoleRunner 

不幸的是我运行Cake脚本时出现以下错误。

Preparing to run build script... 
VERBOSE: Restoring tools from NuGet... 
VERBOSE: Feeds used: 
    C:\Users\bergkar\.nuget\packages\ 

All packages listed in C:\dev\Xamarin\fleetboard-core-library\tools\packages.config are already installed. 
Running build script... 
Analyzing build script... 
Processing build script... 
Installing tools... 
Unable to find package 'NUnit.ConsoleRunner' 
NuGet exited with 1 
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter? 
Error: Failed to install tool 'NUnit.ConsoleRunner'. 

当我添加一个特定的版本,我想像下面使用,那么一切工作正常。

#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0 

有人能告诉我为什么它不工作没有版本的东西?

随着我得到以下输出 “\ build.ps1 -Verbosity诊断”:

Preparing to run build script... 
Running build script... 
Module directory does not exist. 
Analyzing build script... 
Analyzing C:/dev/Xamarin/fleetboard-core-library/build.cake... 
Processing build script... 
Installing tools... 
Installing NuGet package NUnit.ConsoleRunner... 
Executing: "C:/dev/Xamarin/fleetboard-core-library/tools/nuget.exe" install "NUnit.ConsoleRunner" -OutputDirectory "C:/d 
ev/Xamarin/fleetboard-core-library/tools" -ExcludeVersion -NonInteractive 
Unable to find package 'NUnit.ConsoleRunner' 
NuGet exited with 1 
Feeds used: 

Output: 
Feeds used: 

Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter? 
Error: Cake.Core.CakeException: Failed to install tool 'NUnit.ConsoleRunner'. 
    at Cake.Core.Scripting.ScriptProcessor.InstallTools(ScriptAnalyzerResult analyzerResult, DirectoryPath installPath) 
    at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) 
    at Cake.Commands.BuildCommand.Execute(CakeOptions options) 
    at Cake.CakeApplication.Run(CakeOptions options) 
    at Cake.Program.Main() 
+0

如果启动带有诊断冗长的蛋糕,您会得到什么?你应该能够看到如何调用nuget.exe,https://stackoverflow.com/questions/38658660/how-to-enable-diagnostic-verbosity-for-cake – devlead

+0

看到上面,我添加了输出到原来的问题 – Pepper

+0

什么版本的NuGet exe?因为它无法解析软件包。无论如何,对于可重现的版本,我会建议固定一个版本。 – devlead

回答

0

现在我发现我的问题并解决它。

问题是NuGet.exe没有指向像“https://api.nuget.org/v3/index.json”这样的公共nuget源的源提要。

这是因为我在“C:\ Users \ YOUR_USER_HOME \ AppData \ Roaming \ NuGet”下的默认NuGet.conf没有定义packageSource。因此,Nuget只知道“C:\ Users \ YOUR_USER_HOME.nuget \ packages”下的本地nuget包缓存,并且不包含指定的包。

因此,我在“C:\ Users \ YOUR_USER_HOME \ AppData \ Roaming \ NuGet \ NuGet.Conf”中添加packageSource后,一切正常。

另一种方法是在build.ps1文件旁边添加一个新的NuGet.Conf,该文件包含CakeBuild和Xamarin项目所需的所有包源。

下面的页面说明了Nuget如何找到它的配置。也许这有助于了解NuGet使用它来查找其配置的机制: https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

相关问题