如何避免蛋糕建设中的长路径问题?

如何避免蛋糕建设中的长路径问题?

问题描述:

我们面临以下错误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.

运行,请提供各地的任何工作,为这个

注意,虽然:我们已经尝试过类似下面的方式

构建长路径模块。 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."); 
} 

创建lonpath.cmd文件,并在模块文件夹复原longpath模块nugets和称为构建饼在CMD文件的行的端像下面

`

@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"); 
} 
}); 
+1

因此目前的长路径模块没有编译0.22.0所以它不是完全兼容。我将在今天晚些时候发布一个针对0.22.0编译的版本。 – devlead

也许我的回答可能对你有帮助。 我们遇到了类似的问题,但我们能够通过为NuGet设置一个环境变量来解决它。 的NuGet是默认存储在本地资源库C中的包:\用户\\ AppData.nuget \包。 我们已将环境变量“NUGET_PACKAGES”配置为c:\ npkg。 通过这样做,包在C萃取:\ npkg然后被安装到所定义的输出目录。 BR MT