如何避免蛋糕制造中的长路问题



我们在运行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文件的末端称为"构建蛋糕",如下面的

`

@ECHO OFF
pushd %~dp0
IF NOT EXIST "%~dp0tools" (md "tools")
IF NOT EXIST "%~dp0toolsmodules" (md "toolsmodules")
IF NOT EXIST "%~dp0toolsnuget.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 "%~dp0toolsCake" (toolsnuget.exe install Cake -ExcludeVersion -OutputDirectory "Tools" -Source https://www.nuget.org/api/v2/)
IF NOT EXIST "%~dp0toolsmodulesCake.LongPath.Module" (toolsnuget.exe install Cake.LongPath.Module -PreRelease -ExcludeVersion -OutputDirectory "%~dp0toolsmodules" -Source https://www.nuget.org/api/v2/)
%~dp0toolsCakeCake.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");
}
});

也许我的答案可能对您有帮助。我们面临类似的问题,但我们能够通过为Nuget设置环境变量来解决它。默认情况下,Nuget将软件包存储在本地存储库中: Users \ AppData.nuget packages。我们已经将环境变量" Nuget_packages"配置为C: npkg。通过这样做,包装将在C: npkg中提取,然后安装到定义的输出目录中。brMT

最新更新