我们在运行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.
请为此提供任何解决方法
注意:我们已经尝试过如下方式的长路径模块
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.");
}
创建lonpath.cmd文件并恢复模块文件夹中的longpath模块nugets,并在cmd文件末尾调用build cake,如下所示
`
@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");
}
});
答案 0 :(得分:0)
也许我的回答对你有帮助。 我们遇到了类似的问题,但我们能够通过为NuGet设置环境变量来解决它。 默认情况下,NuGet将包存储在本地存储库C:\ users \\ AppData.nuget \ packages中。 我们已将环境变量“NUGET_PACKAGES”配置为c:\ npkg。 通过这样做,包将在c:\ npkg中提取,然后安装到定义的输出目录中。 BR MT