Cake build.ps1 fails to install Cake

余生长醉 提交于 2020-04-14 08:08:11

问题


We use the standard build.ps1 PowerShell script supplied from Cakebuild.net

It's worked splendid on both CI and developer machines, but for 1 of our developers we get the following error when launching build.ps1

Unable to find package 'Cake'

And then exits, checking tools folder there's no Cake installed.


回答1:


The error you're getting is because NuGet console can't find the Cake package among the configured feeds on the machine.

You can test this theory by changing the following line in build.ps

$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

To

$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`" -Source `"https://www.nuget.org/api/v2`""

If that works your colleagues machine likely lacks or have the standard nuget.org feeds disabled on his machine.

You can list which sources you have configured by using the NuGet console like this (if you don't have nuget console in path it should be avail in the repo tools folder)

nuget sources list

It should then list v2 and/or v3 feed for nuget.org and they should have the text [Enabled] after them like below

Registered Sources:

  1.  https://www.nuget.org/api/v2/ [Enabled]
      https://www.nuget.org/api/v2/
  2.  https://api.nuget.org/v3/index.json [Enabled]
      https://api.nuget.org/v3/index.json

If they're listed but disabled you can enable them by typing

nuget source enable -Name https://www.nuget.org/api/v2/

Or

nuget source enable -Name  https://api.nuget.org/v3/index.json

Depending on which feed you have registered & disabled, if the sources are missing then you can add them by typing

nuget sources add -Name https://www.nuget.org/api/v2/ -Source  https://www.nuget.org/api/v2/

Settings are stored in %AppData%\NuGet\NuGet.config so you could manually edit that file, to make sure everyone uses same sources in team you could add a NuGet.config to the root of the repository as nuget tries to find config in path and then falls back to app data.



来源:https://stackoverflow.com/questions/38792473/cake-build-ps1-fails-to-install-cake

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!