简体   繁体   English

使 dotnet 发布使用来自 bin 文件夹而不是来自 nuget 缓存的依赖项

[英]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并创建objbin文件夹。 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 builddotnet 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM