[英]Make dotnet publish use dependencies from bin folder and not from nuget cache
In my CI I build and publish .net app on different stages.在我的 CI 中,我在不同阶段构建并发布 .net 应用程序。
On build stage I do dotnet build
and it creates obj
and bin
folders.在构建阶段,我进行
dotnet build
并创建obj
和bin
文件夹。 I then pass that two folders to publish stage and run dotnet publish -o pub --no-build
, but msbuild tries to copy dependencies from nuget cache folder ( .nuget/packages
) and not from bin
.然后我将这两个文件夹传递给发布阶段并运行
dotnet publish -o pub --no-build
,但 msbuild 尝试从 nuget 缓存文件夹( .nuget/packages
)而不是bin
复制依赖项。
Is there a way to make dotnet publish
use dependencies from bin
folder?有没有办法让
dotnet publish
使用bin
文件夹中的依赖项? I do not want to pass whole .nuget
folder from the first stage, as all the dependencies already stored inside bin
anyway.我不想从第一阶段传递整个
.nuget
文件夹,因为无论如何所有依赖项都已经存储在bin
中。
May I ask why do you need the explicit dotnet build
when dotnet publish
does build under the hood by default?我可以问一下,当
dotnet publish
默认在后台构建时,为什么需要显式dotnet build
? Maybe this can help?也许这可以帮助?
If consistency in packages cache is the goal, another approach would be to explicitly execute dotnet restore
(maybe even to an agent temp folder), and then use that package cache in both dotnet build
and dotnet restore
.如果包缓存的一致性是目标,另一种方法是显式执行
dotnet restore
(甚至可能是代理临时文件夹),然后在dotnet build
和dotnet restore
中使用 package 缓存。
dotnet restore app\app.csproj
dotnet build app\app.csproj --no-restore
dotnet publish app\app.csproj -o pub --no-restore
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.