Cake build.ps1 fails to install Cake
Asked Answered
S

1

2

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.

Stranglehold answered 5/8, 2016 at 15:7 Comment(0)
W
6

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.

Wear answered 5/8, 2016 at 15:9 Comment(1)
Wow that answer was actually spot on! Did a nuget sources list on devs machine and nuget.org was disabled. Enabling it worked like a charm, thanks! !disabledStranglehold

© 2022 - 2024 — McMap. All rights reserved.