0

We are facing below error while running build.cake

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

please provide any work around for this

Note : Already we tried long path module like below manner

build.ps1 :

#Load Longpath Module
Write-Host "Restoring long path module..."
try
{
echo $PSScriptRoot
Invoke-Expression "& cmd /c $PSScriptRoot/longpath.cmd"
} 
catch{
    throw new Exception("Long path nuget not restored.");
}

created lonpath.cmd file and restored longpath module nugets in modules folder and called build cake at end of line of cmd file like below

`

@ECHO OFF
pushd %~dp0
IF NOT EXIST "%~dp0\tools" (md "tools")
IF NOT EXIST "%~dp0\tools\modules" (md "tools\modules")
IF NOT EXIST "%~dp0\tools\nuget.exe" (@powershell -NoProfile -ExecutionPolicy Bypass -Command "(New-Object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe','tools/nuget.exe')")
IF NOT EXIST "%~dp0\tools\Cake" (tools\nuget.exe install Cake -ExcludeVersion -OutputDirectory "Tools" -Source https://www.nuget.org/api/v2/)
IF NOT EXIST "%~dp0\tools\modules\Cake.LongPath.Module" (tools\nuget.exe install Cake.LongPath.Module -PreRelease -ExcludeVersion -OutputDirectory "%~dp0\tools\modules" -Source https://www.nuget.org/api/v2/)
%~dp0\tools\Cake\Cake.exe build.cake -target="LoadlongPath"

build.cake

Task("LoadlongPath")
.Does(() =>
{
var fileSystemType = Context.FileSystem.GetType();

Information(fileSystemType.ToString());
if (fileSystemType.ToString()=="Cake.LongPath.Module.LongPathFileSystem")
{
    Information("Suscessfully loaded {0}", fileSystemType.Assembly.Location);
}
else
{
    Error("Failed to load Cake.LongPath.Module");
}
});
vijay
  • 701
  • 2
  • 12
  • 26
  • 1
    So currently the long path module isn't compile for 0.22.0 so it's not fully compatible. I'll release a version later today that's compiled against 0.22.0. – devlead Oct 06 '17 at 06:02

1 Answers1

0

Maybe my answer could be of help for you. We were facing a similar issue but we were able to solve it by setting an environment variable for NuGet. NuGet is by default storing the packages in local repository C:\users\\AppData.nuget\packages. We have configured environment variable "NUGET_PACKAGES" to c:\npkg. By doing so the packages are extracted in c:\npkg and are then installed to the defined output directory. BR MT

Mr. T
  • 167
  • 1
  • 7